How do I cancel a key?
Blitz3D Forums/Blitz3D Beginners Area/How do I cancel a key?
| ||
I actually need help with 2D BlitzBasic. I'm trying to find out how do I cancel a key? The link to the thread is below: http://www.blitzbasic.com/Community/posts.php?topic=95362#1097810 Thanks |
| ||
You should be able to do this by adding in a global variable that can record whenever the Jump key is enabled or not. Set this to True at the start of your program, and False when the collision occurs. Don't forget to "re-enable" it, by setting it back to True once the player is free of the door again! Global JumpEnabled=True ;------------------------- blahblahblah ;------------------------- If (KeyHit (57) And (JumpEnabled))Then h\y = h\y - 600 EndIf If ImagesCollide (HENRY,h\x,h\y,0,DOOR,d\x,d\y,0) Then JumpEnabled=False b\image = BACKGROUND2 Else JumpEnabled=True EndIf |
| ||
It's not really cancelling a key as much as establishing a condition for its state to mean something: "IF the key is being pressed AND the character isn't colliding with the wall, THEN do something", like Malice exemplified. So far you had the "key being pressed" condition; you needed to add the "colliding with the wall" one. You can establish as much of these conditions as you want by relating them with the And, Not and Or operatives. Make sure to catch up on the documentation to these. |
| ||
Thanks Malice. It worked. And Kryzon, thanks for the link and the explanation. |