Author |
Message |
cool dude
|
Posted: Mon Apr 24, 2006 6:24 pm Post subject: (No subject) |
|
|
here
Description: |
|
Download |
Filename: |
jump.vbp |
Filesize: |
683 Bytes |
Downloaded: |
100 Time(s) |
Description: |
|
Download |
Filename: |
jump.frm |
Filesize: |
2.36 KB |
Downloaded: |
106 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Darkmantis
|
Posted: Tue Apr 25, 2006 5:40 am Post subject: (No subject) |
|
|
wow, thats awesome thanks a lot
|
|
|
|
|
|
Darkmantis
|
Posted: Tue Apr 25, 2006 6:37 am Post subject: (No subject) |
|
|
Does anyone have any good code that I can use to get my guy to jump and land on a platform?
|
|
|
|
|
|
cool dude
|
Posted: Tue Apr 25, 2006 1:10 pm Post subject: (No subject) |
|
|
Darkmantis wrote: 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
|
Posted: Tue Apr 25, 2006 2:41 pm Post subject: (No subject) |
|
|
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:
code: |
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
|
Posted: Tue Apr 25, 2006 3:33 pm Post subject: (No subject) |
|
|
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.
code: |
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
code: |
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...
code: |
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
|
Posted: Tue Apr 25, 2006 6:22 pm Post subject: (No subject) |
|
|
awesome thx I try to build this into my game
|
|
|
|
|
|
Darkmantis
|
Posted: Tue Apr 25, 2006 6:27 pm Post subject: (No subject) |
|
|
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
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
cool dude
|
Posted: Tue Apr 25, 2006 7:23 pm Post subject: (No subject) |
|
|
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
|
Posted: Wed Apr 26, 2006 10:49 am Post subject: (No subject) |
|
|
fine be that way I guess Ill look else where for help
|
|
|
|
|
|
cool dude
|
Posted: Wed Apr 26, 2006 1:12 pm Post subject: (No subject) |
|
|
Darkmantis wrote: 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
|
Posted: Wed Apr 26, 2006 4:53 pm Post subject: (No subject) |
|
|
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
|
Posted: Wed Apr 26, 2006 5:22 pm Post subject: (No subject) |
|
|
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
|
Posted: Wed Apr 26, 2006 6:25 pm Post subject: (No subject) |
|
|
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
|
Posted: Wed Apr 26, 2006 7:27 pm Post subject: (No subject) |
|
|
english plz
|
|
|
|
|
|
|