| Forum Home > Turing > Jumping character (on 2d ss) | ||
|---|---|---|
|
Moderator Posts: 5 |
Here is a sample code to get a character to jump upward. Its simple and just modifies velocity. const Gravity := 2 var x := 100 var y := 100 var y_velocity := 0 var keys : array char of boolean setscreen ("offscreenonly") loop Input.KeyDown (keys) if keys (KEY_UP_ARROW) and y <= 0 then y_velocity := 30 %If the jump button is pressed, velocity shoots up. end if if keys (KEY_LEFT_ARROW) and x > 0 then x -= 5 %basic X movement. end if if keys (KEY_RIGHT_ARROW) and x < maxx then x += 5 end if
y_velocity -= Gravity y += y_velocity
if y < 0 then %this makes sure the character stays above the ground (if he goes undr, it brings him back up) y := 0 y_velocity := 0 end if
Draw.FillOval (x, y, 10, 10, 79) View.Update delay (20) cls end loop
| |
|
-- - Stanley
| ||
|
Member Posts: 11 |
im just saying, we shouldn't bother making these with this idk what language. flash actionscript is soooo mush better for these small games... | |
| ||
|
Moderator Posts: 8 |
Mmm, yeah flash can be useful sometimes, like for these simpler examples, but if you want to make more complicated programs with turing or any other language, you'll have to start simpler first, and build your skills up - Rui | |
| ||