extends KinematicBody2D
const UP = Vector2(0,-1)
const GRAVITY = 20
const MAXFALLSPEED = 200
const MAXSPEED = 80
const JUMPFORCE = 300
const ACCEL = 10
var motion = Vector2()
var facing_right = true
func _ready():
pass
func _physics_process(_delta):
motion.y += GRAVITY
if motion.y > MAXFALLSPEED:
motion.y = MAXFALLSPEED
if facing_right == true:
$Lancer.scale.x = 1
else:
$Lancer.scale.x = -1
motion.x = clamp(motion.x,-MAXSPEED,MAXSPEED)
if Input.is_action_pressed("right"):
motion.x += ACCEL
facing_right = true
elif Input.is_action_pressed("left"):
motion.x -= ACCEL
facing_right = false
else:
motion.x = lerp(motion.x,0,0.2)
if is_on_floor():
if Input.is_action_just_pressed("jump"):
motion.y = -JUMPFORCE
motion = move_and_slide(motion,UP)