Author |
Message |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
Posted: Sat Apr 22, 2006 1:25 pm Post subject: need help with a program |
|
|
is there a way to disable a key on the key board while a program is running? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
Posted: Sat Apr 22, 2006 1:55 pm Post subject: (No subject) |
|
|
the program I need help with is a side scroller im working on here it is it may be crap right now but im just trying to get a jumping system to work but im having a hard time with it. |
|
|
|
|
![](images/spacer.gif) |
NikG
|
Posted: Sat Apr 22, 2006 11:31 pm Post subject: (No subject) |
|
|
What exactly do you mean? Why do you need to disable a key? |
|
|
|
|
![](images/spacer.gif) |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
Posted: Sun Apr 23, 2006 1:48 pm Post subject: (No subject) |
|
|
well im thinking of disabling the up key so u cant press it while the character is in the air and then enable it again afterward |
|
|
|
|
![](images/spacer.gif) |
GlobeTrotter
|
Posted: Sun Apr 23, 2006 2:40 pm Post subject: (No subject) |
|
|
Then you don't need to disable the key. You just need to put an if statement where the up key performs an action. Just make sure the person is on the ground before performing the jump action.
eg:
pseudocode:
code: |
If UP_KEY_PRESSED then
If (Player.Top - Player.Height)= 0 then
Call Jump
End if
end if
|
|
|
|
|
|
![](images/spacer.gif) |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
|
|
|
![](images/spacer.gif) |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
Posted: Sun Apr 23, 2006 8:17 pm Post subject: (No subject) |
|
|
I tryed out the code and my program still glitches up when I click the jump butten while a jump is in progress. |
|
|
|
|
![](images/spacer.gif) |
cool dude
![](http://www.taylorstrategicmarketing.com/images/king.jpg)
|
Posted: Sun Apr 23, 2006 8:38 pm Post subject: (No subject) |
|
|
try this pseudo code! similar to GlobeTrotter
code: |
If UP_KEY_PRESSED and jump = false then
Call Jump
jump = true
End if
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
Posted: Mon Apr 24, 2006 6:16 am Post subject: (No subject) |
|
|
what the hell is pseudo code??? |
|
|
|
|
![](images/spacer.gif) |
cool dude
![](http://www.taylorstrategicmarketing.com/images/king.jpg)
|
Posted: Mon Apr 24, 2006 10:09 am Post subject: (No subject) |
|
|
Darkmantis wrote: what the hell is pseudo code???
u don't know wat pseudo code is?
its like code made in comments. the reason i gave u pseudo code is because thats how u do it, but u can't copy and paste the code because u didn't use the same variable names! basically take my code and stick in the variable names u used and i think it should work!
oh and i forgot to mention after my code when the jump was finished just set the variable jump back to false so u can jump again. |
|
|
|
|
![](images/spacer.gif) |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
Posted: Mon Apr 24, 2006 10:43 am Post subject: (No subject) |
|
|
Lol ok awesome thats wat I did. But now I can jump without it glitching except I can jump in midair over and over for some reason but it shouldn't let me. |
|
|
|
|
![](images/spacer.gif) |
cool dude
![](http://www.taylorstrategicmarketing.com/images/king.jpg)
|
Posted: Mon Apr 24, 2006 4:55 pm Post subject: (No subject) |
|
|
if u used my code correctly than that wouldn't happen because it would never call the jump procedure since the boolean is set to true which means your in the air already.
post your new code and i'll take a look at it |
|
|
|
|
![](images/spacer.gif) |
cool dude
![](http://www.taylorstrategicmarketing.com/images/king.jpg)
|
Posted: Mon Apr 24, 2006 5:01 pm Post subject: (No subject) |
|
|
***Edit*** the code that u already posted is terrible!!! why do u have 4 timers??? and it completely doesn't work! tell me what you are trying to do and post the updated code |
|
|
|
|
![](images/spacer.gif) |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
Posted: Mon Apr 24, 2006 5:26 pm Post subject: (No subject) |
|
|
Here is my updated version with the new code, but as u said the timer thing is kinda hard to get to work if u can help me out with this it would be awesome, and ill post the code to for people who are too lazy to download the program.
code: |
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Then
Timer4.Enabled = False
front.Left = front.Left + 100
End If
If KeyCode = 37 Then
Timer4.Enabled = False
front.Left = front.Left - 100
End If
If KeyCode = 38 And Timer3.Enabled = False Then
If front.Top = 2760 Then
front.Visible = False
jump.Top = front.Top
jump.Left = front.Left
jump.Visible = True
Timer1.Enabled = True
Timer2.Enabled = True
Timer4.Enabled = False
End If
End If
End Sub
Private Sub Form_Load()
jumpend = 2760
End Sub
Private Sub Timer1_Timer()
jump.Top = jump.Top - 100
End Sub
Private Sub Timer2_Timer()
If jump.Top = 760 Then
Timer1.Enabled = False
Timer3.Enabled = True
Timer4.Enabled = True
End If
End Sub
Private Sub Timer3_Timer()
jump.Top = jump.Top + 100
End Sub
Private Sub Timer4_Timer()
If jump.Top = jumpend Then
Timer2.Enabled = False
Timer3.Enabled = False
jump.Top = jumpend
jump.Visible = False
front.Top = jump.Top
front.Left = jump.Left
front.Visible = True
End If
End Sub
|
|
|
|
|
|
![](images/spacer.gif) |
Darkmantis
![](http://compsci.ca/v3/uploads/user_avatars/26883420945d0bc0dc57ea.jpg)
|
Posted: Mon Apr 24, 2006 5:27 pm Post subject: (No subject) |
|
|
LOL FORGOT TO POST THE ZIP FILE |
|
|
|
|
![](images/spacer.gif) |
|