rpg/Scripts/player.gd

32 lines
731 B
GDScript3
Raw Normal View History

2022-04-06 03:23:22 +00:00
extends KinematicBody2D
## zoom zoom
export (int) var speed = 200
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
2022-04-06 03:51:49 +00:00
func _physics_process(delta):
2022-04-06 03:23:22 +00:00
var direction = Vector2.ZERO
if Input.is_action_pressed("right"):
direction.x += 1
if Input.is_action_pressed("left"):
direction.x -= 1
if Input.is_action_pressed("up"):
direction.y -= 1
2022-04-06 03:51:49 +00:00
if Input.is_action_pressed("down"):
direction.y += 1
print(direction.normalized()*speed)
direction = direction.normalized() * speed
move_and_collide(direction)
2022-04-06 03:23:22 +00:00