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.

Newcomers DBPro Corner / Problem with For...Next...step loop

Author
Message
Bullet butter
18
Years of Service
User Offline
Joined: 5th Mar 2006
Location:
Posted: 13th Mar 2006 04:35
I am trying to make a sprite 'fall' down my screen at a reasonable speed. Here is the code I have so far.


This works but it happens way to fast. I tried using a step of .2 but it doesn't seem to work at all when I step with decimals. Putting a wait/sleep timer just screws everything up so that is not an option either.

DBPro
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 13th Mar 2006 05:17
Wait, that code doesnt look like it makes a sprite fall down, are you sure you put in the right code?

Pirates of Port Royale
Live the life of a pirate.
Bullet butter
18
Years of Service
User Offline
Joined: 5th Mar 2006
Location:
Posted: 13th Mar 2006 05:47
Well, this is the way I am moving all of my other sprites (aside from the for loop). So if this isn't the correct way help would be appreciated.
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 13th Mar 2006 17:13 Edited at: 14th Mar 2006 11:53
if you step in fractional amounts then you need to use floats, so add a # to your variable name...eg

FOR A# = 130 TO 450 step 0.1
SPRITE 17, 100, int(A#), 17
NEXT A#

although unless you want your game to stop at this point while the sprite falls then you need to forsake loops and use a logical compare to move your sprite so that it will keep moving the object a little each loop...eg

if A<450
inc A
SPRITE 17, 100, A, 17
endif

will move it once per loop until it reaches the bottom.



if you listen you can hear the inter-dimensional zombies calling.....branes, branes......
Bullet butter
18
Years of Service
User Offline
Joined: 5th Mar 2006
Location:
Posted: 13th Mar 2006 17:52
Yeah, thanks. I just took it out of the For loop and got it working the way I wanted it to. Thanks for the help.

Login to post a reply

Server time is: 2024-09-24 19:26:15
Your offset time is: 2024-09-24 19:26:15