physics layer, veg terrain, parallax background, collectables, basic slimes

This commit is contained in:
RudyIm committed 2025-10-27 21:02:09 -04:00
1 parent 869d4b70cf
commit 8d07c7630f
26 files changed
+688 -4

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
class_name Coin extends Area2D
signal coinCollectedSignal(body, coin)
# 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:
pass
func _on_body_entered(body: Node2D) -> void:
print("body entered in coin")
if body is Player:
coinCollectedSignal.emit(body, self)
+1
View File
@@ -0,0 +1 @@
uid://b68u5fhlky241
+20
View File
@@ -5,6 +5,9 @@ var cratesDestroyed = 0
var timeLimit = 10
var timer:= Timer.new()
var coinsCollectedTotal:int = 0
var totalCoinsAvailable:int = 0
# Called when the node enters the scene tree for the first time.
func _ready():
add_child(timer)
@@ -33,3 +36,20 @@ func _on_trigger_fired(intent: Variant, body) -> void:
get_tree().reload_current_scene()
"powerup":
print("power up this thing")
func _on_coin_collected(body, coin):
print("GC knows coin collected")
coinsCollectedTotal += 1
coin.queue_free()
if coinsCollectedTotal >= totalCoinsAvailable:
print("You won the level!")
func totalCoins(value):
totalCoinsAvailable = value
func _on_slime_damage(body, slime):
print("GC knows slime damage")
func totalEnemies(value):
print("GC knows total enemies " + str(value))
#totalEnemies = value
+1 -1
View File
@@ -1,4 +1,4 @@
extends CharacterBody2D
class_name Player extends CharacterBody2D
const SPEED = 300.0
+24 -1
View File
@@ -2,6 +2,9 @@ class_name SceneManager extends Node2D
var bullet = preload("res://scenes/bullet.tscn")
@onready var coins: Node2D = $"../Coins"
@onready var enemies: Node2D = $"../Enemies"
@onready var game: Node2D = $".."
var bulletArray = []
@@ -11,8 +14,28 @@ var grenade = preload("res://scenes/grenade.tscn")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
buildLevel()
func buildLevel() -> void:
# hook up coins
var totalCoins = 0
if coins:
for obj in coins.get_children():
if obj is Coin:
totalCoins += 1
# hook up a listener at the game controller
obj.coinCollectedSignal.connect(game._on_coin_collected)
# tell GC how many coins total
game.totalCoins(totalCoins)
var totalEnemies = 0
if enemies:
for obj in enemies.get_children():
if obj is Slime:
totalEnemies += 1
# hook up a listener at the game controller
obj.slimeDamageSignal.connect(game._on_slime_damage)
game.totalEnemies(totalEnemies)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
+18
View File
@@ -0,0 +1,18 @@
class_name Slime extends Area2D
signal slimeDamageSignal(body, slime)
# 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:
pass
func _on_body_entered(body: Node2D) -> void:
print("slime detects body")
if body is Player:
slimeDamageSignal.emit(body, self)
+1
View File
@@ -0,0 +1 @@
uid://0mkt8m2sv83a