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 Professional Discussion / KeyUp and KeyDown events?

Author
Message
3ddd
20
Years of Service
User Offline
Joined: 14th Apr 2004
Location: Orlando, FL
Posted: 20th Apr 2004 20:16
Is there anyway (in code or via plug-in) to detect KeyUp and KeyDown events? I did not see any event-based functions in the manual.

I'm working on a Super Mario clone to learn DBP and to try to build a general tile-based game engine. It's coming along nicely, but I am having a problem that has to do detecting keyboard events. I am trying to create this effect:

The height of Mario's jump increases if you hold down the jump key (while on the ground). This must not happen once the jump key has been released while in the middle of a jump.
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 20th Apr 2004 20:22
KeyState() is your answer - has 0 or 1 depending on whether it is up or down.

This code from my Bruce Lee game is checking for W, A, S and D being down :-



3ddd
20
Years of Service
User Offline
Joined: 14th Apr 2004
Location: Orlando, FL
Posted: 20th Apr 2004 20:44
I suppose I can detect a "KeyUp event" by checking to see if a keystate turned from 1 to 0. I was just hopiing there was a more direct way.
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 20th Apr 2004 21:18
dbp is not event driven. you should make a main loop and test conditions within it, branching to subs or functions as handlers.


Home of the VB.NET Class Builder Utility - Demo and FULL versions now available!!
walaber
20
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 21st Apr 2004 07:57
yup, just use a boolean variable to keep track for yourself.



Go Go Gadget DBPRO!

Athlon XP 2400+ || DDR-SDRAM 1GB || Nvidia GeForce 4 Ti4200 AGP 8x 128MB

Login to post a reply

Server time is: 2024-04-27 05:11:40
Your offset time is: 2024-04-27 05:11:40