coins, parralax background, terrains, physics layer

This commit is contained in:
OddlyTimbot committed 2025-08-25 21:09:19 -04:00
1 parent ae6159a9f0
commit 53bae7b109
27 files changed
+817 -16

No files matched your search

+5
View File
@@ -1,4 +1,5 @@
class_name Bullet extends Area2D
@onready var bullet_graphic: Sprite2D = $BulletGraphic
var speed:float = 700
@@ -6,6 +7,10 @@ signal bulletDamageSignal(body, bullet)
func setSpeed(value:float):
speed = value
if value<0:
bullet_graphic.flip_h = true
if value>0:
bullet_graphic.flip_h = false
func _physics_process(delta: float) -> void:
position += transform.x * speed * delta
+3
View File
@@ -25,3 +25,6 @@ func bulletDamage(body, bullet):
print("GC know about bullet hit")
body.queue_free()
func coinCollected(body, coin):
print("GC knows coin collected")
+5
View File
@@ -4,6 +4,7 @@ var totalAllowedBullets = 7
var bullet = preload("res://scenes/bullet.tscn")
@onready var game: Node2D = $".."
@onready var triggers: Node2D = $"../triggers"
@onready var coins: Node2D = $"../coins"
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -11,6 +12,10 @@ func _ready() -> void:
for obj in triggers.get_children():
if obj is Trigger:
obj.areaTriggerSignal.connect(game._on_trigger)
if coins:
for obj in coins.get_children():
if obj is Coin:
obj.coinCollectedSignal.connect(game.coinCollected)
# Called every frame. 'delta' is the elapsed time since the previous frame.