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 / Rolling Movement

Author
Message
Black Cat XIII
19
Years of Service
User Offline
Joined: 23rd Jan 2006
Location:
Posted: 14th Feb 2006 04:23
How can I control a spherical object to where when I use the up arrow it moves forward and rotates on its X-axis as if its rolling?

Could you possibly provide code for me?

Enemy Lasagna
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 14th Feb 2006 23:32 Edited at: 14th Feb 2006 23:35
if upkey() = 1
move object [ball],0.5
xrotate object [ball],wrapvalue(object angle x([ball])+0.5)
endif

make sure before you reach this loop (assuming it's in a loop) make sure you:
set object rotation zyx [ball]
otherwise it may not rotate as you want it to...
Black Cat XIII
19
Years of Service
User Offline
Joined: 23rd Jan 2006
Location:
Posted: 15th Feb 2006 18:00
Um, what exactly do I do for the set object rotation? What do I set it to?

ALso, I did that without the Set Object Rotation, and all it does is a rolling frontflip over and over again.

Help?

Enemy Lasagna
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 15th Feb 2006 18:09
Sounds like your pivot point might be at the bottom of your rotating object, instead of the centre.

Did you make the object in a modelling package, and if so - when you exported/saved it - where was 0,0,0?

Was it at the bottom of the object, or in the very middle?

(It needs to be in the very middle).
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 15th Feb 2006 21:32
true about the modelling package bit...

but for the command I think you're a little unsure of:
set object rotation zyx 1

if your ball object is object 1, if it's not 1, then replace the 1 with the actual number of your ball object. Doing object rotation zyx, won't stop it front-flipping, but trust me, it will be handy a little later on...
Black Cat XIII
19
Years of Service
User Offline
Joined: 23rd Jan 2006
Location:
Posted: 15th Feb 2006 23:52
I found a good rolling code, so I'm ok now.

I'm trying to figure out how to use 2 keys at once. I know its simple, I'm just oblivious right now.

Enemy Lasagna
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 16th Feb 2006 13:42
instead of upkey()=1 you'll need is keystate()=1 (with the key number in the brackets)

Login to post a reply

Server time is: 2025-05-23 14:58:09
Your offset time is: 2025-05-23 14:58:09