need to sleep
This commit is contained in:
parent
dafae35985
commit
211a5e074b
13 changed files with 381 additions and 15 deletions
|
|
@ -9,11 +9,15 @@ var food : float = 5
|
|||
@export var max_food = 5
|
||||
@export var food_drain = 0.1
|
||||
var pit_apples : int = 0
|
||||
var burn_apples : float = 0
|
||||
var score : int = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
Router.activate_seg.connect(activate_segment)
|
||||
Router.eat_apple.connect(rec_apple)
|
||||
Router.pickup_apple.connect(pickupApple)
|
||||
Router.burn_apple.connect(burnApple)
|
||||
food = max_food
|
||||
#segements = get_children() as Array[snake_segment]
|
||||
segements.assign(segements_holder.get_children())
|
||||
|
|
@ -38,9 +42,18 @@ func _process(delta: float) -> void:
|
|||
if(Input.is_action_just_pressed("test_add_segment")):
|
||||
add_segment()
|
||||
|
||||
|
||||
burn_apples -= 0.2 * delta
|
||||
if burn_apples <= 0:
|
||||
burn_apples = 0
|
||||
else:
|
||||
food += 0.3 * delta
|
||||
|
||||
if food > max_food:
|
||||
food = max_food
|
||||
food -= food_drain * delta
|
||||
|
||||
|
||||
pass
|
||||
|
||||
func activate_segment(act_segment : int):
|
||||
|
|
@ -73,8 +86,15 @@ func add_segment():
|
|||
func rec_apple():
|
||||
#food += 1
|
||||
pit_apples += 1
|
||||
SNAKE_SPEED += 0.1
|
||||
SNAKE_SPEED += 0.03
|
||||
score += 5
|
||||
add_segment()
|
||||
for seg in segements:
|
||||
seg.snake_speed = SNAKE_SPEED
|
||||
|
||||
|
||||
func pickupApple():
|
||||
pit_apples -= 1
|
||||
|
||||
func burnApple():
|
||||
burn_apples += 1
|
||||
score += 5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue