Computer Science Canada Jumping Ball |
Author: | Paul [ Fri Oct 29, 2004 3:14 pm ] |
Post subject: | Jumping Ball |
A person in my class was trying to get a ball to jump with gravity and shit, so I made this in 15-20 min. Not great coding, but yea... w/e. The gravity is set to -0.2 right now, you can change it for observation. But basically when u jump (ctrl) it gives the ball an initial velocity, and gravity is acting on the ball at all times anyhow. I've gotten a crude bottom side collision detection in. But I'm too lazy to expand on this. If anyone can improve/ exand on this code, I'd like to see the results or w/e. But this was basically a demonstration to my classmate. Just press control to jump |
Author: | Cervantes [ Fri Oct 29, 2004 6:03 pm ] | ||||||
Post subject: | |||||||
nice work paul. Pretty good, for such a short time. Here's a simple function I wrote for collision detection, again, using whatdotcolour.
check_under_obj is intended to be the y velocity of the object, which, since you're checking to see if it hit the ground, should be a negative value. also, since you're ball doesn't fall down when he moves off of the ground (he doesn't fall when he runs off a cliff), you could do something like the following: use the above function in an if statement such as:
this causes the jump sequence to be initiated, and causes gravity to come into play. The only thing is that you'd have to move ballv := 8 into the if chars (key_ctrl) statement:
Cheers! |