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 / keeping a key pressed down after release??????

Author
Message
Armeggadon
23
Years of Service
User Offline
Joined: 10th Apr 2003
Location: United States
Posted: 29th Apr 2003 03:58 Edited at: 29th Apr 2003 03:59
i have a problem. right now all i have is

if spacekey()=1 then paste image 200,512,0

i know theres a way to keep the image up after you release the spacbar but i dont know how. i need it so that the image appears when i press the spacebar and stayds when i release the spacebar. but then if the image is already up when you press the spacebar i want it to hide the image. how would i go about doing this(a code snippet may be appreciated) thx in adv for help

Current Status: learning MORE about dbpro
I consider myself: newb
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 29th Apr 2003 05:29 Edited at: 29th Apr 2003 23:54
You could do something like this:



You need the wait 100 because it will swich very rapidly every loop if you don't let go fast.

"All programmers are playwrites and all computers are lousy actors" -Anon
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Apr 2003 13:13
Here's an example of the standard push-on/push-off button code that I use. Just replace the 'text' command with your paste image command.

AsriCE
23
Years of Service
User Offline
Joined: 10th Jan 2003
Location: Brunei
Posted: 29th Apr 2003 14:01
Or you could try this..



Asri CE Crew

Anak Brunei!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Apr 2003 16:37
That doesn't do what he wants. Your code just does the 'switch-on', but not the 'switch-off'.
AtomR
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 29th Apr 2003 17:24 Edited at: 29th Apr 2003 17:32
I am assuming you are using 3d in your game in wich case it makes it a bit easier.


Hope this is what you wanted.

Take care
AtomR
Armeggadon
23
Years of Service
User Offline
Joined: 10th Apr 2003
Location: United States
Posted: 29th Apr 2003 23:39 Edited at: 30th Apr 2003 00:16
well kind of. when i put the code in by itself it works but when i try to incorporate it into the rest of my key commands it keeps messing up. the screen keeps flashing and you cant tell whats going on. im so confused. im not using 3d and i cant figure out what to do. im trying to work it but cant understand. i've come up with something but it still isn't working. here is what i have. i know why it isn't working but i dont know what to do.

this is my entire keypress command line.


i know that it isn't working becasue when i hold down the spacekey that is =1 so it pastes and deletes the image. how so i make it so that it doesn't do this.(you dont have to bother the other key commands as they are fine it was just to help you incorporate the spacekey command better) and i cant post the entire code because it is for a project i am helping a friend with and he wants to kepp the code as closed as possible until its release(and even then he's still not sure about making it open source)

Current Status: learning MORE about dbpro
I consider myself: newb
TheCyborg
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 30th Apr 2003 01:19 Edited at: 30th Apr 2003 01:20
This should do what you need. It's the while/endwhile lines you have to include:



OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 30th Apr 2003 01:49
What i do is set a counter to say 100 (or whatever) when the key in question is pressed as well as perfoming the task. If the counter is not equal to zero it doesn't meet the condition simple.
eg:

if counter>0 then dec counter,1
if counter=0 and spacekey()=1
counter=100
rem whatever u want 2 do can go here
endif
Armeggadon
23
Years of Service
User Offline
Joined: 10th Apr 2003
Location: United States
Posted: 30th Apr 2003 03:16
OH THANK YOU THANK YOU THANK YOU. it FINALLY works. thank you sooooooo much. i used theCyborg's code but ill keep yours in mind OzBot just in case i need it for something else

Current Status: learning MORE about dbpro
I consider myself: newb
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 30th Apr 2003 10:00
Glad to help.
TheCyborg
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 30th Apr 2003 14:22

Login to post a reply

Server time is: 2026-07-11 04:22:38
Your offset time is: 2026-07-11 04:22:38