Posted By: Denn15
random jump strength - 12/03/12 20:31
ive started working on a marble madness type game and i would like the ball that you are controlling to jump and ive managed to make it jump when you press space but sometimes the ball jumps a sky high and other times the ball almost doesnt jump at all. there is probably a better way tro script a jump the way i did, since im completely new to lite-c but anyways these are the lines of code concerning the jumping:
Code:
function jump() { if (event_type == EVENT_FRICTION) { if (key_space) { if (!snd_playing(sound)) { ball_jump.z = 60; sound = snd_play (impact, 100, 1); } } } } function redux() { while (1) { if (ball_jump.z > 0) { ball_jump.z = - 1*time_step; } wait(-0.1); } } function main() { pXent_setcollisionflag(ball, NULL, NX_NOTIFY_ON_TOUCH); ball.event = jump; redux(); while (1) { pXent_addvelcentral(ball, ball_jump); } }