commit 60729215f26f4efbbda9ebf63ab0f20c7d5f3d41 Author: OddlyTimbot Date: Mon Apr 20 21:12:58 2026 -0400 static body, rigidbody, characterbody, area, signals 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/Scenes/game.tscn b/Scenes/game.tscn new file mode 100644 index 0000000..d4f31a0 --- /dev/null +++ b/Scenes/game.tscn @@ -0,0 +1,74 @@ +[gd_scene format=3 uid="uid://b06dlp8n6upld"] + +[ext_resource type="Script" uid="uid://btmoyp0rwqmxe" path="res://Scripts/player.gd" id="1_ebmjs"] +[ext_resource type="Script" uid="uid://bc25u4w35ibeu" path="res://Scripts/gameController.gd" id="1_qxrlw"] +[ext_resource type="Script" uid="uid://4hekg0d8n04f" path="res://Scripts/trigger.gd" id="3_wrm1d"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_2poj3"] +size = Vector2(84, 20) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ebmjs"] + +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_2poj3"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_2poj3"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_3dryh"] +radius = 32.01562 + +[node name="Game" type="Node2D" unique_id=1698001017] +script = ExtResource("1_qxrlw") + +[node name="platform" type="StaticBody2D" parent="." unique_id=601020872] +position = Vector2(436, 297) +constant_linear_velocity = Vector2(10, 0) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="platform" unique_id=1836025932] +shape = SubResource("RectangleShape2D_2poj3") + +[node name="RigidBody2D" type="RigidBody2D" parent="." unique_id=2015643131] +position = Vector2(415.00003, 189) +rotation = 0.46453398 +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D" unique_id=1377201570] +shape = SubResource("RectangleShape2D_ebmjs") +debug_color = Color(0.8535397, 0.36730364, 0.11225829, 0.41960785) + +[node name="RigidBody2D2" type="RigidBody2D" parent="." unique_id=800232702] +position = Vector2(443, 191.00003) +rotation = 0.9293104 +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D2" unique_id=2111607142] +shape = SubResource("RectangleShape2D_ebmjs") +debug_color = Color(0.8535397, 0.36730364, 0.11225829, 0.41960785) + +[node name="StaticBody2D" type="StaticBody2D" parent="." unique_id=1600506296] +position = Vector2(448, 452) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D" unique_id=1926005878] +shape = SubResource("WorldBoundaryShape2D_2poj3") + +[node name="CharacterBody2D" type="CharacterBody2D" parent="." unique_id=380327915] +position = Vector2(437, 250) +script = ExtResource("1_ebmjs") +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D" unique_id=1235513256] +shape = SubResource("CircleShape2D_2poj3") +debug_color = Color(0.36777267, 0.6132997, 0.17400515, 0.41960785) + +[node name="Area2D" type="Area2D" parent="." unique_id=1184709580] +position = Vector2(495, 356) +script = ExtResource("3_wrm1d") +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=1623965811] +shape = SubResource("CircleShape2D_3dryh") +debug_color = Color(0.7716697, 0.28327075, 0.8513461, 0.41960785) + +[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"] +[connection signal="triggerActiveSignal" from="Area2D" to="." method="_on_triggerSignal"] diff --git a/Scripts/gameController.gd b/Scripts/gameController.gd new file mode 100644 index 0000000..c161670 --- /dev/null +++ b/Scripts/gameController.gd @@ -0,0 +1,17 @@ +extends Node2D + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + get_window().grab_focus() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_triggerSignal(body: Variant, intentMessage: Variant) -> void: + print("GC knows about a trigger!") + if not body is Player and intentMessage == "destroy": + body.queue_free() diff --git a/Scripts/gameController.gd.uid b/Scripts/gameController.gd.uid new file mode 100644 index 0000000..7c694a0 --- /dev/null +++ b/Scripts/gameController.gd.uid @@ -0,0 +1 @@ +uid://bc25u4w35ibeu diff --git a/Scripts/player.gd b/Scripts/player.gd new file mode 100644 index 0000000..c2a4f56 --- /dev/null +++ b/Scripts/player.gd @@ -0,0 +1,29 @@ +class_name Player 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_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() + for i in get_slide_collision_count(): + var c = get_slide_collision(i) + if c.get_collider() is RigidBody2D: + #deliver the impact + c.get_collider().apply_central_impulse(-c.get_normal() * 100) diff --git a/Scripts/player.gd.uid b/Scripts/player.gd.uid new file mode 100644 index 0000000..50fe10a --- /dev/null +++ b/Scripts/player.gd.uid @@ -0,0 +1 @@ +uid://btmoyp0rwqmxe diff --git a/Scripts/trigger.gd b/Scripts/trigger.gd new file mode 100644 index 0000000..60fe6ed --- /dev/null +++ b/Scripts/trigger.gd @@ -0,0 +1,8 @@ +class_name Trigger extends Area2D + +@export var intent:String = "destroy" +signal triggerActiveSignal(body, intentMessage) + +func _on_body_entered(body: Node2D) -> void: + print("Body entered Trigger") + triggerActiveSignal.emit(body,intent) diff --git a/Scripts/trigger.gd.uid b/Scripts/trigger.gd.uid new file mode 100644 index 0000000..47a444e --- /dev/null +++ b/Scripts/trigger.gd.uid @@ -0,0 +1 @@ +uid://4hekg0d8n04f 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..918bd11 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cgqh7inwnegx" +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..55556b1 --- /dev/null +++ b/project.godot @@ -0,0 +1,30 @@ +; 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="AprilGameExample" +run/main_scene="uid://b06dlp8n6upld" +config/features=PackedStringArray("4.6", "Forward Plus") +config/icon="res://icon.svg" + +[file_customization] + +folder_colors={ +"res://Scripts/": "red" +} + +[physics] + +3d/physics_engine="Jolt Physics" + +[rendering] + +rendering_device/driver.windows="d3d12"