feat: add gameScene; add player movement;
This commit is contained in:
+19
-3
@@ -1,11 +1,27 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var move_speed: float = 100
|
||||
@export var hp: int = 10
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
var damage: float = 2
|
||||
print(damage)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
var move_vector: Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
velocity = move_vector * move_speed
|
||||
if velocity.x > 0:
|
||||
$AnimatedSprite2D.play("move_right")
|
||||
print(velocity)
|
||||
if velocity.x < 0:
|
||||
$AnimatedSprite2D.play("move_left")
|
||||
print(velocity)
|
||||
if velocity.y > 0:
|
||||
$AnimatedSprite2D.play("move_down")
|
||||
print(velocity)
|
||||
if velocity.y < 0:
|
||||
$AnimatedSprite2D.play("move_up")
|
||||
print(velocity)
|
||||
move_and_slide()
|
||||
|
||||
Reference in New Issue
Block a user