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.

2D All the way! / Sprite sheet Problems Again

Author
Message
old rinkly
22
Years of Service
User Offline
Joined: 11th Mar 2004
Location: Devon UK
Posted: 28th Jan 2007 23:36
Why when I use a full 8X8 sprite sheet,each line of 8 in a different direction of the compass and I want to use say top and bottom line,( East and West), The animation runs through the whole sheet when gong back from the last line, to the first (West back to East
Created: 28/01/2007 21:53:18
Rem Project: SpriteTesting
Rem ***** Main Source File *****
set display mode 640,480,32
create animated sprite 1,"Girlwalking2.png",8,8,1
GL#=10:girl#=0.25:L1=1:L2=8
do
sprite 1,GL#,240,1
if GL#<501:play sprite 1,L1,L2,150:Gl#=GL#+girl#:endif
if gl#>500:girl#=-0.25:L1=57:L2=64:play sprite 1,L1,L2,150:endif
if gl#<11:girl#=0.25:L1=1:L2=8:play sprite 1,L1,L2,150:endif
loop]

old rinkly
Suicidal Sledder
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 29th Jan 2007 07:19
use the SET SPRITE FRAME command maybe?

"See?!?! Port IS left and starboard is RIGHT!!" - Hobbes
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 29th Jan 2007 07:55 Edited at: 29th Jan 2007 07:56
It's because when you use "play sprite" the next time it sees "play sprite" it tries to do the same frames as the last "play sprite" regardless of the fact they are now different frame numbers. You need to add "set sprite frame" before you use the "play sprite" command to make sure it doesn't continue to use the old values.

Also at certain points all three if/thens change the sprite frames and replays the sprite per loop. You need to change your code so that only one if/then runs at a time when it's needed... not constantly. You need only one "play sprite" command too (right under the sprite command would work).

Normally I would advise against using floats for screen coordinates but I realize you did that on purpose to slow down the movement on screen.

Because the if/thens are only run when the character goes to the limits the actual movement is in a different if/then checking for a new variable which determines what direction the character is moving.



Edit: Ack beat me to it.

old rinkly
22
Years of Service
User Offline
Joined: 11th Mar 2004
Location: Devon UK
Posted: 29th Jan 2007 10:17
Thanks Grog Grueslayer, I had an idea I was using too much code, like using a sledghammer to crack a wallnut.
Thanks for the code.
My computer should stop smoking now. Old Wrinkly.

old rinkly
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 29th Jan 2007 19:18
Np.

Login to post a reply

Server time is: 2026-07-05 22:56:06
Your offset time is: 2026-07-05 22:56:06