Week 1 commit.

This commit is contained in:
AnthonyRusso committed 2026-06-22 21:03:05 -04:00
commit 8b43b3c4f9
18 files changed
+274

No files matched your search

+1
View File
@@ -0,0 +1 @@
class_name Crate extends RigidBody2D
+1
View File
@@ -0,0 +1 @@
uid://uqo7d6vtae3w
+37
View File
@@ -0,0 +1,37 @@
extends Node2D
var numberOfCrates = 2
var timeAvailable = 5
var timer = Timer.new()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
add_child(timer)
timer.wait_time = 1
timer.one_shot = false
timer.connect("timeout", countdown)
timer.start()
func countdown() -> void:
# reduce time left
timeAvailable -= 1
if timeAvailable <= 0 and numberOfCrates > 0:
print("LOSER!!!")
get_tree().reload_current_scene()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_trigger(body: Variant, trigger: Variant) -> void:
print("Game controller knows trigger fired")
body.queue_free()
numberOfCrates -=1
if numberOfCrates == 0:
print("WINNER!!!")
get_tree().reload_current_scene()
func crateTotal(numOfCrates):
numberOfCrates = numOfCrates
print("Game controller knows about crates - there are: " + str(numOfCrates))
+1
View File
@@ -0,0 +1 @@
uid://cv4ex134wdu7j
+29
View File
@@ -0,0 +1,29 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_up") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
for i in get_slide_collision_count():
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal() * 100)
+1
View File
@@ -0,0 +1 @@
uid://dy5o70pk5y8b2
+20
View File
@@ -0,0 +1,20 @@
extends Node2D
@onready var game: Node2D = $".."
@onready var crates: Node2D = $"../Crates"
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
buildLevel()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func buildLevel() -> void:
# tell game controller how many crates
var totalCrates = 0
if crates:
for obj in crates.get_children():
if obj is Crate:
totalCrates += 1
game.crateTotal(totalCrates)
+1
View File
@@ -0,0 +1 @@
uid://cclb4boli603j
+16
View File
@@ -0,0 +1,16 @@
extends Area2D
signal areaTriggerSignal(body, trigger)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
print("Trigger is ready")
# 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("Something has entered the trigger zone")
areaTriggerSignal.emit(body, self)
+1
View File
@@ -0,0 +1 @@
uid://dy0ahrwhakd4d