commit 3d1f5bc3a87015c008526675445a6dc4dc381048 Author: AlexCavalcanti Date: Mon Apr 20 21:13:00 2026 -0400 static body, rigid body, character body, 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..f6e8142 --- /dev/null +++ b/Scenes/game.tscn @@ -0,0 +1,73 @@ +[gd_scene format=3 uid="uid://dtp5ijexobwve"] + +[ext_resource type="Script" uid="uid://dhm0a2m0fffvi" path="res://Scripts/player.gd" id="1_ebmjs"] +[ext_resource type="Script" uid="uid://bk2anxyq2o8o1" path="res://Scripts/gameController.gd" id="1_qxrlw"] +[ext_resource type="Script" uid="uid://duiou7q05u7yw" path="res://Scripts/trigger.gd" id="3_wrm1d"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_2poj3"] +size = Vector2(82, 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 = 63.134777 + +[node name="Game" type="Node2D" unique_id=44705523] +script = ExtResource("1_qxrlw") + +[node name="platform" type="StaticBody2D" parent="." unique_id=985263501] +position = Vector2(592, 350) +constant_linear_velocity = Vector2(10, 0) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="platform" unique_id=2116505086] +shape = SubResource("RectangleShape2D_2poj3") + +[node name="RigidBody2D" type="RigidBody2D" parent="." unique_id=1126415599] +position = Vector2(612, 180) +rotation = -0.50427383 +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D" unique_id=199536487] +shape = SubResource("RectangleShape2D_ebmjs") +debug_color = Color(0.8794198, 0.3322537, 0.19291705, 0.41960785) + +[node name="RigidBody2D2" type="RigidBody2D" parent="." unique_id=875571591] +position = Vector2(587, 127) +rotation = 1.5921826 +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D2" unique_id=1509622384] +shape = SubResource("RectangleShape2D_ebmjs") +debug_color = Color(0.8794198, 0.3322537, 0.19291705, 0.41960785) + +[node name="StaticBody2D" type="StaticBody2D" parent="." unique_id=621475000] +position = Vector2(594, 538) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D" unique_id=694080468] +shape = SubResource("WorldBoundaryShape2D_2poj3") + +[node name="CharacterBody2D" type="CharacterBody2D" parent="." unique_id=310597327] +position = Vector2(592, 264) +script = ExtResource("1_ebmjs") +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D" unique_id=2099117408] +shape = SubResource("CircleShape2D_2poj3") +debug_color = Color(0.2297152, 0.6339106, 0.2173942, 0.41960785) + +[node name="Area2D" type="Area2D" parent="." unique_id=668255328] +script = ExtResource("3_wrm1d") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=1692585551] +position = Vector2(693, 411) +shape = SubResource("CircleShape2D_3dryh") +debug_color = Color(0.9163366, 0.039014786, 0.69713354, 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..133ce41 --- /dev/null +++ b/Scripts/gameController.gd.uid @@ -0,0 +1 @@ +uid://bk2anxyq2o8o1 diff --git a/Scripts/player.gd b/Scripts/player.gd new file mode 100644 index 0000000..06b142b --- /dev/null +++ b/Scripts/player.gd @@ -0,0 +1,30 @@ +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..4b550c9 --- /dev/null +++ b/Scripts/player.gd.uid @@ -0,0 +1 @@ +uid://dhm0a2m0fffvi diff --git a/Scripts/trigger.gd b/Scripts/trigger.gd new file mode 100644 index 0000000..1f05e5b --- /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 a trigger") + triggerActiveSignal.emit(body, intent) diff --git a/Scripts/trigger.gd.uid b/Scripts/trigger.gd.uid new file mode 100644 index 0000000..9c7d404 --- /dev/null +++ b/Scripts/trigger.gd.uid @@ -0,0 +1 @@ +uid://duiou7q05u7yw 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..1137405 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dio8q387tt66q" +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..e4afc6c --- /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="ACAprilGame" +run/main_scene="uid://dtp5ijexobwve" +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"