Add a very basic enemy

This commit is contained in:
CactiChameleon9 2022-07-17 17:22:52 +01:00
parent 6ec76a2988
commit d0e99788fb
2 changed files with 28 additions and 0 deletions

17
Characters/Enemy.gd Normal file
View File

@ -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

11
Characters/Enemy.tscn Normal file
View File

@ -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 )