big 4 objects, custom signal, game controller

This commit is contained in:
RudyIm committed 2025-09-29 21:11:01 -04:00
commit afe089fdcd
16 files changed
+261

No files matched your search

+11
View File
@@ -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.36065605
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_uwrxv")
debug_color = Color(0.90240496, 0.29881617, 0.21305403, 0.41960785)
+73
View File
@@ -0,0 +1,73 @@
[gd_scene load_steps=8 format=3 uid="uid://cy1i6ucex6m0d"]
[ext_resource type="Script" uid="uid://c546prectbgc7" 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"]
[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(120, 233)
scale = Vector2(3.2000012, 1)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource("RectangleShape2D_8cj0n")
[node name="StaticBody2D2" type="StaticBody2D" parent="."]
position = Vector2(229.00002, 261)
rotation = -0.43738624
scale = Vector2(3.2000012, 1)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D2"]
shape = SubResource("RectangleShape2D_8cj0n")
[node name="StaticBody2D3" type="StaticBody2D" parent="."]
position = Vector2(321.00003, 198.00003)
rotation = 0.59605384
scale = Vector2(3.2000012, 1)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D3"]
shape = SubResource("RectangleShape2D_8cj0n")
[node name="Crate" parent="." instance=ExtResource("1_uwrxv")]
position = Vector2(112, 186)
[node name="RigidBody2D2" type="RigidBody2D" parent="."]
position = Vector2(147.99998, 202.99994)
rotation = 2.6595373
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D2"]
shape = SubResource("RectangleShape2D_uwrxv")
debug_color = Color(0.90240496, 0.29881617, 0.21305403, 0.41960785)
[node name="Boundary" type="StaticBody2D" parent="."]
position = Vector2(142, 591)
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(201, 376)
[node name="Trigger2" parent="." instance=ExtResource("2_yqjtg")]
position = Vector2(62.000015, 278)
intent = "powerup"
[node name="CharacterBody2D" parent="." instance=ExtResource("3_lnu2h")]
position = Vector2(96, 206)
[connection signal="triggerFiredSignal" from="Trigger" to="." method="_on_trigger_fired"]
[connection signal="triggerFiredSignal" from="Trigger2" to="." method="_on_trigger_fired"]
+35
View File
@@ -0,0 +1,35 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
@export var BUMP_POWER = 100
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()
# 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)
+1
View File
@@ -0,0 +1 @@
uid://bpcy1rfota5tu
+12
View File
@@ -0,0 +1,12 @@
[gd_scene load_steps=3 format=3 uid="uid://b1yy0sybg66hh"]
[ext_resource type="Script" uid="uid://bpcy1rfota5tu" path="res://scenes/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.46210045, 0.5883958, 0.21709043, 0.41960785)
+16
View File
@@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=3 uid="uid://dmrrbiwqptrho"]
[ext_resource type="Script" uid="uid://pxfi4acsyvl0" path="res://scripts/trigger.gd" id="1_du5ex"]
[sub_resource type="CircleShape2D" id="CircleShape2D_yqjtg"]
[node name="Trigger" type="Area2D"]
scale = Vector2(3.1635494, 3.0528653)
script = ExtResource("1_du5ex")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_yqjtg")
debug_color = Color(0.6732683, 0.3949942, 0.82000834, 0.41960785)
[connection signal="body_entered" from="." to="." method="_on_body_entered"]