physics layer, veg terain, parallax background, collectables, basic slimes
This commit is contained in:
1 parent
d656a8663e
commit
bdaeeec44f
26 files changed
+700
-12
No files matched your search
@@ -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():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
print("body connected with coin")
|
||||
if body is Player:
|
||||
coinCollectedSignal.emit(body, self)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dxweii7qmijb8
|
||||
@@ -1,5 +1,7 @@
|
||||
extends Node2D
|
||||
|
||||
var coinsCollectedTotal:int = 0
|
||||
var totalCoinsAvailable:int = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -19,3 +21,18 @@ func _on_trigger_fired(intent, body):
|
||||
body.queue_free()
|
||||
"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))
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
extends CharacterBody2D
|
||||
class_name Player extends CharacterBody2D
|
||||
|
||||
|
||||
const SPEED = 300.0
|
||||
|
||||
@@ -2,6 +2,8 @@ class_name SceneManager extends Node2D
|
||||
|
||||
var bullet = preload("res://scenes/bullet.tscn")
|
||||
var grenade = preload("res://scenes/grenade.tscn")
|
||||
@onready var coins = $"../Coins"
|
||||
@onready var enemies = $"../Enemies"
|
||||
|
||||
@onready var game = $".."
|
||||
var bulletArray = []
|
||||
@@ -9,8 +11,29 @@ var totalAllowedBullets = 7
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
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 game controller
|
||||
obj.slimeDamageSignal.connect(game._on_slime_damage)
|
||||
pass
|
||||
game.totalEnemies(totalEnemies)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class_name Slime extends Area2D
|
||||
|
||||
signal slimeDamageSignal(body, slime)
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
print("slime detects body")
|
||||
if body is Player:
|
||||
slimeDamageSignal.emit(body, self)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cx2xxgqkp68jc
|
||||
Reference in new issue
Block a user