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 / how to make player move slower?

Author
Message
ZapMan
13
Years of Service
User Offline
Joined: 1st Feb 2013
Location:
Posted: 16th Jul 2014 22:50
Hello! So I am making a simple program with a sphere that is controlled with arrow keys. It all works but the minimum speed is simply faster than what I was intending. I tried putting a delay on the keys so that it would only move the character every couple milliseconds with the WAIT command, but then it looks too choppy. My dad suggested lowering the sync rate, and although i am aware this would slow down my character, it makes it slow, and really choppy. I don't know how to use FLOAT commands, but i do know they allow for decimals. Is it possible to use a float for the speed?

Heres my code:
[ Rem Project: 3D Spheres and boxes
Rem Created: Monday, July 07, 2014

Rem ***** Main Source File *****
cls
Sync rate 60
MAKE OBJECT SPHERE 1, 2
Make object cube 2, 2

`Speeds for characters
Pspeed = 1
ESpeed = 1


`Object positions
Position object 1, 0, 0, 50
Position object 2, 20, 0, 50

Do

if upkey()
move object up 1, Pspeed
endif

if downkey()
move object down 1, Pspeed
endif

If leftkey()
move object left 1, Pspeed
endif

if rightkey()
move object right 1, Pspeed
endif

sync
Loop ]

Metric City Police Department
VisualProg
17
Years of Service
User Offline
Joined: 31st Mar 2009
Location: RussianFederation, Smolensk
Posted: 17th Jul 2014 15:35 Edited at: 17th Jul 2014 15:41
changed 2 strings (and add 2):


or this, more math:


MZh[NUL] <---

My musics
ZapMan
13
Years of Service
User Offline
Joined: 1st Feb 2013
Location:
Posted: 17th Jul 2014 20:12
Thank you! shortly after i posted this i realized the Speed on the command Move Object could be a float, but i didnt know i could set a variable as a float with the global command! Again, thank you alot

Metric City Police Department

Login to post a reply

Server time is: 2026-07-06 04:29:03
Your offset time is: 2026-07-06 04:29:03