Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Fustyv |
I am following the Your First Game tutorial.
Wrote the player movement as described but whenever I press F5 to test it (Or F6) it is stuck on the Godot Engine logo, also I cannot exit it from the windows I have to go to the engine and press the stop bottom.
I can minimize it, but I cannot force quit it.
I had this problem previously, then I quit and removed the project and created a new one, and after that it did work.
Is it a classic IBM error?
The code I wrote is like this:
extends Area2D
export (int) var SPEED
var screensize
func _ready():
screensize = get_viewport_rect()
pass
func _process(delta):
var velocity = Vector2()
if input.is_action_pressed("ui_right"):
velocity.x += 1
if input.is_action_pressed("ui_left"):
velocity.x -= 1
if input.is_action_pressed("ui_down"):
velocity.y += 1
if input.is_action_pressed("ui_up"):
velocity.y -= 1
if velocity.length > 0:
velocity = velocity.normalized() + SPEED
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()
position += velocity + delta
position.x = clamp(position.x, 0, screensize.x)
position.y = clamp(position.y, 0, screensize.y)