27 lines
339 B
GDScript
27 lines
339 B
GDScript
extends CharacterBody2D
|
|
|
|
|
|
var SPEED = Vector2(5, 0)
|
|
const JUMP_VELOCITY = -400.0
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
$Timer.start()
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
velocity += get_gravity() * delta
|
|
move_and_slide()
|
|
patrol()
|
|
|
|
|
|
func patrol():
|
|
position += SPEED
|
|
|
|
|
|
func _on_timer_timeout() -> void:
|
|
SPEED = -SPEED
|
|
$Timer.start()
|