godot/scripting_first_script/Sprite2D.gd

21 lines
457 B
GDScript

extends Sprite2D
var speed = 400
var angular_speed = PI
func _process(delta):
var direction = 0
if Input.is_action_pressed('ui_left'):
direction = -1
if Input.is_action_pressed('ui_right'):
direction = +1
rotation += angular_speed * direction * delta
var velocity = Vector2.UP.rotated(rotation) * speed
if Input.is_action_pressed('ui_up'):
position += velocity * delta
if Input.is_action_pressed('ui_down'):
position -= velocity * delta