1
Fork 0
mirror of https://github.com/Steffo99/watermelonkeys-patched-ld51.git synced 2024-11-25 09:24:24 +00:00
fading-sun/Giovanna.gd

37 lines
857 B
GDScript3
Raw Normal View History

2022-10-03 13:27:12 +00:00
class_name Giovanna
2022-10-03 13:05:31 +00:00
extends KinematicBody2D
2022-10-03 13:27:12 +00:00
export(float, 0.01, 2.0, 0.01) var stopping_force = 1.0
2022-10-03 13:05:31 +00:00
var ammo = 6
var velocity = Vector2(0,0)
const max_speed = 150
const GRAVITY = 30
const JUMPFORCE = -500
2022-10-03 13:27:12 +00:00
func _ready():
owner.set_meta("player", self)
2022-10-03 13:05:31 +00:00
func _physics_process(delta):
if Input.is_action_pressed("right"):
velocity.x = max_speed
$AnimatedSprite.play("walk")
$AnimatedSprite.flip_h = true
elif Input.is_action_pressed("left"):
velocity.x = -max_speed
$AnimatedSprite.play("walk")
$AnimatedSprite.flip_h = false
else:
$AnimatedSprite.play("idle")
if not is_on_floor():
$AnimatedSprite.play("air")
velocity.y = velocity.y + GRAVITY
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMPFORCE
velocity = move_and_slide(velocity,Vector2.UP)
2022-10-03 13:27:12 +00:00
velocity.x = lerp(velocity.x,0,stopping_force)
2022-10-03 13:05:31 +00:00