coyote hunt

This commit is contained in:
chimchooree
2023-09-08 10:07:22 -05:00
commit 25e72421c3
88 changed files with 1143 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
extends "res://events/moved/Moved.gd"
# Event Handler for Character Moving
func _arrived(character): # at next
var next = character.get_next()
return next && character.reached_next()
func _reached(character): # at current dot
var cd = character.get_current_dot()
return cd && character.reached_current_dot()
+6
View File
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://events/moved/Char.gd" type="Script" id=1]
[node name="Moved" type="Node"]
script = ExtResource( 1 )
+51
View File
@@ -0,0 +1,51 @@
extends Node
# Event Handler for Moving
# Variable
var topic = "moved"
var positions = []
func _arrived(_character):
return false
# are positions the same?
func compare_pos():
var p1 = positions[0]
for p in positions:
if p != p1:
return false # moving
return true # not moving
func _reached(_character):
return false
func track_pos(new_pos):
positions.append(new_pos)
if len(positions) > 50:
positions.pop_front()
# Handle
func handle(character):
var current_pos = character.get_gpos()
track_pos(current_pos)
if _arrived(character):
character.think("Moved/Arrived")
character.emit_signal("arrived")
return
elif _reached(character):
character.think("Moved/Reached Dot")
character.emit_signal("reached")
return
elif compare_pos():
character.think("Moved/Not Moving")
character.emit_signal("not_moving")
return
#elif character.get_internal_velocity() != Vector2(0.0,0.0) and character.get_velocity() != character.get_internal_velocity():
# var sdfoia = character.get_internal_velocity()
# var posjk = character.get_velocity()
# character.think("Moved/Wrong Directiaon")
# character.emit_signal("wrong_direction")
else:
return