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 / Space bar pressed

Author
Message
xiva
15
Years of Service
User Offline
Joined: 16th Apr 2009
Location:
Posted: 17th May 2009 17:42
How can i do it so that the ball move if i press space bar not if im holding it so i press space and it moves the ball, rather than having to hold the key to move the ball the full distance.

Thanks

"Lifes like a box of chocolates, you never know which one you get" Forest Gump
Unless you read the leaflet, thats why hes so "different"
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 17th May 2009 18:20 Edited at: 17th May 2009 18:20
Set a flag that indicates that the space bar has been pressed and base your actions on the flag rather than the state of the spacebar.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
ketchup mustard
16
Years of Service
User Offline
Joined: 31st Jan 2008
Location:
Posted: 19th May 2009 02:54
cool ^^ wats a flag? and how do i implement it?

Don't Clap, Just Throw Money!
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 19th May 2009 17:56 Edited at: 19th May 2009 18:05
A flag is basically some variable, usually an integer or a boolean. that's used to keep track of the status of something you're trying to.... well, keep track of. Let's say you want to use the space bar to toggle when something moves. The object is at rest. You hit the space bar and it begins to move. You hit the space bar again and it stops. I'm going to use pseudo code here since I don't have time to construct a full example.



elswhere in your main loop you should have something like



Integers can be used to track items that have multiple states, such as a stopped ball, slow ball, fast ball, no ball...., etc.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
ketchup mustard
16
Years of Service
User Offline
Joined: 31st Jan 2008
Location:
Posted: 19th May 2009 18:32
omg Lilith you are so helpful ^^ y aren't you a mod?

Don't Clap, Just Throw Money!
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 19th May 2009 21:29
While I've had a long history of programming on and off (mostly c/c++) I really don't have the in depth understanding of Dark GDK nor do I have the time to devote to the pursuit. I'd love to be able to dedicate my efforts to game writing but I just have too many demands on my time.

The main thing you should realize is that the type of question you asked relates to a fairly general programming technique, just applied to something in a game program. Study not only the language you plan to use but also programming techniques in general. You'll need some of them as you get into more complex game requirements.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-11-05 18:44:19
Your offset time is: 2024-11-05 18:44:19