Added static typing and enforced it

This commit is contained in:
Dan 2024-06-01 20:36:05 +01:00
parent 217f0ab18c
commit cc80783d16
4 changed files with 47 additions and 29 deletions

View file

@ -1,21 +1,23 @@
extends Node2D
class_name Glowling
@onready var tilemap = $"../TileMap" # This needs rectifying
@onready var tilemap : CustomTileMap = $"../TileMap" # This needs rectifying
var current_path : Array[Vector2i] = []
@onready var animation_player : AnimationPlayer = $GlowlingAnimations
var speed : int = 40
func _ready():
$GlowlingAnimations.play("GlowingPulse")
func _ready() -> void:
animation_player.play("GlowingPulse")
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
func _process(delta : float) -> void:
if current_path.is_empty():
return
var target_position = tilemap.map_to_local(current_path.front())
var target_position : Vector2 = tilemap.map_to_local(current_path.front() as Vector2i)
global_position = global_position.move_toward(target_position, speed * delta)
if global_position == target_position:
@ -23,8 +25,8 @@ func _process(delta):
pass
## This is the temporary way for having something move
func _unhandled_input(event):
var click_position = get_global_mouse_position()
func _unhandled_input(event : InputEvent) -> void:
var click_position : Vector2 = get_global_mouse_position()
if event.is_action_pressed("move_to"):
if tilemap.is_point_walkable(click_position):
current_path = tilemap.astar.get_id_path(