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 Discussion / 2D game sprite speed

Author
Message
robertpas
12
Years of Service
User Offline
Joined: 31st May 2011
Location:
Posted: 31st May 2011 13:49
Hello everyone!

I'm new to dark basic and I have been working on a 2D game as a project for college. Mainly it's a platformer game where you have to avoid some projectiles.
The problem is that they are just too fast



That would be the code for a lock-on "missile" ball. The problem is that +1 and -1 are just too fast. And using 0.01 doesn't work. Is there a way to make it slower? I really don't want to come up with a game that requires skill equal to dodging a bullet in real life.
Please help me if you can.
Thanks in anticipation!
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 31st May 2011 17:40
Hello robertpas! Welcome to the forums!

You had the solution right to use numbers that are less than 1. Here is how to make them work:



The trick is positioning the sprite using float variables, rather than integer values. The sprite will still be positioned at the same place, but after several loops through, it will increase by 1. When positioned, the command will drop the fraction.

Hope this helps!

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 3rd Jun 2011 04:40 Edited at: 3rd Jun 2011 04:42
BN2 is quite correct. Also note he is using sync to update the screen. You can declare a float using # on the end of the variable name, or defining it at the start of the program as a float. Also note that sync rate 0 will run at the fastest speed possible, rather than a steady 60 fps for instance. You may want to use the timer() command to get it running at the desired frame rate, which affects your game speed also. You could of course set it to 60 instead of 0, but that will actually introduce pauses in your game and is best avoided.

http://s6.bitefight.org/c.php?uid=103081

Login to post a reply

Server time is: 2024-03-28 15:34:49
Your offset time is: 2024-03-28 15:34:49