2024-04-16 20:29:45 -04:00
|
|
|
extends RigidBody2D
|
|
|
|
|
|
|
|
var speed = 1000 # move speed in pixels/sec
|
|
|
|
var rotation_speed = 3 # turning speed in radians/sec
|
|
|
|
var quare = preload("res://quare.tscn")
|
|
|
|
var exagon = preload("res://exagon.tscn")
|
|
|
|
@onready var notifier = $"../Notification"
|
2024-04-17 15:00:20 -04:00
|
|
|
var absolute_movement = false
|
2024-04-17 18:39:03 -04:00
|
|
|
var config = ConfigFile.new()
|
2024-04-16 20:29:45 -04:00
|
|
|
|
2024-04-18 19:45:52 -04:00
|
|
|
var moving = false
|
2024-05-06 14:09:14 -04:00
|
|
|
var frozen = false
|
|
|
|
|
|
|
|
func update_animation():
|
|
|
|
pass
|
2024-04-18 19:45:52 -04:00
|
|
|
|
2024-04-16 20:29:45 -04:00
|
|
|
func _ready():
|
2024-04-18 19:45:52 -04:00
|
|
|
update_animation()
|
2024-04-17 18:39:03 -04:00
|
|
|
if config.load("user://settings.cfg") == OK:
|
|
|
|
absolute_movement = not config.get_value("config", "relative_controls")
|
2024-04-16 20:29:45 -04:00
|
|
|
|
|
|
|
func _physics_process(delta):
|
2024-05-06 14:09:14 -04:00
|
|
|
if frozen:
|
|
|
|
return
|
2024-04-16 20:29:45 -04:00
|
|
|
look_at(get_global_mouse_position())
|
|
|
|
var move_input = Input.get_axis("down", "up")
|
2024-04-17 19:14:46 -04:00
|
|
|
var side_input = Input.get_axis("right", "left")
|
2024-04-18 19:45:52 -04:00
|
|
|
if move_input > 0 and not moving:
|
|
|
|
moving = true
|
|
|
|
update_animation()
|
|
|
|
elif move_input <= 0 and moving:
|
|
|
|
moving = false
|
|
|
|
update_animation()
|
|
|
|
|
2024-04-17 15:00:20 -04:00
|
|
|
if absolute_movement:
|
2024-05-06 10:05:42 -04:00
|
|
|
apply_central_force(Vector2(side_input, move_input).normalized() * -speed)
|
2024-04-17 15:00:20 -04:00
|
|
|
else:
|
2024-04-17 19:14:46 -04:00
|
|
|
apply_central_force(transform.y * side_input * speed / -2 + transform.x * move_input * speed)
|
2024-04-16 20:29:45 -04:00
|
|
|
|
|
|
|
func destroy():
|
2024-04-20 09:45:17 -04:00
|
|
|
$DeathFX.play()
|
2024-04-16 20:29:45 -04:00
|
|
|
get_tree().paused = true
|
|
|
|
$"../GameOver".visible = true
|