2022-07-17 14:24:15 +02:00
|
|
|
extends KinematicBody2D
|
|
|
|
|
2022-07-18 03:28:10 +02:00
|
|
|
const GRAVITY = 2000.0
|
|
|
|
const SNAP = Vector2(0, 100)
|
|
|
|
var velocity = Vector2(0, 0)
|
|
|
|
var snap = SNAP
|
2022-07-17 14:24:15 +02:00
|
|
|
export var health : int = 100
|
|
|
|
|
2022-07-18 03:28:10 +02:00
|
|
|
func _process_gravity(delta):
|
2022-07-17 14:24:15 +02:00
|
|
|
if not is_on_floor():
|
2022-07-18 03:28:10 +02:00
|
|
|
velocity.y += delta * GRAVITY
|
2022-07-17 14:24:15 +02:00
|
|
|
else:
|
2022-07-18 03:28:10 +02:00
|
|
|
velocity.y = 1
|
2022-07-17 14:24:15 +02:00
|
|
|
if is_on_ceiling():
|
2022-07-18 03:28:10 +02:00
|
|
|
velocity.y = 1
|
2022-07-17 14:24:15 +02:00
|
|
|
|
|
|
|
func _physics_process(delta):
|
2022-07-18 03:28:10 +02:00
|
|
|
if velocity != null:
|
|
|
|
move_and_slide_with_snap(velocity, snap, Vector2(0, -1))
|
|
|
|
_process_gravity(delta)
|