Add a very basic enemy
This commit is contained in:
parent
6ec76a2988
commit
d0e99788fb
17
Characters/Enemy.gd
Normal file
17
Characters/Enemy.gd
Normal 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
11
Characters/Enemy.tscn
Normal 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 )
|
Loading…
x
Reference in New Issue
Block a user