
-----------------------------------
Darkmantis
Sat Apr 22, 2006 1:25 pm

need help with a program
-----------------------------------
is there a way to disable a key on the key board while a program is running?

-----------------------------------
Darkmantis
Sat Apr 22, 2006 1:55 pm


-----------------------------------
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
Sat Apr 22, 2006 11:31 pm


-----------------------------------
What exactly do you mean? Why do you need to disable a key?

-----------------------------------
Darkmantis
Sun Apr 23, 2006 1:48 pm


-----------------------------------
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
Sun Apr 23, 2006 2:40 pm


-----------------------------------
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:

If UP_KEY_PRESSED then
   If (Player.Top - Player.Height)= 0 then
      Call Jump
   End if
end if


-----------------------------------
Darkmantis
Sun Apr 23, 2006 6:49 pm


-----------------------------------
So u are saying I should use a code like this to use?

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  :D  :D  :D

-----------------------------------
Darkmantis
Sun Apr 23, 2006 8:17 pm


-----------------------------------
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
Sun Apr 23, 2006 8:38 pm


-----------------------------------
try this pseudo code! similar to GlobeTrotter


If UP_KEY_PRESSED and jump = false then  
      Call Jump
      jump = true
End if 



-----------------------------------
Darkmantis
Mon Apr 24, 2006 6:16 am


-----------------------------------
what the hell is pseudo code???

-----------------------------------
cool dude
Mon Apr 24, 2006 10:09 am


-----------------------------------
what the hell is pseudo code???

u don't know wat pseudo code is?  :shock: 

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.

-----------------------------------
Darkmantis
Mon Apr 24, 2006 10:43 am


-----------------------------------
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
Mon Apr 24, 2006 4:55 pm


-----------------------------------
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
Mon Apr 24, 2006 5:01 pm


-----------------------------------
***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
Mon Apr 24, 2006 5:26 pm


-----------------------------------
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.
 

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
Mon Apr 24, 2006 5:27 pm


-----------------------------------
LOL FORGOT TO POST THE ZIP FILE

-----------------------------------
cool dude
Mon Apr 24, 2006 6:24 pm


-----------------------------------
here  :)

-----------------------------------
Darkmantis
Tue Apr 25, 2006 5:40 am


-----------------------------------
wow, thats awesome thanks a lot :)

-----------------------------------
Darkmantis
Tue Apr 25, 2006 6:37 am


-----------------------------------
Does anyone have any good code that I can use to get my guy to jump and land on a platform?

-----------------------------------
cool dude
Tue Apr 25, 2006 1:10 pm


-----------------------------------
Does anyone have any good code that I can use to get my guy to jump and land on a platform?

u don't ask for code because thats not wat we r here for. we are here to help u and not give u free code which i kinda already did. why don't u rephrase your question and ask how do i do collision detection

-----------------------------------
Darkmantis
Tue Apr 25, 2006 2:41 pm


-----------------------------------
well I already have code but Im not sure how to use it or reliable it is. This code is from a game I did at school almost like pong but the player paddles were on the top and bottem instead of the left and right. 
Here it is:

hfx = shape1.Top + shape1.Height
hfy = shape1.Left + (shape1.Width / 2)
py = Shape2.Left + (Shape2.Width / 2)

If hfx >= Shape2.Top Then
If Abs(hfy - py) < (Shape2.Width / 2) Then
direction1 = -30
shape1.Top = shape1.Top + direction1
End If
End If


-----------------------------------
cool dude
Tue Apr 25, 2006 3:33 pm


-----------------------------------
k your code is kinda pointless. collision detection is really simple. i'll help u get started by helping u with the left side of the box collision detection and then u could implement that to get right side and top of the box collision detection. 

Left Side

u want your person to stop moving if it hits the left side so first we need to determine that.


if front.left + front.width > shape2.left then


this basically states that if the right side of the persion is greater than the left side of the box.

now we determined if it collides with the box so what do we want to do? we want to make the person stop so no matter if the user presses "D" to go left it will not move. to do so we need to say


front.left = front.left


***Important*** this code u want to put in your form_keypress procedure inside the if statement that is going to the left.

so that if statement will look like so...



    ElseIf KeyAscii = 100 Then
        If front.Left + front.Width > Shape2.Left Then
            front.Left = front.Left
        Else
            front.Left = front.Left + 100
        End If

-----------------------------------
Darkmantis
Tue Apr 25, 2006 6:22 pm


-----------------------------------
awesome thx I try to build this into my game  :D  :D  :D

-----------------------------------
Darkmantis
Tue Apr 25, 2006 6:27 pm


-----------------------------------
Oh umm.. first I need to be able to jump onto the platform so how can I make it jump diagonal? I tried but I can't get it to work by pressing left and up key :(

-----------------------------------
cool dude
Tue Apr 25, 2006 7:23 pm


-----------------------------------
my code was just showing u collision detection so if the person touches the box it won't go through the box. that has nothing to do with jumping diagonally. to jump diagonally u might want to look up something with trig.

-----------------------------------
Darkmantis
Wed Apr 26, 2006 10:49 am


-----------------------------------
fine be that way  :(  I guess Ill look else where for help

-----------------------------------
cool dude
Wed Apr 26, 2006 1:12 pm


-----------------------------------
fine be that way  :(  I guess Ill look else where for help

i helped u more than enough and i'm not giving u more code! u have to try figuring some stuff on your own because that way u will learn something. i even gave u a quick tutorial on collision detection so u should be thankful. when u try doing it yourself and post the code that u did (not random code put together) and ask a specific question!!! than we might help u more.

-----------------------------------
Darkmantis
Wed Apr 26, 2006 4:53 pm


-----------------------------------
I already knew the crap U showed me first of all I just wanted to know where to apply it. And second I have a really bad memory!

-----------------------------------
cool dude
Wed Apr 26, 2006 5:22 pm


-----------------------------------
hahaha u knew that crap! it really doesn't look like u knew it because looking at your first code with your 5 timers it seems u have no idea wat a timer is for and u put a bunch of code together to say its code. as well if u knew it u wouldn't ask for help! u really shouldn't try to piss of a person that helps u because who's goin to help u now eh?

-----------------------------------
GlobeTrotter
Wed Apr 26, 2006 6:25 pm


-----------------------------------
Trig should not be used to jump diagonally.  If you've taken physics 12 (maybe 11) you'll know that horizontal motion of a projectile is independant of the vertical.  Thus, simulating gravity in the vy whilst simulating constand horizontal motion in the vx direction is sufficient.

The problem with moving diagonally is: you have to recognize two keys being pressed at once.  Under your current implementation, this is not possible.  You're going to have to completely redesign your keyboard input to use an array(255) of boolean if you wish to allow for simultaneious imput.

-----------------------------------
Darkmantis
Wed Apr 26, 2006 7:27 pm


-----------------------------------
english plz

-----------------------------------
Darkmantis
Wed Apr 26, 2006 7:30 pm


-----------------------------------
hahaha u knew that crap! it really doesn't look like u knew it because looking at your first code with your 5 timers it seems u have no idea wat a timer is for and u put a bunch of code together to say its code. as well if u knew it u wouldn't ask for help! u really shouldn't try to piss of a person that helps u because who's goin to help u now eh?
obviously not u! that timer thing that ur making fun of is wat I was taught in school first off all.And second of all IM NOT TRYING TO PISS ANYONE OFF IM JUST STARTING THE FUCKING OBVIOUS!!
