#5 développement du mouvement du robot et d'une caméra qui le suit
This commit is contained in:
14
entities/player/scripts/player.gd
Normal file
14
entities/player/scripts/player.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
extends CharacterBody2D
|
||||
class_name Player
|
||||
|
||||
@export var speed = 400
|
||||
|
||||
func get_input():
|
||||
var input_direction : Vector2 = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||
velocity = input_direction * speed
|
||||
if input_direction.x:
|
||||
$Sprite.flip_h = (input_direction.x < 0)
|
||||
|
||||
func _physics_process(_delta):
|
||||
get_input()
|
||||
move_and_slide()
|
||||
Reference in New Issue
Block a user