GodotCourse/week5/updated_project/scripts/gamecontroller.gd

30 lines
658 B
GDScript3
Raw Normal View History

2024-08-12 14:22:12 +00:00
extends Node2D
2024-08-12 19:19:54 +00:00
var coinsCollected = 0
2024-08-12 14:22:12 +00:00
var crate = preload("res://scenes/crate.tscn")
@onready var boxtrap = $crates/boxtrap
2024-08-12 19:19:54 +00:00
@onready var player = $CharacterBody2D
2024-08-12 14:22:12 +00:00
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")
2024-08-12 19:19:54 +00:00
"kill":
print("kill the player")
func coinCollected():
coinsCollected +=1
print("coins collected "+str(coinsCollected) )
func playerDeath():
print("kill the player")