4 games objects,

This commit is contained in:
konzy 2024-11-18 20:50:07 -05:00
parent 7f9389cd7a
commit 112f7ec7ee
5 changed files with 164 additions and 0 deletions

View File

@ -11,5 +11,12 @@ config_version=5
[application]
config/name="NovemberGame"
run/main_scene="res://scenes/game.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg"
[file_customization]
folder_colors={
"res://scripts/": "green"
}

View File

@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://flumvyk8tafw"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c58s7"]
size = Vector2(46, 42)
[node name="RigidBody2D" type="RigidBody2D" groups=["box"]]
position = Vector2(588, 292)
rotation = 0.837162
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_c58s7")
debug_color = Color(0.816792, 0.399035, 0.20363, 0.42)

View File

@ -0,0 +1,90 @@
[gd_scene load_steps=8 format=3 uid="uid://dmk3hbsrqhgad"]
[ext_resource type="PackedScene" uid="uid://flumvyk8tafw" path="res://scenes/box.tscn" id="1_ixp3c"]
[ext_resource type="Script" path="res://scripts/dudecontroller.gd" id="1_pin1i"]
[ext_resource type="Script" path="res://scripts/trigger.gd" id="2_e4xab"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_mhewf"]
size = Vector2(102, 12)
[sub_resource type="CircleShape2D" id="CircleShape2D_drde1"]
radius = 23.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0jo0r"]
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_jsnkw"]
[node name="Game" type="Node2D"]
[node name="Platform" type="StaticBody2D" parent="."]
position = Vector2(584, 454)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform"]
shape = SubResource("RectangleShape2D_mhewf")
[node name="Platform2" type="StaticBody2D" parent="."]
position = Vector2(802, 455)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform2"]
shape = SubResource("RectangleShape2D_mhewf")
[node name="Platform4" type="StaticBody2D" parent="."]
position = Vector2(980, 381)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform4"]
shape = SubResource("RectangleShape2D_mhewf")
[node name="Platform3" type="StaticBody2D" parent="."]
position = Vector2(331, 455)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform3"]
shape = SubResource("RectangleShape2D_mhewf")
[node name="Platform5" type="StaticBody2D" parent="."]
position = Vector2(137, 363)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform5"]
shape = SubResource("RectangleShape2D_mhewf")
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
position = Vector2(589, 426)
script = ExtResource("1_pin1i")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
rotation = -0.0421956
shape = SubResource("CircleShape2D_drde1")
debug_color = Color(0.459127, 0.454101, 0.981072, 0.42)
[node name="Area2D" type="Area2D" parent="."]
position = Vector2(576, 533)
scale = Vector2(18.56, 0.640005)
script = ExtResource("2_e4xab")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("RectangleShape2D_0jo0r")
debug_color = Color(0.774214, 0.233911, 0.917118, 0.42)
[node name="RigidBody2D" parent="." instance=ExtResource("1_ixp3c")]
position = Vector2(627, 304)
[node name="RigidBody2D2" parent="." instance=ExtResource("1_ixp3c")]
position = Vector2(586, 229)
[node name="RigidBody2D3" parent="." instance=ExtResource("1_ixp3c")]
position = Vector2(533, 301)
[node name="StaticBody2D" type="StaticBody2D" parent="."]
position = Vector2(581, 648)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource("WorldBoundaryShape2D_jsnkw")
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]

View File

@ -0,0 +1,33 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
const BUMP_FORCE = 50
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:
c.get_collider().apply_central_impulse(-c.get_normal() * BUMP_FORCE)

View File

@ -0,0 +1,21 @@
extends Area2D
var BoxCount = 0
var MaxBoxes = 3
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_body_entered(body: Node2D) -> void:
print("Trigger saw a thing")
if body.is_in_group("box"):
print("box hit the trigger")
BoxCount +=1
if BoxCount >= MaxBoxes:
print("YU WUN")