News:

Function Finder  Find all the functions within source code files

Main Menu

different way to use sprites in PlayBASIC from DarkBASIC

Started by Laskiapina, January 16, 2010, 07:54:36 AM

Previous topic - Next topic

Laskiapina

I'm just migrating from DarkBASIC and having trouble adjusting. What I'm trying to do is cut a sprite from picture and use it as the player image.

PlayBASIC Code: [Select]
loadimage "sprites.png",1
getimage 1,490,1,560,55

drawimage 1,x,y,0

sync



So could someone just tell me how to use sprites in PlayBasic the simple way?  ::)
Finished projects so far: Kumiankka, Meals of the Dragon, Fisut, Draw Old, Reikäkopio, Blindage, Escape from Millmier

Homepage: Not yet named project

kevin

PlayBASIC Code: [Select]
loadimage "sprites.png",1

rendertoimage 1

getimage 2,490,1,560,55

rendertoscreen

drawimage 2,x,y,0

sync



Laskiapina

Ah, I see. The first image is #1 so you have to start cutting the sprites from #2. And if I got it right, you have to tell the program what it must work on - on the picture data or on the screen. Thank you. Moving on. :)
I was making a platformer on DarkBASIC when I noticed that DB doesn't meet my requirements. So now I'm changing the code to work in PB.
Finished projects so far: Kumiankka, Meals of the Dragon, Fisut, Draw Old, Reikäkopio, Blindage, Escape from Millmier

Homepage: Not yet named project

Laskiapina

Are images slower than sprites? Is it wise to use DRAWIMAGE for drawing platforms and other stuff (a lot of them) or does the program get too slow?
Finished projects so far: Kumiankka, Meals of the Dragon, Fisut, Draw Old, Reikäkopio, Blindage, Escape from Millmier

Homepage: Not yet named project

Laskiapina

Apparently I can't use collision detection if I use only DRAWIMAGE. I read the image tutorial, but it didn't help me much. So how am I to change the images to sprites and how do I use them (for example in DB: sprite 1,x,y,1)?
Finished projects so far: Kumiankka, Meals of the Dragon, Fisut, Draw Old, Reikäkopio, Blindage, Escape from Millmier

Homepage: Not yet named project

kevin

  You can replicate the SPRITE function in DBclassic with the following.

PlayBASIC Code: [Select]
Function  Sprite(index,xpos,ypos,ImageIndex)
Createsprite Index
Positionsprite index,xpos,ypos
Spriteimage index,ImageIndex
EndFunction




However i wouldn't recommend that !


  This is more appropriate,

PlayBASIC Code: [Select]
Function  Sprite(index,xpos,ypos,ImageIndex)
if GetSpriteStatus(index)=false
Createsprite Index
endif
Positionsprite index,xpos,ypos
Spriteimage index,ImageIndex
EndFunction




Laskiapina

Finished projects so far: Kumiankka, Meals of the Dragon, Fisut, Draw Old, Reikäkopio, Blindage, Escape from Millmier

Homepage: Not yet named project