extends KinematicBody2D
const speed = 200
const jump_power = -250
export (int) var gravity = 100
const FLOOR = Vector2(0, -1)
var velocity = Vector2()
var on_ground = false
func physicsprocess(delta):
if Input.is_action_pressed("kanan"):
velocity.x = speed
elif Input.is_action_pressed("kiri"):
velocity.x = -speed
else:
velocity.x = 0
if Input.is_action_pressed("lompat"):
if on_ground == true:
velocity.y = jump_power
on_ground = false
else:
velocity.y = 0
velocity.y += gravity
if is_on_floor():
on_ground = true
else:
on_ground = false
velocity = move_and_slide(velocity, FLOOR)