parallax background, second terrain for veggies, start of custom player graphics, collectible coin
This commit is contained in:
1 parent
bb9f58ae08
commit
ac67579888
31 files changed
+726
-59
No files matched your search
@@ -0,0 +1,7 @@
|
||||
class_name Coin extends Area2D
|
||||
signal coinCollectedSignal(body,coin)
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if body is Player:
|
||||
print("you hit a coin")
|
||||
coinCollectedSignal.emit(body,self)
|
||||
@@ -0,0 +1 @@
|
||||
uid://d2sc7mlvheh7m
|
||||
+10
-2
@@ -5,6 +5,7 @@ signal teleportTriggerSignal(body)
|
||||
var numberOfCrates = 2
|
||||
var timeAvailable = 50
|
||||
|
||||
var totalCoinsCollected = 0
|
||||
var timer = Timer.new()
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@@ -31,7 +32,8 @@ func _on_trigger(body: Variant, trigger: Variant, intent:String) -> void:
|
||||
print("GC knows trigger fired")
|
||||
match intent:
|
||||
"destroy":
|
||||
destroySignal.emit(body)
|
||||
if body is RigidBody2D:
|
||||
destroySignal.emit(body)
|
||||
"fan":
|
||||
print("do a fan effect")
|
||||
fanTriggerSignal.emit(body,Vector2(0,-1)*100*9)
|
||||
@@ -45,7 +47,13 @@ func crateTotal(howmany):
|
||||
if numberOfCrates == 0:
|
||||
print("YOU WON!!!")
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
func coinCollected(body,coin)->void:
|
||||
totalCoinsCollected +=1
|
||||
print("GC knows coin collected")
|
||||
destroySignal.emit(coin)
|
||||
func coinTotal(totalAmount)->void:
|
||||
print("GC knows total coins "+str(totalAmount))
|
||||
|
||||
func bulletDamage(body, _bullet)->void:
|
||||
if body.is_in_group("shootable"):
|
||||
destroySignal.emit(body)
|
||||
|
||||
@@ -2,6 +2,8 @@ extends Node2D
|
||||
@onready var game: GameController = $".."
|
||||
@onready var crates: Node2D = $"../Crates"
|
||||
@onready var player: Player = $"../Player"
|
||||
@onready var coin: Coin = $"../Coins/Coin"
|
||||
@onready var coins: Node2D = $"../Coins"
|
||||
|
||||
var bullet = preload("res://scenes/bullet.tscn")
|
||||
var rocket = preload("res://scenes/rocket.tscn")
|
||||
@@ -22,6 +24,9 @@ func _ready() -> void:
|
||||
game.destroySignal.connect(destroy)
|
||||
game.fanTriggerSignal.connect(pushTarget)
|
||||
game.teleportTriggerSignal.connect(teleportTarget)
|
||||
|
||||
#signals from pickups
|
||||
coin.coinCollectedSignal.connect(game.coinCollected)
|
||||
buildLevel()
|
||||
|
||||
|
||||
@@ -32,6 +37,7 @@ func _process(delta: float) -> void:
|
||||
func buildLevel()->void:
|
||||
#tell GC how many crates...
|
||||
updateCrates()
|
||||
updateCoins()
|
||||
|
||||
func updateCrates()->void:
|
||||
var totalCrates = 0
|
||||
@@ -44,6 +50,14 @@ func updateCrates()->void:
|
||||
|
||||
game.crateTotal(totalCrates)
|
||||
|
||||
func updateCoins()->void:
|
||||
var totalCoins = 0
|
||||
if coins:
|
||||
for obj in coins.get_children():
|
||||
if obj is Coin:
|
||||
totalCoins +=1
|
||||
game.coinTotal(totalCoins)
|
||||
|
||||
func pushTarget(body,pushDirection)->void:
|
||||
if body is RigidBody2D:
|
||||
body.apply_central_impulse(pushDirection)
|
||||
|
||||
Reference in new issue
Block a user