Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparing Beta Branch #4034

Merged
merged 12 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 81 additions & 8 deletions apps/gamejam/brackeys/13/scenes/game.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://cbrda40vq26pj"]
[gd_scene load_steps=14 format=3 uid="uid://cbrda40vq26pj"]

[ext_resource type="Script" path="res://scripts/game.gd" id="1_oyaqx"]
[ext_resource type="PackedScene" uid="uid://1s5v0llrjq3" path="res://scenes/spaceship.tscn" id="1_rlyye"]
Expand All @@ -10,10 +10,90 @@
[ext_resource type="Script" path="res://scripts/environment_layer.gd" id="8_rakg7"]
[ext_resource type="Script" path="res://scripts/toast_manager.gd" id="9_tiuga"]
[ext_resource type="Script" path="res://scripts/entity.gd" id="10_1liq3"]
[ext_resource type="Script" path="res://scripts/hud.gd" id="11_e1u8f"]
[ext_resource type="Theme" uid="uid://bkt3waoihtb6j" path="res://theme/Theme.tres" id="11_je1f8"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4vpul"]
bg_color = Color(0.6, 0.6, 0.6, 0.5)
expand_margin_left = 20.0
expand_margin_right = 20.0

[node name="Game" type="Node2D"]
script = ExtResource("1_oyaqx")

[node name="CanvasLayer" type="CanvasLayer" parent="."]

[node name="UI" type="Control" parent="CanvasLayer"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="HUD" type="Control" parent="CanvasLayer/UI"]
custom_minimum_size = Vector2(0, 80)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
theme = ExtResource("11_je1f8")
script = ExtResource("11_e1u8f")

[node name="Panel" type="PanelContainer" parent="CanvasLayer/UI/HUD"]
custom_minimum_size = Vector2(0, 80)
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 23.0
grow_horizontal = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_4vpul")

[node name="Menu" type="HBoxContainer" parent="CanvasLayer/UI/HUD/Panel"]
layout_mode = 2
alignment = 1

[node name="Stone" type="Label" parent="CanvasLayer/UI/HUD/Panel/Menu"]
layout_mode = 2

[node name="Metal" type="Label" parent="CanvasLayer/UI/HUD/Panel/Menu"]
layout_mode = 2

[node name="Gems" type="Label" parent="CanvasLayer/UI/HUD/Panel/Menu"]
layout_mode = 2

[node name="Gold" type="Label" parent="CanvasLayer/UI/HUD/Panel/Menu"]
layout_mode = 2

[node name="StarshipName" type="Label" parent="CanvasLayer/UI/HUD/Panel/Menu"]
layout_mode = 2

[node name="Label" type="Label" parent="CanvasLayer/UI/HUD/Panel/Menu"]
layout_mode = 2

[node name="Bottom" type="Control" parent="CanvasLayer"]
layout_mode = 3
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 0

[node name="ToastManager" type="Control" parent="CanvasLayer/Bottom"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -80.0
offset_right = 40.0
offset_bottom = -40.0
grow_vertical = 0
script = ExtResource("9_tiuga")

[node name="Spaceship" parent="." instance=ExtResource("1_rlyye")]
position = Vector2(500, 300)

Expand All @@ -39,12 +119,5 @@ script = ExtResource("7_hvh2v")
[node name="EnvironmentLayer" type="Node2D" parent="Background"]
script = ExtResource("8_rakg7")

[node name="ToastManager" type="Control" parent="."]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("9_tiuga")

[node name="Entity" type="Node2D" parent="."]
script = ExtResource("10_1liq3")
12 changes: 12 additions & 0 deletions apps/gamejam/brackeys/13/scenes/ui/shop.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://cl2srbe0xb2gw"]

[ext_resource type="Script" path="res://scripts/shop.gd" id="1_xq0us"]

[node name="Shop" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_xq0us")
7 changes: 6 additions & 1 deletion apps/gamejam/brackeys/13/scenes/ui/toast.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

[node name="Toast" type="Control"]
layout_mode = 3
anchors_preset = 0
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 0
script = ExtResource("1_jpci1")

[node name="Panel" type="Panel" parent="."]
Expand Down
2 changes: 1 addition & 1 deletion apps/gamejam/brackeys/13/scripts/entity.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends Node2D

const ASTEROID_SCENE = preload("res://scenes/Asteroid.tscn")
const ASTEROID_SCENE = preload("res://scenes/asteroid.tscn")

var asteroid_pool: Array = []
var active_asteroids: Array = []
Expand Down
6 changes: 3 additions & 3 deletions apps/gamejam/brackeys/13/scripts/game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ extends Node2D
@onready var spaceship = $Spaceship
@onready var projectiles = $Projectiles
@onready var background = $Background
@onready var tm = $ToastManager
#@onready var tm = $ToastManager

const LASER_POOL_SIZE = 25
const LASER_POOL_SIZE = 10

func _ready():
spaceship.connect("laser_shot", _on_spaceship_laser_shot)
projectiles.initialize_pool(LASER_POOL_SIZE)
tm.show_toast("game_start", "Game Started! Ready for launch.", "info")
Global.emit_signal("notification_received", "game_start", "Game Started! Ready for launch.", "info")

func _on_spaceship_laser_shot(scope_position: Vector2, rotation: float):
projectiles.shoot_laser(scope_position, rotation)
9 changes: 8 additions & 1 deletion apps/gamejam/brackeys/13/scripts/global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ signal starship_data_changed(data_name, new_value)
signal environment_data_changed(data_name, new_value)
signal notification_received(message_id: String, message: String, type: String)

@export var resources_list: Array[String] = ["gold", "stone", "metal", "gems"]

var environment_data := {
"asteroids": 10,
"asteroid_speed": 200,
Expand All @@ -27,7 +29,7 @@ var base_starship_stats := {
"rotation_speed": 270.0,
"laser_speed": 550.0,
"overheat": 0.0,
"laser_ammo": 25.0,
"laser_ammo": 10.0,
}

var starship_bonuses := {
Expand All @@ -45,6 +47,11 @@ var starship_data := {
"shield_active": false
}

func earn_random_resource(resource_name: String, min_value: int = 3, max_value: int = 15):
var amount = randi_range(min_value, max_value)
earn_resource(resource_name, amount)


func earn_resource(resource_name: String, amount: int, invoice: String = "Earned"):
if amount <= 0:
return
Expand Down
49 changes: 49 additions & 0 deletions apps/gamejam/brackeys/13/scripts/hud.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
extends Control

@onready var score_label = $Panel/Menu/Label
@onready var name_label = $Panel/Menu/StarshipName
@onready var stone_label = $Panel/Menu/Stone
@onready var metal_label = $Panel/Menu/Metal
@onready var gems_label = $Panel/Menu/Gems
@onready var gold_label = $Panel/Menu/Gold

var resource_labels = {}

func _ready():
resource_labels = {
"gold": gold_label,
"stone": stone_label,
"metal": metal_label,
"gems": gems_label
}

call_deferred("_update_starship_name")
call_deferred("_update_starship_resources")
Global.connect("resource_changed", Callable(self, "_on_resource_changed"))
update_score(0)

func update_score(new_score):
if score_label:
score_label.text = "Score: %d" % new_score
else:
push_warning("Score label not found!")

func _update_starship_resources():
for resource in Global.resources_list:
var amount = Global.get_resource(resource)
if resource_labels.has(resource) and resource_labels[resource]:
resource_labels[resource].text = "%s: %d" % [resource.capitalize(), amount]

func _on_resource_changed(resource_name: String, new_value: int):
if resource_labels.has(resource_name) and resource_labels[resource_name]:
resource_labels[resource_name].text = "%s: %d" % [resource_name.capitalize(), new_value]

func _update_starship_name():
var starship_name = Global.get_starship_data("name")
if name_label:
if starship_name:
name_label.text = "Starship: " + starship_name
else:
name_label.text = "Starship: Unknown"
else:
push_warning("Starship name label not found!")
2 changes: 2 additions & 0 deletions apps/gamejam/brackeys/13/scripts/laser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func _on_area_entered(area):
if area is Asteroid:
var asteroid = area
asteroid.destroy()
Global.emit_signal("notification_received", "asteroid_hit", "Asteroid was destoried!", "success")
Global.earn_random_resource("stone")
visible = false
if get_parent():
get_parent()._on_laser_exited(self)
6 changes: 3 additions & 3 deletions apps/gamejam/brackeys/13/scripts/projectiles.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends Node

const LASER_SCENE = preload("res://scenes/laser.tscn")
@onready var tm = get_parent().get_node("ToastManager")
# @onready var tm = get_parent().get_node("ToastManager")
# Shift these to the Q crate later on.
var laser_pool: Array = []
var active_lasers: Array = []
Expand Down Expand Up @@ -42,7 +42,7 @@ func dynamic_pool_adjustment():
laser.set_deferred("visible", false)
laser_pool.append(laser)
add_child(laser)
emit_signal("notification_received","laser_upgrade", "Laser Upgraded", "info")
Global.emit_signal("notification_received","laser_upgrade", "Laser Upgraded", "info")
print("Laser pool increased to:", desired_pool_size)

elif desired_pool_size < current_pool_size:
Expand All @@ -51,5 +51,5 @@ func dynamic_pool_adjustment():
if laser_pool.size() > 0:
var laser = laser_pool.pop_back()
laser.queue_free()
emit_signal("notification_received","laser_downgrade", "Laser Downgraded", "warning")
Global.emit_signal("notification_received","laser_downgrade", "Laser Downgraded", "warning")
print("Laser pool decreased to:", desired_pool_size)
11 changes: 11 additions & 0 deletions apps/gamejam/brackeys/13/scripts/shop.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Control


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
Loading