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 / How does dbShiftKey() work?

Author
Message
Mew151
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location: Glitch city
Posted: 7th Nov 2008 03:18
Whenever I try this:


Whenever I have tried pressing shift key, the particles don't disappear.

(By the way, the .x file I loaded is just a red cube.)

ow! that hurt!
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 7th Nov 2008 05:00 Edited at: 7th Nov 2008 05:07
The following code needs to be altered and placed inside your main game loop:




It doesn't work because when the program executes the code it hits the while loop and checks to see if dbShiftKey() == 1. If this is currently true (which its most likely not unless your holding the shift key right as the program starts) it will hide the particles. Most likely the shift key isn't being held yet so realistically dbShiftKey() == 0 not 1.

The program then passes the while loop without executing the dbHideParticles() command. Then it continues onto the next loop until you exit.

In order to fix it, just replace the while( dbShiftKey() == 1 ) statement with the an if statement and make sure you move it into the main program loop.



Also, I would suggest removing the while (!dbEscapeKey( )) because the code isn't needed. while( LoopGDK()) takes care of the escape key and window escapekey itself.

Lastly I'm guessing once you let go of the space key you would like to have the particles visible again. I added an else block to the if statement so once you let go the particles are visible again. There might be a more practicle way to do this, but it works just fine. Let me know if that helps


Mew151
16
Years of Service
User Offline
Joined: 1st Jun 2008
Location: Glitch city
Posted: 8th Nov 2008 00:54
Thanks! That really helped! I also solved another problem, rotating the cube while pressing shift. Thanks again!

ow! that hurt!

Login to post a reply

Server time is: 2024-11-25 05:14:16
Your offset time is: 2024-11-25 05:14:16