25 lines
775 B
GDScript
25 lines
775 B
GDScript
extends Area2D
|
|
class_name Player
|
|
|
|
const GROUP = "player"
|
|
|
|
const _movementSpeed = 2
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
if Input.is_action_pressed("MoveUp"):
|
|
$AnimatedSprite2D.global_position += Vector2.UP * 2
|
|
if Input.is_action_pressed("MoveDown"):
|
|
$AnimatedSprite2D.global_position += Vector2.DOWN * 2
|
|
if Input.is_action_pressed("MoveLeft"):
|
|
$AnimatedSprite2D.global_position += Vector2.LEFT * 2
|
|
if Input.is_action_pressed("MoveRight"):
|
|
$AnimatedSprite2D.global_position += Vector2.RIGHT * 2
|
|
|
|
$Camera2D.global_position = $AnimatedSprite2D.global_position
|