36 lines
1 KiB
GDScript
36 lines
1 KiB
GDScript
extends Node2D
|
|
|
|
@export var snake_man : Node2D
|
|
@export var count : Label
|
|
@export var my_area : Area2D
|
|
@export var brain : Node2D
|
|
@export var furnace_sprite : AnimatedSprite2D
|
|
var player_detected : bool
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
count.text = str( ceilf(snake_man.burn_apples*10)/10 )
|
|
if my_area.get_overlapping_areas():
|
|
player_detected = false
|
|
for overlaps in my_area.get_overlapping_areas():
|
|
if overlaps.is_in_group("braincell"):
|
|
player_detected = true
|
|
if player_detected:
|
|
modulate = Color (2,2,2)
|
|
else:
|
|
modulate = Color.WHITE
|
|
|
|
if snake_man.burn_apples > 0:
|
|
furnace_sprite.play("on")
|
|
else:
|
|
furnace_sprite.play("off")
|
|
|
|
#print(str(player_detected) + " "+ str(snake_man.pit_apples) +" " +str(brain.holding_apple))
|
|
if player_detected and brain.holding_apple:
|
|
if Input.is_action_just_pressed("action"):
|
|
Router.burn_apple.emit()
|