34 lines
800 B
GDScript3
34 lines
800 B
GDScript3
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.
|
|
func _physics_process(delta):
|
|
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
|
|
if Input.is_action_pressed("down"):
|
|
direction.y += 1
|
|
if direction.y != 0 and direction.x !=0:
|
|
direction = Vector2.ZERO
|
|
print(direction.normalized()*speed)
|
|
direction = direction.normalized() * speed
|
|
move_and_collide(direction)
|
|
|