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.

Dark GDK / Ship rotating by itself...

Author
Message
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 17th Jun 2008 04:20
im using a wsad/arrow keys control scheme. teh arrow keys work fine. but my wsad is aperation even if i dont hold down the keys.



thats my code...what am I missing?

Your signature has been erased by a mod - please reduce it to 600x120
programing maniac
16
Years of Service
User Offline
Joined: 19th Apr 2008
Location: Bawk, Bawkity
Posted: 17th Jun 2008 04:26
Quote: "if(dbLeftKey())
"


This is saying if ( dbLeftKey is there, do this.);

I think your problem is that you have to say

if (dbLeftKey() == 1);

To make sure that it is when it is PRESSED down, not just there.

Your signature has been erased by a mod - 120 high maximum please
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 17th Jun 2008 04:28
no, if leftkey is being pressed down then dbLeftKey() returns true(1). So if the left key is down it resolves to if(1){} if not then its if(0). therefor it does ask if the key is pressed. it problem is somewhere with the keystates.

Your signature has been erased by a mod - please reduce it to 600x120
programing maniac
16
Years of Service
User Offline
Joined: 19th Apr 2008
Location: Bawk, Bawkity
Posted: 17th Jun 2008 04:31
Oh, well that is the way I do it....

Quote: "it problem is somewhere with the keystates."


It isn't, the keystates are right.

Sorry I couldn't be of much help


Your signature has been erased by a mod - 120 high maximum please
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 17th Jun 2008 04:38
its okay. when i put a "!" before the dbkeystate it works all except for keystate 30. it does nothing. im so confused right now.

Your signature has been erased by a mod - please reduce it to 600x120
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 17th Jun 2008 05:07
I'm not a 3D type but let me ask this.

Does dbRotateObject(1,pitch,angle,roll) tell it to pitch, angle and roll to whatever the set values are or does it tell the object to rotate by those values from their previous angle?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Vesper103
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location: Beloit WI
Posted: 17th Jun 2008 05:25
it tells it to rotate to that angle. to rotate from you would have to do a dbObjectAngleX(object id)+anglex, ect...

Your signature has been erased by a mod - please reduce it to 600x120
Dabbler
17
Years of Service
User Offline
Joined: 3rd Mar 2007
Location: Minnesota
Posted: 17th Jun 2008 05:29
Just a thought:

Try removing the ==1 from the keystate tests(if it works for the left & right tests, it might work for the others.)


Whatever...
ionstream
20
Years of Service
User Offline
Joined: 4th Jul 2004
Location: Overweb
Posted: 17th Jun 2008 06:37
You are calling dbRotateObject each time, regardless of whether or not a key is down, which causes the objects orientation to be added by the values you give. As long as pitch, angle, or roll is not zero, the object will rotate because they are never set back to zero. You could use dbSetObjectRotation if you want to use absolute degrees, or just set pitch angle and roll back to zero if their keys aren't being pressed.

haYnguy
16
Years of Service
User Offline
Joined: 5th Jun 2008
Location: on my island
Posted: 20th Jun 2008 06:51
ironstream: lol you caught it and mentioned it before I did.

yeah, setting the pitch, angle, and roll back to zero after the rotation is called would be best. I don't think there is anything else to remedy the problem while keeping the code you have there.

even if you check for a pressed key before checking which key is pressed wouldn't remove the rotation problem. It would mean, if any key is pressed, regardless if it is the one's you've chosen, the ship would rotate since the values aren't returned to zero.

-- from my island, aloha wau 'ia 'oe --

Login to post a reply

Server time is: 2024-11-20 13:31:08
Your offset time is: 2024-11-20 13:31:08