diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2022-06-03 21:13:19 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2022-06-03 21:13:19 -0600 |
commit | f922fe4669080d1633e0a345a3f8981867c9e841 (patch) | |
tree | 7c2c98bfca20fda37fe34ba99e2d3caa9a39ca02 /src/entities/actors/snake/scripts/generic_segment.gd | |
parent | 898877f09808691a5e5d45850d27ae85f270db16 (diff) |
add working world gen, fixed food placing, minor refactoring
Diffstat (limited to 'src/entities/actors/snake/scripts/generic_segment.gd')
-rw-r--r-- | src/entities/actors/snake/scripts/generic_segment.gd | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/entities/actors/snake/scripts/generic_segment.gd b/src/entities/actors/snake/scripts/generic_segment.gd index e2db91d..d0bb944 100644 --- a/src/entities/actors/snake/scripts/generic_segment.gd +++ b/src/entities/actors/snake/scripts/generic_segment.gd @@ -6,6 +6,7 @@ onready var _segment: Area2D = get_child(0) func _ready() -> void: + Event.connect("snake_rotated", self, "_on_snake_rotated") _segment.connect("body_entered", self, "_on_body_entered") @@ -15,3 +16,9 @@ func _physics_process(delta: float) -> void: func _on_body_entered(body: Node) -> void: Event.emit_signal("snake_segment_body_entered", body) + + +func _on_snake_rotated() -> void: + # this is just random, i need to offset a tiny bit whenever the snake rotates + # so that the first body segmetn doesn't catch up with the head + offset -= Global.SNAKE_SPEED * pow(get_physics_process_delta_time(), 2)
\ No newline at end of file |