summaryrefslogtreecommitdiff
path: root/Spatial.gd
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2026-11-14 10:31:37 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2026-11-14 10:31:37 +0100
commit1f33e9cd8223da7c92b0ec3ffa3af97ecda6deed (patch)
tree5351940ce0040eb03a97b094f1a2f8418e37a18c /Spatial.gd
parent1b5c02c6ac4938d7891084ba3af66958c1cc05f3 (diff)
downloadnj26-1f33e9cd8223da7c92b0ec3ffa3af97ecda6deed.tar.gz
Setup Team + add powerup tcsn
Diffstat (limited to 'Spatial.gd')
-rw-r--r--Spatial.gd82
1 files changed, 52 insertions, 30 deletions
diff --git a/Spatial.gd b/Spatial.gd
index 25330aa..64f0ad8 100644
--- a/Spatial.gd
+++ b/Spatial.gd
@@ -1,43 +1,65 @@
extends Spatial
-var box = preload("res://box.tscn")
+const t = preload("res://team.gd")
+var b = preload("res://box.tscn")
+
+var blue_points = 0
+var pink_points = 0
func randpos() -> float:
- return randf() * 5
+ return randf() * 6.0
-func _entered(node: Node):
- if node == get_node("mesh/MeshInstance2/basefloor"):
- pass
+func set_points(box, points):
+ var team = box.myteam
-func _exited(node: Node):
- if node == get_node("mesh/MeshInstance2/basefloor"):
- pass
+ if team == t.Team.BLUE:
+ blue_points += points
+ else:
+ pink_points += points
-# Called when the node enters the scene tree for the first time.
-func _ready():
- randomize()
+ print("Team blue has %d points" % blue_points)
+ print("Team pink has %d points" % pink_points)
+
+func _entered(box):
+ set_points(box, 1)
+
+func _exited(box):
+ set_points(box, -1)
+
+func create_box(team):
+ var box = b.instance()
+ var x = randpos()
+ var z = randpos()
- for _i in range(30):
- var b = box.instance()
- var x = randpos()
- var z = randpos()
+ box.set_team(team)
+ box.set_floor(get_node("mesh/MeshInstance2/basefloor"))
- if x < 2.0 and z > 2.0:
- x += 2
- x = fmod(x, 5)
- elif z < 2.0:
- z += 2
- z = fmod(z, 5)
+ if x < 2.0 and z > 2.0:
+ x += 2
+ x = fmod(x, 6)
+ elif z < 2.0:
+ z += 2
+ z = fmod(z, 6)
- if randi() & 1:
- x = -x
+ if randi() & 1:
+ x = -x
- if randi() & 1:
- z = -z
+ if randi() & 1:
+ z = -z
+
+ var pos = Vector3(x, 10, z)
+
+ box.translate(pos)
+ box.connect("entered", self, "_entered")
+ box.connect("exited", self, "_exited")
+ add_child(box)
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ randomize()
- var pos = Vector3(x, 10, z)
+ for _i in range(15):
+ create_box(t.Team.PINK)
- b.translate(pos)
- b.connect("body_entered", self, "_entered")
- b.connect("body_exited", self, "_exited")
- add_child(b)
+ for _i in range(15):
+ create_box(t.Team.BLUE)