30 lines
658 B
GDScript
30 lines
658 B
GDScript
extends Node2D
|
|
|
|
var coinsCollected = 0
|
|
|
|
var crate = preload("res://scenes/crate.tscn")
|
|
@onready var boxtrap = $crates/boxtrap
|
|
@onready var player = $CharacterBody2D
|
|
|
|
func _on_area_2d_areatrigger(effect, body):
|
|
print("Game Controller sees the trigger "+effect)
|
|
match effect:
|
|
"alert":
|
|
#do stuff
|
|
if body.is_in_group("player"):
|
|
for n in 3:
|
|
var box = crate.instantiate()
|
|
add_child(box)
|
|
box.position = boxtrap.position
|
|
"powerup":
|
|
print("you got power")
|
|
"kill":
|
|
print("kill the player")
|
|
func coinCollected():
|
|
coinsCollected +=1
|
|
print("coins collected "+str(coinsCollected) )
|
|
|
|
func playerDeath():
|
|
print("kill the player")
|
|
|