Sign in to follow this  
Meshboy

KeyPress, make sure function only runs once.

Recommended Posts

Basic, i have made my FPS Engine that is taking lines as walls with a height. instead of in the game place my player within a loaded level at a corner and then write down the position for the beginning of that wall and move to the position where i want the end of the line and write that position down i want a procedure like this: move to a position and then press 'A', then within a textfile this text will be generated: planes.add(new types.cplane(new vector3(x,y,z), and then move the player to the end of the line and press 'B' then this text will be generated and then create new linespace. new vector3(x,y,z),height); so in my textfile then i have planes.add(new types.cplane(new vector3(x,y,z),new vector3(x,y,z),height)); then i can just copy that code into my app and run it, this will save me lots and lots of time. But when i just slightly press 'A' this will generate lost of lines: planes.add(new types.cplane(new vector3(x,y,z),planes.add(new types.cplane(new vector3(x,y,z),planes.add(new types.cplane(new vector3(x,y,z),planes.add(new types.cplane(new vector3(x,y,z),planes.add(new types.cplane(new vector3(x,y,z), how can i make sure that only ONE line is created when pressing A. The same problem with open door in game. Press space and if closed then open and if open the close. but when pressing space it will open and close so fast i have no control. i need some sort of delay? plz help, my game is starting to look pretty good, soon i will cope with lights and shaders etc... =)

Share this post


Link to post
Share on other sites
You need to record the state of the button on the last frame. Then it's just a case of:
if(!buttonWasDown && buttonIsDown) // Button has become pressed

Share this post


Link to post
Share on other sites
How do you handle the frames?

when moving in my scenes i don´t use frame, i only have a direction vector with a certain speed that is corrected by the collidion detection.

Share this post


Link to post
Share on other sites
Quote:
Original post by Meshboy
How do you handle the frames?

when moving in my scenes i don´t use frame, i only have a direction vector with a certain speed that is corrected by the collidion detection.
Well, you know the last time you checked a keypress, so just use that as the last status for the key.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this