coins, parralaxbg, terrain,physics layer

This commit is contained in:
JayisonDevadas committed 2025-08-25 21:09:22 -04:00
1 parent 25527f75d8
commit 189869d71f
31 files changed
+934 -27

No files matched your search

+6
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
@@ -16,3 +21,4 @@ func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("shootables"):
bulletDamageSignal.emit(body,self)
+8
View File
@@ -0,0 +1,8 @@
class_name Coin extends Area2D
signal coinCollectedSignal(body, coin)
func _on_body_entered(body: Node2D) -> void:
print("coin collision")
coinCollectedSignal.emit(body, self)
+3
View File
@@ -25,3 +25,6 @@ func bulletDamage(body, bullet):
print("gc knows about bullet hit")
body.queue_free()
#apply_central_impulse(Vector2(shoveDirection,0)*700)
func coinCollected(body,coin):
print("gc knows coin collected")
+1 -1
View File
@@ -10,7 +10,7 @@ class_name Player extends CharacterBody2D
const SPEED = 300
const JUMP_VELOCITY = -400.0
@export var acceleration:int = 5
@export var acceleration:int = 15
var upJump:bool = false
var direction
+9
View File
@@ -4,6 +4,8 @@ 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:
@@ -13,6 +15,13 @@ func _ready() -> void:
obj.areaTriggerSignal.connect(game._on_trigger)
if coins:
print("found coins")
for obj in coins.get_children():
if obj is Coin:
print("coin collected")
obj.coinCollectedSignal.connect(game.coinCollected)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass