diff --git a/.gitignore b/.gitignore index 4709183..41336a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # Godot 4+ specific ignores .godot/ +export diff --git a/assets/rocket.png b/assets/rocket.png new file mode 100644 index 0000000..398bc5c Binary files /dev/null and b/assets/rocket.png differ diff --git a/assets/rocket.png.import b/assets/rocket.png.import new file mode 100644 index 0000000..9be1dab --- /dev/null +++ b/assets/rocket.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d0hl8bxqr6pit" +path="res://.godot/imported/rocket.png-ee7caa6d60b8c73f0b17d79a887f39b7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/rocket.png" +dest_files=["res://.godot/imported/rocket.png-ee7caa6d60b8c73f0b17d79a887f39b7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/wild_jam/66-All-Cards.png b/assets/wild_jam/66-All-Cards.png new file mode 100644 index 0000000..469aa8a Binary files /dev/null and b/assets/wild_jam/66-All-Cards.png differ diff --git a/assets/wild_jam/66-All-Cards.png.import b/assets/wild_jam/66-All-Cards.png.import new file mode 100644 index 0000000..0c16386 --- /dev/null +++ b/assets/wild_jam/66-All-Cards.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bov61wf487vok" +path="res://.godot/imported/66-All-Cards.png-3b6d757317c73e1d6ae59e3b465a3399.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/wild_jam/66-All-Cards.png" +dest_files=["res://.godot/imported/66-All-Cards.png-3b6d757317c73e1d6ae59e3b465a3399.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/wild_jam/66-Escape.png b/assets/wild_jam/66-Escape.png new file mode 100644 index 0000000..ff6e8cb Binary files /dev/null and b/assets/wild_jam/66-Escape.png differ diff --git a/assets/wild_jam/66-Escape.png.import b/assets/wild_jam/66-Escape.png.import new file mode 100644 index 0000000..e4a5dbf --- /dev/null +++ b/assets/wild_jam/66-Escape.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://xkyvydieglea" +path="res://.godot/imported/66-Escape.png-1e2f87117eee255a6bff76adf9986f2b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/wild_jam/66-Escape.png" +dest_files=["res://.godot/imported/66-Escape.png-1e2f87117eee255a6bff76adf9986f2b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/wild_jam/Et-tu-Brute.png b/assets/wild_jam/Et-tu-Brute.png new file mode 100644 index 0000000..bb12cc8 Binary files /dev/null and b/assets/wild_jam/Et-tu-Brute.png differ diff --git a/assets/wild_jam/Et-tu-Brute.png.import b/assets/wild_jam/Et-tu-Brute.png.import new file mode 100644 index 0000000..609f0e4 --- /dev/null +++ b/assets/wild_jam/Et-tu-Brute.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c2mrfb6olx5xg" +path="res://.godot/imported/Et-tu-Brute.png-12df95ef3de215143d4b5ab392bb40e3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/wild_jam/Et-tu-Brute.png" +dest_files=["res://.godot/imported/Et-tu-Brute.png-12df95ef3de215143d4b5ab392bb40e3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/wild_jam/inside-box.png b/assets/wild_jam/inside-box.png new file mode 100644 index 0000000..d5aace7 Binary files /dev/null and b/assets/wild_jam/inside-box.png differ diff --git a/assets/wild_jam/inside-box.png.import b/assets/wild_jam/inside-box.png.import new file mode 100644 index 0000000..3e8cfe5 --- /dev/null +++ b/assets/wild_jam/inside-box.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bkugnjwg6m3ef" +path="res://.godot/imported/inside-box.png-c9f4e79ee0fdb1bf73515f816556c251.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/wild_jam/inside-box.png" +dest_files=["res://.godot/imported/inside-box.png-c9f4e79ee0fdb1bf73515f816556c251.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/wild_jam/then-the-morning-comes.png b/assets/wild_jam/then-the-morning-comes.png new file mode 100644 index 0000000..a12487e Binary files /dev/null and b/assets/wild_jam/then-the-morning-comes.png differ diff --git a/assets/wild_jam/then-the-morning-comes.png.import b/assets/wild_jam/then-the-morning-comes.png.import new file mode 100644 index 0000000..9c8b875 --- /dev/null +++ b/assets/wild_jam/then-the-morning-comes.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://be8ir6au5xed5" +path="res://.godot/imported/then-the-morning-comes.png-2d3f4245fb4f2475f0a4c4d21fad9262.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/wild_jam/then-the-morning-comes.png" +dest_files=["res://.godot/imported/then-the-morning-comes.png-2d3f4245fb4f2475f0a4c4d21fad9262.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..bffce1a --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,37 @@ +[preset.0] + +name="Web" +platform="Web" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="export/index.html" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +variant/extensions_support=false +vram_texture_compression/for_desktop=true +vram_texture_compression/for_mobile=false +html/export_icon=true +html/custom_html_shell="" +html/head_include="" +html/canvas_resize_policy=2 +html/focus_canvas_on_start=true +html/experimental_virtual_keyboard=false +progressive_web_app/enabled=false +progressive_web_app/offline_page="" +progressive_web_app/display=1 +progressive_web_app/orientation=0 +progressive_web_app/icon_144x144="" +progressive_web_app/icon_180x180="" +progressive_web_app/icon_512x512="" +progressive_web_app/background_color=Color(0, 0, 0, 1) diff --git a/project.godot b/project.godot index f626278..477a955 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="rgb" -run/main_scene="res://scene/maze_1.tscn" +run/main_scene="res://scene/main_menu.tscn" config/features=PackedStringArray("4.2", "GL Compatibility") config/icon="res://icon.svg" @@ -19,6 +19,14 @@ config/icon="res://icon.svg" aseprite_executable_path="C:/Program Files/aseprite/build/bin/aseprite.exe" +[autoload] + +HasWon="*res://scripts/has_won.gd" + +[display] + +window/stretch/mode="canvas_items" + [editor_plugins] enabled=PackedStringArray("res://addons/nklbdev.aseprite_importers/plugin.cfg") diff --git a/scene/hud.tscn b/scene/hud.tscn index 29fbbb7..fff995f 100644 --- a/scene/hud.tscn +++ b/scene/hud.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://dcpeowc6xcfcv"] +[gd_scene load_steps=9 format=3 uid="uid://dcpeowc6xcfcv"] [ext_resource type="Texture2D" uid="uid://d32ory5gus4lm" path="res://assets/dot.png" id="1_tsiui"] [ext_resource type="Script" path="res://scripts/hud.gd" id="1_yk6cu"] @@ -7,6 +7,13 @@ [ext_resource type="Theme" uid="uid://ewgo3qi2xs54" path="res://data/themes/green_progress_bar_theme.tres" id="3_wvu2t"] [ext_resource type="Theme" uid="uid://dm1sx57hw07cn" path="res://data/themes/blue_progress_bar_theme.tres" id="4_n8d17"] +[sub_resource type="Gradient" id="Gradient_qj638"] +colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_w5aj4"] +gradient = SubResource("Gradient_qj638") +width = 64 + [node name="HUD" type="CanvasLayer"] script = ExtResource("1_yk6cu") @@ -14,10 +21,10 @@ script = ExtResource("1_yk6cu") anchors_preset = 2 anchor_top = 1.0 anchor_bottom = 1.0 -offset_left = 16.0 -offset_top = -184.0 -offset_right = 64.0 -offset_bottom = -24.0 +offset_left = 8.0 +offset_top = -258.0 +offset_right = 80.0 +offset_bottom = -8.0 grow_vertical = 0 [node name="MarginContainer" type="MarginContainer" parent="PanelContainer"] @@ -30,6 +37,26 @@ theme_override_constants/margin_bottom = 2 [node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"] layout_mode = 2 +[node name="AllianceContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="AllianceText" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer/AllianceContainer"] +layout_mode = 2 +text = "Alliance" +horizontal_alignment = 1 + +[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/MarginContainer/VBoxContainer/AllianceContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 2 +theme_override_constants/margin_top = 2 +theme_override_constants/margin_right = 2 +theme_override_constants/margin_bottom = 2 + +[node name="AllianceTexture" type="TextureRect" parent="PanelContainer/MarginContainer/VBoxContainer/AllianceContainer/MarginContainer"] +custom_minimum_size = Vector2(0, 8) +layout_mode = 2 +texture = SubResource("GradientTexture1D_w5aj4") + [node name="LivesContainer" type="GridContainer" parent="PanelContainer/MarginContainer/VBoxContainer"] layout_mode = 2 columns = 3 @@ -106,3 +133,28 @@ theme_override_constants/margin_right = 8 [node name="EntityCountLabel" type="Label" parent="EntityCountContainer/MarginContainer"] layout_mode = 2 text = "Entity Count: 0" + +[node name="RocketSpawnedToast" type="PanelContainer" parent="."] +visible = false +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="RocketSpawnedToast"] +layout_mode = 2 +text = "Rocket has been placed! +Find it to escape!" +horizontal_alignment = 1 + +[node name="Timer" type="Timer" parent="RocketSpawnedToast"] +wait_time = 2.0 + +[connection signal="timeout" from="RocketSpawnedToast/Timer" to="." method="_on_timer_timeout"] diff --git a/scene/main_menu.tscn b/scene/main_menu.tscn new file mode 100644 index 0000000..b4fb147 --- /dev/null +++ b/scene/main_menu.tscn @@ -0,0 +1,106 @@ +[gd_scene load_steps=4 format=3 uid="uid://bx16w4v1gvjjm"] + +[ext_resource type="Script" path="res://scripts/main_menu.gd" id="1_wb16r"] +[ext_resource type="Texture2D" uid="uid://c2mrfb6olx5xg" path="res://assets/wild_jam/Et-tu-Brute.png" id="2_i550s"] +[ext_resource type="Texture2D" uid="uid://bkugnjwg6m3ef" path="res://assets/wild_jam/inside-box.png" id="3_jsic8"] + +[node name="MainMenu" 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_wb16r") + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer2" type="MarginContainer" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/margin_top = 150 +theme_override_constants/margin_bottom = 150 + +[node name="Betrayal" type="TextureRect" parent="HBoxContainer/MarginContainer2"] +layout_mode = 2 +texture = ExtResource("2_i550s") +expand_mode = 3 +stretch_mode = 5 + +[node name="MarginContainer" type="MarginContainer" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/margin_left = 64 +theme_override_constants/margin_right = 64 + +[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/MarginContainer"] +layout_mode = 2 + +[node name="Spacer" type="Control" parent="HBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.5 + +[node name="Label" type="Label" parent="HBoxContainer/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(250, 0) +layout_mode = 2 +size_flags_vertical = 6 +theme_override_font_sizes/font_size = 64 +text = "RGBetrayal" +horizontal_alignment = 1 + +[node name="Spacer2" type="Control" parent="HBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.5 + +[node name="WinLossLabel" type="Label" parent="HBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +horizontal_alignment = 1 + +[node name="Spacer5" type="Control" parent="HBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.5 + +[node name="PlayButton" type="Button" parent="HBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Play" + +[node name="Spacer3" type="Control" parent="HBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.5 + +[node name="QuitButton" type="Button" parent="HBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Quit" + +[node name="Spacer4" type="Control" parent="HBoxContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.5 + +[node name="MarginContainer3" type="MarginContainer" parent="HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/margin_top = 150 +theme_override_constants/margin_bottom = 150 + +[node name="ThinkInsideTheBox" type="TextureRect" parent="HBoxContainer/MarginContainer3"] +layout_mode = 2 +size_flags_horizontal = 3 +texture = ExtResource("3_jsic8") +expand_mode = 3 +stretch_mode = 5 + +[connection signal="pressed" from="HBoxContainer/MarginContainer/VBoxContainer/PlayButton" to="." method="_on_play_button_pressed"] +[connection signal="pressed" from="HBoxContainer/MarginContainer/VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"] diff --git a/scene/maze_1.tscn b/scene/maze_1.tscn index b50e80d..da7772b 100644 --- a/scene/maze_1.tscn +++ b/scene/maze_1.tscn @@ -262,3 +262,10 @@ buff = ExtResource("6_ll7oj") [node name="HUD" parent="." instance=ExtResource("4_7uel4")] [node name="EntityContainer" type="Node" parent="."] + +[node name="RocketTimer" type="Timer" parent="."] +wait_time = 45.0 +one_shot = true +autostart = true + +[connection signal="timeout" from="RocketTimer" to="." method="_on_rocket_timer_timeout"] diff --git a/scene/rocket.tscn b/scene/rocket.tscn new file mode 100644 index 0000000..e26960f --- /dev/null +++ b/scene/rocket.tscn @@ -0,0 +1,42 @@ +[gd_scene load_steps=4 format=3 uid="uid://dktsl7nrpdhkd"] + +[ext_resource type="Texture2D" uid="uid://d0hl8bxqr6pit" path="res://assets/rocket.png" id="1_rmsjo"] +[ext_resource type="Script" path="res://scripts/rocket.gd" id="1_y7fw2"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_l5sta"] +radius = 32.0 + +[node name="Rocket" type="Node2D"] +script = ExtResource("1_y7fw2") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_rmsjo") + +[node name="CollectionZone" type="Area2D" parent="."] +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CollectionZone"] +shape = SubResource("CircleShape2D_l5sta") + +[node name="LeaveTimer" type="Timer" parent="."] + +[node name="CountdownLabel" type="Label" parent="."] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -11.5 +offset_right = 20.0 +offset_bottom = 11.5 +grow_horizontal = 2 +grow_vertical = 2 +text = "5" +horizontal_alignment = 1 +vertical_alignment = 1 + +[connection signal="body_entered" from="CollectionZone" to="." method="_on_collection_zone_body_entered"] +[connection signal="body_exited" from="CollectionZone" to="." method="_on_collection_zone_body_exited"] +[connection signal="timeout" from="LeaveTimer" to="." method="_on_leave_timer_timeout"] diff --git a/scripts/attack.gd b/scripts/attack.gd index d8cf070..e2e012c 100644 --- a/scripts/attack.gd +++ b/scripts/attack.gd @@ -3,6 +3,7 @@ class_name Attack @onready var cpu_particles_2d: CPUParticles2D = $CPUParticles2D @onready var area_2d: Area2D = $Area2D +@onready var collision_shape_2d: CollisionShape2D = $Area2D/CollisionShape2D var initiator: Entity @@ -13,11 +14,15 @@ func set_initiator(entity: Entity) -> void: func _ready() -> void: cpu_particles_2d.emitting = true cpu_particles_2d.color = initiator.color + collision_shape_2d.shape.radius = initiator.attack_pow + cpu_particles_2d.initial_velocity_min = float(initiator.attack_pow) * 4.0 + cpu_particles_2d.initial_velocity_max = float(initiator.attack_pow) * 4.0 func _on_cpu_particles_2d_finished() -> void: var collisions := area_2d.get_overlapping_bodies() for object in collisions: if object is Entity and object != initiator: - object.hit() - print("attack hit %s" % collisions.size()) + var color_diff = object.color - initiator.color + if abs(color_diff.r) + abs(color_diff.g) + abs(color_diff.b) > 0.5: + object.hit() queue_free() diff --git a/scripts/enemy.gd b/scripts/enemy.gd index 23826d8..8b45fdf 100644 --- a/scripts/enemy.gd +++ b/scripts/enemy.gd @@ -5,8 +5,13 @@ class_name Enemy @onready var nav_agent: NavigationAgent2D = $NavigationAgent2D var vision: int = 100 +var at_rocket := false func _physics_process(delta: float) -> void: + if not at_rocket: + random_movement() + +func random_movement(): if nav_agent.is_navigation_finished(): call_deferred("new_target_point") return @@ -26,7 +31,7 @@ func _physics_process(delta: float) -> void: lives += 1 color.r -= 0.25 buff.colors.GREEN: - #$Camera2D.zoom -= Vector2(0.4, 0.4) + vision += 25 color.g -= 0.25 buff.colors.BLUE: speed += 12 @@ -48,3 +53,6 @@ func new_target_point(): #point_delta = point_delta.normalized() #closest_point += point_delta * 32 nav_agent.target_position = closest_point + +func reach_rocket(): + at_rocket = true diff --git a/scripts/entity.gd b/scripts/entity.gd index 0b9429a..f11dbb5 100644 --- a/scripts/entity.gd +++ b/scripts/entity.gd @@ -1,14 +1,21 @@ extends CharacterBody2D class_name Entity -signal death +signal death(entity: Entity) +var alliance: Buff.colors +var attack_pow: int = 0 var color := Color.WHITE -@export var speed = 100 +@export var speed = 80 var lives: int = 1 +func received_buff(color: Buff.colors) -> void: + if alliance == color: + attack_pow += 6 + else: + attack_pow -= 3 + func hit() -> void: lives -= 1 if lives <= 0: - death.emit() - queue_free() + death.emit(self) diff --git a/scripts/has_won.gd b/scripts/has_won.gd new file mode 100644 index 0000000..9447ace --- /dev/null +++ b/scripts/has_won.gd @@ -0,0 +1,5 @@ +extends Node + +var won := false +var inital_load := true +var escaped = {} diff --git a/scripts/hud.gd b/scripts/hud.gd index 3d1d0c3..3d36b4b 100644 --- a/scripts/hud.gd +++ b/scripts/hud.gd @@ -7,6 +7,8 @@ class_name HUD @onready var texture_rect: TextureRect = $PanelContainer/MarginContainer/VBoxContainer/TextureRect @onready var lives_container: GridContainer = $PanelContainer/MarginContainer/VBoxContainer/LivesContainer @onready var entity_count_label: Label = $EntityCountContainer/MarginContainer/EntityCountLabel +@onready var rocket_spawned_toast: PanelContainer = $RocketSpawnedToast +@onready var alliance_texture: TextureRect = $PanelContainer/MarginContainer/VBoxContainer/AllianceContainer/MarginContainer/AllianceTexture const HEART = preload("res://assets/heart.png") func _on_player_color_changed(color: Color) -> void: @@ -27,3 +29,19 @@ func _on_player_lives_changed(lives: int) -> void: func update_entity_count(count: int): entity_count_label.text = "Entity Count: %s" % count + +func rocket_placed() -> void: + rocket_spawned_toast.show() + rocket_spawned_toast.get_node("Timer").start() + +func _on_timer_timeout() -> void: + rocket_spawned_toast.hide() + +func set_alliance(alliance: Buff.colors) -> void: + match alliance: + Buff.colors.RED: + alliance_texture.modulate = Color.RED + Buff.colors.GREEN: + alliance_texture.modulate = Color.GREEN + Buff.colors.BLUE: + alliance_texture.modulate = Color.BLUE diff --git a/scripts/main_menu.gd b/scripts/main_menu.gd new file mode 100644 index 0000000..e9283e7 --- /dev/null +++ b/scripts/main_menu.gd @@ -0,0 +1,19 @@ +extends Control +class_name MainMenu + +var mazes = ["res://scene/maze_1.tscn"] + +@onready var win_loss_label: Label = $HBoxContainer/MarginContainer/VBoxContainer/WinLossLabel + +func _on_quit_button_pressed() -> void: + get_tree().quit() + + +func _on_play_button_pressed() -> void: + get_tree().change_scene_to_file(mazes.pick_random()) + +func _ready() -> void: + if not HasWon.inital_load: + var won_text = ["YOU WON!!!" if HasWon.won else "You Lost..."] + won_text.append_array(HasWon.escaped.values()) + win_loss_label.text = "%s Escaped counts: %s Red, %s Green, %s Blue" % won_text diff --git a/scripts/maze.gd b/scripts/maze.gd index 60003bb..f5d9471 100644 --- a/scripts/maze.gd +++ b/scripts/maze.gd @@ -3,6 +3,8 @@ class_name Maze const PLAYER = preload("res://scene/player.tscn") const ENEMY = preload("res://scene/enemy.tscn") +const ROCKET = preload("res://scene/rocket.tscn") +const MAIN_MENU = "res://scene/main_menu.tscn" var spawn_locations: Array[Vector2] = [] @@ -11,6 +13,7 @@ var spawn_locations: Array[Vector2] = [] @onready var entity_container: Node = $EntityContainer func _ready() -> void: + HasWon.inital_load = false var spawn_zone_array := spawn_zones.get_children() for spawn_zone in spawn_zone_array: var zone := spawn_zone.get_child(0) as CollisionShape2D @@ -20,18 +23,40 @@ func _ready() -> void: spawn_locations.append(top_left + Vector2(x * 16, y * 16)) hud.update_entity_count(spawn_locations.size()) var player_loc: Vector2 = spawn_locations.pick_random() + var alliegences: Array[Buff.colors] = [] for spawn in spawn_locations: - var entity + var entity: Entity if spawn == player_loc: entity = PLAYER.instantiate() + entity.alliance = get_random_alliance(alliegences) + hud.set_alliance(entity.alliance) entity.color_changed.connect(hud._on_player_color_changed) entity.lives_changed.connect(hud._on_player_lives_changed) else: entity = ENEMY.instantiate() + entity.alliance = get_random_alliance(alliegences) entity.position = spawn entity.death.connect(_on_entity_death) entity_container.add_child(entity) -func _on_entity_death(): - var entities = entity_container.get_child_count() +func get_random_alliance(alliegences: Array[Buff.colors]) -> Buff.colors: + if alliegences.size() == 0: + alliegences.append_array([Buff.colors.RED, Buff.colors.GREEN, Buff.colors.BLUE]) + return alliegences.pop_at(randi_range(0, alliegences.size() - 1)) + +func _on_entity_death(entity: Entity): + var entities = entity_container.get_child_count() - 1 hud.update_entity_count(entities) + entity.queue_free() + + +func _on_rocket_timer_timeout() -> void: + var rocket_location: Node2D = spawn_zones.get_children().pick_random().get_child(0) + var rocket = ROCKET.instantiate() + rocket.global_position = rocket_location.global_position + rocket.game_over.connect(_on_game_over) + add_child(rocket) + hud.rocket_placed() + +func _on_game_over() -> void: + get_tree().change_scene_to_file(MAIN_MENU) diff --git a/scripts/player.gd b/scripts/player.gd index 75c3dc2..212e579 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -18,6 +18,7 @@ func _physics_process(delta: float) -> void: if collision.get_collider() is Chest: var buff: Buff = collision.get_collider().open(self) if buff: + super.received_buff(buff.color) match(buff.color): buff.colors.RED: lives += 1 @@ -33,6 +34,7 @@ func _physics_process(delta: float) -> void: color_changed.emit(color) if Input.is_action_just_pressed("ui_accept"): - var attack: Attack = ATTACK.instantiate() - attack.set_initiator(self) - get_parent().add_sibling(attack) + if attack_pow > 0: + var attack: Attack = ATTACK.instantiate() + attack.set_initiator(self) + get_parent().add_sibling(attack) diff --git a/scripts/rocket.gd b/scripts/rocket.gd new file mode 100644 index 0000000..eaead41 --- /dev/null +++ b/scripts/rocket.gd @@ -0,0 +1,41 @@ +extends Node2D + +signal game_over + +@onready var leave_timer: Timer = $LeaveTimer +@onready var collection_zone: Area2D = $CollectionZone +@onready var countdown_label: Label = $CountdownLabel + +var countdown = 5 +var count = -1 + +func _on_collection_zone_body_entered(body: Node2D) -> void: + leave_timer.start() + count = countdown + countdown_label.text = str(count) + countdown_label.show() + if body is Enemy: + body.reach_rocket() + + +func _on_collection_zone_body_exited(body: Node2D) -> void: + if collection_zone.get_overlapping_bodies().size() == 0: + leave_timer.stop() + countdown_label.hide() + + +func _on_leave_timer_timeout() -> void: + count -= 1 + countdown_label.text = str(count) + + if count == 0: + for clr in Buff.colors: + HasWon.escaped[clr] = 0 + var escaped: Array[Node2D] = collection_zone.get_overlapping_bodies() + HasWon.won = false + for entity: Entity in escaped: + HasWon.escaped[Buff.colors.keys()[entity.alliance]] += 1 + if entity is Player: + HasWon.won = true + game_over.emit() +