diff --git a/Characters/Enemy.gd b/Characters/Enemy.gd new file mode 100644 index 0000000..3e64f73 --- /dev/null +++ b/Characters/Enemy.gd @@ -0,0 +1,17 @@ +extends Node2D + +export var map_position : Vector2 = Vector2.ZERO + +var target_position : Vector2 = Vector2.ZERO +var moving : bool = false + + +func _physics_process(delta): + + # If the 2 positions are close enough, then not moving + moving = false if target_position.round() == position.round() else true + + if not moving: return + + #TODO: Replace with tween magic + position += (target_position - position)/2.5 diff --git a/Characters/Enemy.tscn b/Characters/Enemy.tscn new file mode 100644 index 0000000..65fd2fc --- /dev/null +++ b/Characters/Enemy.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://icon.png" type="Texture" id=1] +[ext_resource path="res://Characters/Enemy.gd" type="Script" id=2] + +[node name="Enemy" type="Node2D" groups=["Enemy"]] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +modulate = Color( 1, 0, 0, 1 ) +texture = ExtResource( 1 )