diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2022-06-04 23:00:58 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2022-06-04 23:00:58 -0600 |
commit | 36abc689d783774ce4f2d7b5a1bb621d8684be45 (patch) | |
tree | a3dbed6069fbd8d9a588c7510ce581af3e847af0 /src/entities/actors/snake | |
parent | 9a2bcf02c2623c8f3e8f5e74e70b3c0333790484 (diff) |
added more ui for after gameplay, generalized basic food
Diffstat (limited to 'src/entities/actors/snake')
-rw-r--r-- | src/entities/actors/snake/scripts/head.gd | 13 | ||||
-rw-r--r-- | src/entities/actors/snake/scripts/snake.gd | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/entities/actors/snake/scripts/head.gd b/src/entities/actors/snake/scripts/head.gd index 32847f7..8747910 100644 --- a/src/entities/actors/snake/scripts/head.gd +++ b/src/entities/actors/snake/scripts/head.gd @@ -28,6 +28,19 @@ func _physics_process(delta: float) -> void: # not sure if needed, worked wonders when using a Node2D instead of KB2D velocity = move_and_slide(velocity) + + # slow down on collisions, so it isn't as unfair + if get_last_slide_collision(): + var speed: float = velocity.length() + Global.SNAKE_SPEED = speed + else: + Global.SNAKE_SPEED = Global.SNAKE_SPEED_BACKUP + + # handle slow speeds + if Global.SNAKE_SPEED <= Global.SNAKE_SPEED_BACKUP / 4.0: + Global.SNAKE_SPEED = Global.SNAKE_SPEED_BACKUP + Event.emit_signal("game_over") + _handle_time_elapsed(delta) diff --git a/src/entities/actors/snake/scripts/snake.gd b/src/entities/actors/snake/scripts/snake.gd index 91e4e39..bae6e83 100644 --- a/src/entities/actors/snake/scripts/snake.gd +++ b/src/entities/actors/snake/scripts/snake.gd @@ -6,6 +6,8 @@ export(PackedScene) var TAIL_SEGMENT_NP: PackedScene onready var path: Path2D = $Path +var stats: Stats = SaveData.get_stats() + var finished_adding_initial_segments: bool = false var current_body_segments: int = 0 var body_segment_stack: Array |