Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / A N00B Learnng Sprite

Author
Message
StudentFrankii
15
Years of Service
User Offline
Joined: 10th Mar 2011
Location:
Posted: 10th Mar 2011 11:20
Hiya so im doing games design at college and atm we are learning about sprites. But my teacher isnt here today so im seeking help on the net

I have several kirby images that allow him walk, they all have a black backgrounds and all are seperet which i think is how it must be. But i now have no idea how to achily get him to walk in a game?? A kind of no a little about sprites but if i dont learn more il fail this subject...

Help

Thanks Allot

StudentFrankii xoxox
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Mar 2011 11:52
Some sprites use individual images, maybe numbered files, then each image is shown in turn to form the animation.

Some sprites use a single image though, with several sprite frames. In DBPro you could grab these images (with a for...next loop, x and y) then do the same as if they were individual files. What I prefer to do, and a lot of other developers, is to use UV coordinates instead, so I'd make the sprite from the tile sheet image, then set the UV coordinate of the sprite to show just the animation frame that I want. This is a little more complex, but saves a lot of time as well - once it's been coded it would cut down on media handling no end.

Anyway, lets pretend you have a sprite sheet with 16x16 sprites on there, in a 8x8 grid...

Load bitmap "mysprites.png",0
img=100
For y=0 to 7
For x=0 to 7
get image img,x*16,y*16,(x+1)*16,(y+1)*16,1
inc img,1
next x
next y

Then you would have all those sprites as images, and just pasting image 100 will show the top left frame from your sprite sheet. Say frames 100 to 107 are an idle loop...

fr#=0.0
Do

inc fr#,0.03
if fr#>7 then fr#=0.0

sprite 1,mousex(),mousey(),100+fr#

sync
Loop

The sprite UV coordinates can be set, meaning a sprite sheet would be just 1 single image, but this can be fiddly, I already have a function that does this easily so I'll just post that up later.

Health, Ammo, and bacon and eggs!
StudentFrankii
15
Years of Service
User Offline
Joined: 10th Mar 2011
Location:
Posted: 16th Jun 2011 11:39
Okayy i kind of get it, im pretty much failing games design at college either way but thank you anyway

Thanks Allot

StudentFrankii xoxox

Login to post a reply

Server time is: 2026-07-10 22:54:38
Your offset time is: 2026-07-10 22:54:38