Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 need help with a program
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
Goto page 1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Darkmantis




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Darkmantis




PostPosted: 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.
NikG




PostPosted: Sat Apr 22, 2006 11:31 pm   Post subject: (No subject)

What exactly do you mean? Why do you need to disable a key?
Darkmantis




PostPosted: 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
GlobeTrotter




PostPosted: 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
Darkmantis




PostPosted: Sun Apr 23, 2006 6:49 pm   Post subject: (No subject)

So u are saying I should use a code like this to use?

code:
if keycode = 38 then
If (Player.Top - Player.Height)= 0 then
timer1.enabled=true
end if
end if


thx this should really help with the development of my program Very Happy Very Happy Very Happy
Darkmantis




PostPosted: 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.
cool dude




PostPosted: 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

Sponsor
Sponsor
Sponsor
sponsor
Darkmantis




PostPosted: Mon Apr 24, 2006 6:16 am   Post subject: (No subject)

what the hell is pseudo code???
cool dude




PostPosted: 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? Shocked

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! Smile

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.
Darkmantis




PostPosted: 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.
cool dude




PostPosted: 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
cool dude




PostPosted: 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
Darkmantis




PostPosted: 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

Darkmantis




PostPosted: Mon Apr 24, 2006 5:27 pm   Post subject: (No subject)

LOL FORGOT TO POST THE ZIP FILE
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 3  [ 31 Posts ]
Goto page 1, 2, 3  Next
Jump to:   


Style:  
Search: