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 / Issue with input?

Author
Message
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 19th Sep 2011 23:19
Hello all!

I'm working on a 2D tiled RPG, and right now I'm working on an event handler, where in the main loop it checks if the space key is being pressed, and then if the space key is pressed it jumps to another portion in code that checks if there is a collision between the main character sprite and a NPC sprite (the event handler), and if there is one, then it jumps to the appropriate event (in this case, being I only have one NPC up now, I have it displaying a text saying "Hello!" in the center of the screen). Well, I hit the space key when my main character has collided with the NPC, and it doesn't pop up with "Hello!" right away. Instead, it stops the loop like a WAIT KEY command, and then it shows the text after I hit another key, and it then does another WAIT KEY (this wait key is correct though).

My event is laid out like this:




So the jist of this question is: Howcome it doesn't show the text right away when I hit the spacebar key the first time?

Any help would be appreciated... Thanks!
ZestyPro
14
Years of Service
User Offline
Joined: 27th Aug 2011
Location: The Grid
Posted: 20th Sep 2011 01:20
check if you have another wait key command somewhere

Haha!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Sep 2011 01:38
Try putting Sync after hello.

Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 20th Sep 2011 01:52
Thank you very much! That fixed it.

What I don't understand though is why I needed to do that? I already have my program set to SYNC at the end of my main loop.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Sep 2011 01:55
Yeah, but you have wait key there, so it waits.

Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 20th Sep 2011 02:04
Wow... Boy do I feel like a moron.

I should have realized that! Meh, so many small quirks in DarkBASIC I have yet to get used to. But what's an enjoyable activity without a bit of challenge to it?

Thanks again man! and for you good sir.

Login to post a reply

Server time is: 2026-07-10 17:19:28
Your offset time is: 2026-07-10 17:19:28