From 39a2c3e097569895b27866610a97660b1dfbd71d Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Mon, 29 Sep 2025 21:11:00 -0400 Subject: [PATCH] big four objects, custom signal, gamecontroller --- .editorconfig | 4 ++ .gitattributes | 2 + .gitignore | 3 ++ icon.svg | 1 + icon.svg.import | 43 ++++++++++++++++++ project.godot | 22 ++++++++++ scenes/crate.tscn | 11 +++++ scenes/game.tscn | 83 +++++++++++++++++++++++++++++++++++ scenes/player.tscn | 12 +++++ scenes/trigger.tscn | 16 +++++++ scripts/gamecontroller.gd | 21 +++++++++ scripts/gamecontroller.gd.uid | 1 + scripts/player.gd | 33 ++++++++++++++ scripts/player.gd.uid | 1 + scripts/trigger.gd | 19 ++++++++ scripts/trigger.gd.uid | 1 + 16 files changed, 273 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 project.godot create mode 100644 scenes/crate.tscn create mode 100644 scenes/game.tscn create mode 100644 scenes/player.tscn create mode 100644 scenes/trigger.tscn create mode 100644 scripts/gamecontroller.gd create mode 100644 scripts/gamecontroller.gd.uid create mode 100644 scripts/player.gd create mode 100644 scripts/player.gd.uid create mode 100644 scripts/trigger.gd create mode 100644 scripts/trigger.gd.uid diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..c6bbb7d --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..4769e1f --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://2bw0cvxvqmor" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..89fdd08 --- /dev/null +++ b/project.godot @@ -0,0 +1,22 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="SeptemberGame" +run/main_scene="uid://cy1i6ucex6m0d" +config/features=PackedStringArray("4.5", "Forward Plus") +config/icon="res://icon.svg" + +[file_customization] + +folder_colors={ +"res://scenes/": "orange" +} diff --git a/scenes/crate.tscn b/scenes/crate.tscn new file mode 100644 index 0000000..fd4c780 --- /dev/null +++ b/scenes/crate.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=3 uid="uid://qv8blu8wkqvq"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_uwrxv"] + +[node name="Crate" type="RigidBody2D"] +rotation = -0.522403 +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_uwrxv") +debug_color = Color(0.84557056, 0.3727497, 0.1753774, 0.41960785) diff --git a/scenes/game.tscn b/scenes/game.tscn new file mode 100644 index 0000000..f7d2806 --- /dev/null +++ b/scenes/game.tscn @@ -0,0 +1,83 @@ +[gd_scene load_steps=8 format=3 uid="uid://cy1i6ucex6m0d"] + +[ext_resource type="Script" uid="uid://crhflh7kooolf" path="res://scripts/gamecontroller.gd" id="1_lbhrr"] +[ext_resource type="PackedScene" uid="uid://qv8blu8wkqvq" path="res://scenes/crate.tscn" id="1_uwrxv"] +[ext_resource type="PackedScene" uid="uid://dmrrbiwqptrho" path="res://scenes/trigger.tscn" id="2_yqjtg"] +[ext_resource type="PackedScene" uid="uid://b1yy0sybg66hh" path="res://scenes/player.tscn" id="3_lnu2h"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_8cj0n"] +size = Vector2(68, 35) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_uwrxv"] + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_8cj0n"] + +[node name="Game" type="Node2D"] +script = ExtResource("1_lbhrr") + +[node name="StaticBody2D" type="StaticBody2D" parent="."] +position = Vector2(394, 353) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] +position = Vector2(0, 7.5) +shape = SubResource("RectangleShape2D_8cj0n") + +[node name="StaticBody2D2" type="StaticBody2D" parent="."] +position = Vector2(312, 412) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D2"] +position = Vector2(0, 7.5) +shape = SubResource("RectangleShape2D_8cj0n") + +[node name="StaticBody2D3" type="StaticBody2D" parent="."] +position = Vector2(509, 287) +rotation = -0.79570585 +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D3"] +position = Vector2(0, 7.5) +shape = SubResource("RectangleShape2D_8cj0n") + +[node name="Crate" parent="." instance=ExtResource("1_uwrxv")] +position = Vector2(406.00003, 327) + +[node name="RigidBody2D2" type="RigidBody2D" parent="."] +position = Vector2(243, 371) +rotation = -1.099222 +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D2"] +shape = SubResource("RectangleShape2D_uwrxv") +debug_color = Color(0.84557056, 0.3727497, 0.1753774, 0.41960785) + +[node name="RigidBody2D3" type="RigidBody2D" parent="."] +position = Vector2(502, 230) +rotation = -1.099222 +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D3"] +shape = SubResource("RectangleShape2D_uwrxv") +debug_color = Color(0.84557056, 0.3727497, 0.1753774, 0.41960785) + +[node name="Boundary" type="StaticBody2D" parent="."] +position = Vector2(389, 542) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Boundary"] +shape = SubResource("WorldBoundaryShape2D_8cj0n") + +[node name="Trigger" parent="." instance=ExtResource("2_yqjtg")] +position = Vector2(434, 409) + +[node name="Trigger2" parent="." instance=ExtResource("2_yqjtg")] +position = Vector2(255.00002, 460.99997) +intent = "powerup" + +[node name="CharacterBody2D" parent="." instance=ExtResource("3_lnu2h")] +position = Vector2(379, 331) +BUMP_POWER = 50 + +[connection signal="triggerFiredSignal" from="Trigger" to="." method="_on_trigger_fired"] +[connection signal="triggerFiredSignal" from="Trigger2" to="." method="_on_trigger_fired"] diff --git a/scenes/player.tscn b/scenes/player.tscn new file mode 100644 index 0000000..c0e84ff --- /dev/null +++ b/scenes/player.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://b1yy0sybg66hh"] + +[ext_resource type="Script" uid="uid://kv8w1gwuy3il" path="res://scripts/player.gd" id="1_3vyb7"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_3vyb7"] + +[node name="CharacterBody2D" type="CharacterBody2D"] +script = ExtResource("1_3vyb7") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_3vyb7") +debug_color = Color(0.46677285, 0.59072345, 0.09206382, 0.41960785) diff --git a/scenes/trigger.tscn b/scenes/trigger.tscn new file mode 100644 index 0000000..64f8f73 --- /dev/null +++ b/scenes/trigger.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3 uid="uid://dmrrbiwqptrho"] + +[ext_resource type="Script" uid="uid://b3ft6s3vbdi4k" path="res://scripts/trigger.gd" id="1_du5ex"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_yqjtg"] + +[node name="Trigger" type="Area2D"] +scale = Vector2(2.7999997, 2.6400025) +script = ExtResource("1_du5ex") +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_yqjtg") +debug_color = Color(0.5985868, 0.3943164, 0.9513896, 0.41960785) + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/scripts/gamecontroller.gd b/scripts/gamecontroller.gd new file mode 100644 index 0000000..57550f1 --- /dev/null +++ b/scripts/gamecontroller.gd @@ -0,0 +1,21 @@ +extends Node2D + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_trigger_fired(intent, body): + print("GC knows trigger fired "+intent) + match intent: + "destroy": + print("destroy this thing") + body.queue_free() + "powerup": + print("power up this thing") diff --git a/scripts/gamecontroller.gd.uid b/scripts/gamecontroller.gd.uid new file mode 100644 index 0000000..5beca32 --- /dev/null +++ b/scripts/gamecontroller.gd.uid @@ -0,0 +1 @@ +uid://crhflh7kooolf diff --git a/scripts/player.gd b/scripts/player.gd new file mode 100644 index 0000000..02d751f --- /dev/null +++ b/scripts/player.gd @@ -0,0 +1,33 @@ +extends CharacterBody2D + + +const SPEED = 300.0 +const JUMP_VELOCITY = -400.0 + +@export var BUMP_POWER = 100 + + +func _physics_process(delta): + # Add the gravity. + if not is_on_floor(): + velocity += get_gravity() * delta + + # Handle jump. + if Input.is_action_just_pressed("ui_accept") 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() + #handle world reactions + 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() * BUMP_POWER) + diff --git a/scripts/player.gd.uid b/scripts/player.gd.uid new file mode 100644 index 0000000..61ff175 --- /dev/null +++ b/scripts/player.gd.uid @@ -0,0 +1 @@ +uid://kv8w1gwuy3il diff --git a/scripts/trigger.gd b/scripts/trigger.gd new file mode 100644 index 0000000..4fcb2d2 --- /dev/null +++ b/scripts/trigger.gd @@ -0,0 +1,19 @@ +extends Area2D + +@export var intent = "destroy" + +signal triggerFiredSignal(intent, body) + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + + +func _on_body_entered(body): + print("trigger fired") + triggerFiredSignal.emit(intent, body) diff --git a/scripts/trigger.gd.uid b/scripts/trigger.gd.uid new file mode 100644 index 0000000..5a4891b --- /dev/null +++ b/scripts/trigger.gd.uid @@ -0,0 +1 @@ +uid://b3ft6s3vbdi4k