From dbc52c5be73fa9a8c2d886cce488d98efb1a42ac Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 4 Oct 2020 16:35:24 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Refactor=20most=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConveyorBelt}/ConveyorBelt.gd | 11 ++--- .../ConveyorBelt}/ConveyorBelt.tscn | 9 ++-- {Scripts => Objects/ConveyorBelt}/Gear.gd | 0 {Scenes => Objects/ConveyorBelt}/Gear.tscn | 3 +- {Scripts => Objects/ConveyorBelt}/Gears.gd | 16 +++---- {Scenes => Objects}/README.md | 0 .../ScrollingObjects}/Buzzsaw.gd | 2 +- .../ScrollingObjects}/Buzzsaw.tscn | 7 ++- .../ScrollingObjects/ConveyorScrollParent.gd | 13 ++++++ .../ConveyorScrollParent.tscn | 6 +++ .../ScrollingObjects}/Press.gd | 24 +++++----- .../ScrollingObjects}/Press.tscn | 3 +- Objects/ScrollingObjects/ScrollParent.gd | 14 ++++++ Objects/ScrollingObjects/ScrollParent.tscn | 6 +++ .../ScrollingObjects}/ScrollingBlock.tscn | 5 ++- Objects/ScrollingObjects/ScrollingPipe.tscn | 10 +++++ .../ScrollingPipesTileMap.tscn | 0 .../SpecialObjects}/Conductor.gd | 0 .../SpecialObjects}/Conductor.tscn | 2 +- {Scenes => Objects/SpecialObjects}/Main.tscn | 28 ++++++------ {Scripts => Objects/SpecialObjects}/Player.gd | 17 +++++-- .../SpecialObjects}/Player.tscn | 3 +- .../SpecialObjects}/SingleScreenWalls.tscn | 14 ++---- {Scenes => Objects/SpecialObjects}/Wall.tscn | 0 Scenes/Obstacles/ScrollingPipe.tscn | 9 ---- Scripts/ExtendedKinematicBody2D.gd | 10 ----- Scripts/Obstacles/ScrollingBlock.gd | 9 ---- ScrollingArea.gd | 7 +-- project.godot | 44 +++++++++---------- 29 files changed, 146 insertions(+), 126 deletions(-) rename {Scripts => Objects/ConveyorBelt}/ConveyorBelt.gd (77%) rename {Scenes => Objects/ConveyorBelt}/ConveyorBelt.tscn (91%) rename {Scripts => Objects/ConveyorBelt}/Gear.gd (100%) rename {Scenes => Objects/ConveyorBelt}/Gear.tscn (90%) rename {Scripts => Objects/ConveyorBelt}/Gears.gd (61%) rename {Scenes => Objects}/README.md (100%) rename {Scripts/Obstacles => Objects/ScrollingObjects}/Buzzsaw.gd (77%) rename {Scenes/Obstacles => Objects/ScrollingObjects}/Buzzsaw.tscn (74%) create mode 100644 Objects/ScrollingObjects/ConveyorScrollParent.gd create mode 100644 Objects/ScrollingObjects/ConveyorScrollParent.tscn rename {Scripts/Obstacles => Objects/ScrollingObjects}/Press.gd (90%) rename {Scenes/Obstacles => Objects/ScrollingObjects}/Press.tscn (93%) create mode 100644 Objects/ScrollingObjects/ScrollParent.gd create mode 100644 Objects/ScrollingObjects/ScrollParent.tscn rename {Scenes/Obstacles => Objects/ScrollingObjects}/ScrollingBlock.tscn (72%) create mode 100644 Objects/ScrollingObjects/ScrollingPipe.tscn rename {Scenes/Obstacles => Objects/ScrollingObjects}/ScrollingPipesTileMap.tscn (100%) rename {Scripts => Objects/SpecialObjects}/Conductor.gd (100%) rename {Scenes => Objects/SpecialObjects}/Conductor.tscn (64%) rename {Scenes => Objects/SpecialObjects}/Main.tscn (84%) rename {Scripts => Objects/SpecialObjects}/Player.gd (89%) rename {Scenes => Objects/SpecialObjects}/Player.tscn (86%) rename {Scenes => Objects/SpecialObjects}/SingleScreenWalls.tscn (59%) rename {Scenes => Objects/SpecialObjects}/Wall.tscn (100%) delete mode 100644 Scenes/Obstacles/ScrollingPipe.tscn delete mode 100644 Scripts/ExtendedKinematicBody2D.gd delete mode 100644 Scripts/Obstacles/ScrollingBlock.gd diff --git a/Scripts/ConveyorBelt.gd b/Objects/ConveyorBelt/ConveyorBelt.gd similarity index 77% rename from Scripts/ConveyorBelt.gd rename to Objects/ConveyorBelt/ConveyorBelt.gd index f3dafe0..a37ffc4 100644 --- a/Scripts/ConveyorBelt.gd +++ b/Objects/ConveyorBelt/ConveyorBelt.gd @@ -6,19 +6,16 @@ class_name ConveyorBelt export(float) var cb_speed = 100 setget set_cb_speed, get_cb_speed export(bool) var randomize_gear_starting_position = false +signal cb_speed_changed(old, new) + func set_cb_speed(value): + var old = cb_speed cb_speed = value - $Gears.set_cb_speed(value) + emit_signal("cb_speed_changed", old, value) func get_cb_speed(): return cb_speed - -func _ready(): - $Gears.set_randomize_start_position(randomize_gear_starting_position) - $Gears.set_cb_speed(cb_speed) - - func get_relative_cb_speed(other_pos: Vector2): var relative_position = other_pos - position var speed_sign = sign(relative_position.dot(Vector2.UP.rotated(rotation))) diff --git a/Scenes/ConveyorBelt.tscn b/Objects/ConveyorBelt/ConveyorBelt.tscn similarity index 91% rename from Scenes/ConveyorBelt.tscn rename to Objects/ConveyorBelt/ConveyorBelt.tscn index 2790698..2a239a0 100644 --- a/Scenes/ConveyorBelt.tscn +++ b/Objects/ConveyorBelt/ConveyorBelt.tscn @@ -1,9 +1,11 @@ [gd_scene load_steps=6 format=2] [ext_resource path="res://Tilesets/ConveyorBelt.tres" type="TileSet" id=1] -[ext_resource path="res://Scripts/ConveyorBelt.gd" type="Script" id=2] -[ext_resource path="res://Scenes/Gear.tscn" type="PackedScene" id=3] -[ext_resource path="res://Scripts/Gears.gd" type="Script" id=5] +[ext_resource path="res://Objects/ConveyorBelt/ConveyorBelt.gd" type="Script" id=2] +[ext_resource path="res://Objects/ConveyorBelt/Gear.tscn" type="PackedScene" id=3] +[ext_resource path="res://Objects/ConveyorBelt/Gears.gd" type="Script" id=5] + + [sub_resource type="RectangleShape2D" id=1] @@ -125,3 +127,4 @@ position = Vector2( 800, 0 ) [node name="Gear32" parent="Gears" instance=ExtResource( 3 )] position = Vector2( 840, 0 ) +[connection signal="cb_speed_changed" from="." to="Gears" method="_on_ConveyorBelt_cb_speed_changed"] diff --git a/Scripts/Gear.gd b/Objects/ConveyorBelt/Gear.gd similarity index 100% rename from Scripts/Gear.gd rename to Objects/ConveyorBelt/Gear.gd diff --git a/Scenes/Gear.tscn b/Objects/ConveyorBelt/Gear.tscn similarity index 90% rename from Scenes/Gear.tscn rename to Objects/ConveyorBelt/Gear.tscn index b3805ed..9d4ed7f 100644 --- a/Scenes/Gear.tscn +++ b/Objects/ConveyorBelt/Gear.tscn @@ -1,7 +1,8 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://Sprites/conveyor_gear.png" type="Texture" id=1] -[ext_resource path="res://Scripts/Gear.gd" type="Script" id=2] +[ext_resource path="res://Objects/ConveyorBelt/Gear.gd" type="Script" id=2] + [sub_resource type="Animation" id=2] diff --git a/Scripts/Gears.gd b/Objects/ConveyorBelt/Gears.gd similarity index 61% rename from Scripts/Gears.gd rename to Objects/ConveyorBelt/Gears.gd index e8872fc..b1e4754 100644 --- a/Scripts/Gears.gd +++ b/Objects/ConveyorBelt/Gears.gd @@ -1,18 +1,14 @@ extends Node2D -var cb_speed: float setget set_cb_speed, get_cb_speed - -func set_cb_speed(value): - for children in get_children(): - children.set_cb_speed(value) - -func get_cb_speed(): - return cb_speed - - var randomize_start_position: bool setget set_randomize_start_position func set_randomize_start_position(value): for children in get_children(): children.randomize_start_position = value + + +func _on_ConveyorBelt_cb_speed_changed(old, new): + for children in get_children(): + children.set_cb_speed(new) + diff --git a/Scenes/README.md b/Objects/README.md similarity index 100% rename from Scenes/README.md rename to Objects/README.md diff --git a/Scripts/Obstacles/Buzzsaw.gd b/Objects/ScrollingObjects/Buzzsaw.gd similarity index 77% rename from Scripts/Obstacles/Buzzsaw.gd rename to Objects/ScrollingObjects/Buzzsaw.gd index cae7fa1..52a3741 100644 --- a/Scripts/Obstacles/Buzzsaw.gd +++ b/Objects/ScrollingObjects/Buzzsaw.gd @@ -1,4 +1,4 @@ -extends ScrollingArea +extends Area2D class_name Buzzsaw diff --git a/Scenes/Obstacles/Buzzsaw.tscn b/Objects/ScrollingObjects/Buzzsaw.tscn similarity index 74% rename from Scenes/Obstacles/Buzzsaw.tscn rename to Objects/ScrollingObjects/Buzzsaw.tscn index 61bee20..72f2471 100644 --- a/Scenes/Obstacles/Buzzsaw.tscn +++ b/Objects/ScrollingObjects/Buzzsaw.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://Sprites/saw.png" type="Texture" id=1] -[ext_resource path="res://Scripts/Obstacles/Buzzsaw.gd" type="Script" id=2] +[ext_resource path="res://Objects/ScrollingObjects/Buzzsaw.gd" type="Script" id=2] +[ext_resource path="res://Objects/ScrollingObjects/ConveyorScrollParent.tscn" type="PackedScene" id=3] [sub_resource type="CircleShape2D" id=1] radius = 71.9263 @@ -34,3 +35,5 @@ shape = SubResource( 1 ) [node name="AnimationPlayer" type="AnimationPlayer" parent="."] anims/SpinClockwise = SubResource( 2 ) + +[node name="ConveyorScrollParent" parent="." instance=ExtResource( 3 )] diff --git a/Objects/ScrollingObjects/ConveyorScrollParent.gd b/Objects/ScrollingObjects/ConveyorScrollParent.gd new file mode 100644 index 0000000..0bf9baa --- /dev/null +++ b/Objects/ScrollingObjects/ConveyorScrollParent.gd @@ -0,0 +1,13 @@ +extends ScrollParent +class_name ConveyorScrollParent + + +onready var conveyor_belt: ConveyorBelt = null + + +func _enter_tree(): + conveyor_belt = get_tree().current_scene.get_node("ConveyorBelt") + conveyor_belt.connect("cb_speed_changed", self, "_on_ConveyorBelt_cb_speed_changed") + +func _on_ConveyorBelt_cb_speed_changed(old, new): + scroll_velocity.x = new diff --git a/Objects/ScrollingObjects/ConveyorScrollParent.tscn b/Objects/ScrollingObjects/ConveyorScrollParent.tscn new file mode 100644 index 0000000..e1a5b63 --- /dev/null +++ b/Objects/ScrollingObjects/ConveyorScrollParent.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Objects/ScrollingObjects/ConveyorScrollParent.gd" type="Script" id=1] + +[node name="ConveyorScrollParent" type="Node"] +script = ExtResource( 1 ) diff --git a/Scripts/Obstacles/Press.gd b/Objects/ScrollingObjects/Press.gd similarity index 90% rename from Scripts/Obstacles/Press.gd rename to Objects/ScrollingObjects/Press.gd index ff14d82..f9afa78 100644 --- a/Scripts/Obstacles/Press.gd +++ b/Objects/ScrollingObjects/Press.gd @@ -1,4 +1,4 @@ -extends ScrollingBlock +extends KinematicBody2D class_name Press export(int, 0, 47) var subbeat_offset = 0 @@ -6,21 +6,19 @@ export(int, 0, 47) var subbeat_offset = 0 var root_node: Node = null var conductor: Conductor = null +func _enter_tree(): + root_node = get_tree().current_scene + conductor = root_node.get_node("Conductor") + +func _ready(): + $CollisionShape2D.shape = RectangleShape2D.new() + $CollisionShape2D.shape.extents = Vector2(80, 76.5) + $Bottom/StompArea/CollisionShape2D.shape = RectangleShape2D.new() + $Bottom/StompArea/CollisionShape2D.shape.extents = Vector2(78, 4) + conductor.connect("subbeat", self, "_subbeat") func _subbeat(subbeat_num): if (subbeat_num - subbeat_offset) % 48 == 0: $AnimationPlayer.play("Stomp") elif (subbeat_num - subbeat_offset) % 48 == 24: $AnimationPlayer.play_backwards("Stomp") - -func _enter_tree(): - $CollisionShape2D.shape = RectangleShape2D.new() - $CollisionShape2D.shape.extents = Vector2(80, 76.5) - $Bottom/StompArea/CollisionShape2D.shape = RectangleShape2D.new() - $Bottom/StompArea/CollisionShape2D.shape.extents = Vector2(78, 4) - root_node = get_tree().current_scene - conductor = root_node.get_node("Conductor") - conductor.connect("subbeat", self, "_subbeat") - -func _on_StompArea_body_entered(body): - print(body) diff --git a/Scenes/Obstacles/Press.tscn b/Objects/ScrollingObjects/Press.tscn similarity index 93% rename from Scenes/Obstacles/Press.tscn rename to Objects/ScrollingObjects/Press.tscn index 07e32b0..aa2c2c3 100644 --- a/Scenes/Obstacles/Press.tscn +++ b/Objects/ScrollingObjects/Press.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=2] [ext_resource path="res://Sprites/press_bottom.png" type="Texture" id=1] -[ext_resource path="res://Scripts/Obstacles/Press.gd" type="Script" id=2] +[ext_resource path="res://Objects/ScrollingObjects/Press.gd" type="Script" id=2] [ext_resource path="res://Sprites/press_pipes.png" type="Texture" id=3] [sub_resource type="Animation" id=1] @@ -91,4 +91,3 @@ disabled = true [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2( 0, 76.5 ) -[connection signal="body_entered" from="Bottom/StompArea" to="." method="_on_StompArea_body_entered"] diff --git a/Objects/ScrollingObjects/ScrollParent.gd b/Objects/ScrollingObjects/ScrollParent.gd new file mode 100644 index 0000000..dfb4171 --- /dev/null +++ b/Objects/ScrollingObjects/ScrollParent.gd @@ -0,0 +1,14 @@ +extends Node +class_name ScrollParent + + +export(Vector2) var scroll_velocity: Vector2 = Vector2(-100, 0) +var parent = null + + +func _enter_tree(): + parent = get_parent() + + +func _physics_process(delta): + parent.position += scroll_velocity * delta diff --git a/Objects/ScrollingObjects/ScrollParent.tscn b/Objects/ScrollingObjects/ScrollParent.tscn new file mode 100644 index 0000000..f18c8c2 --- /dev/null +++ b/Objects/ScrollingObjects/ScrollParent.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Objects/ScrollingObjects/ScrollParent.gd" type="Script" id=1] + +[node name="ScrollParent" type="Node"] +script = ExtResource( 1 ) diff --git a/Scenes/Obstacles/ScrollingBlock.tscn b/Objects/ScrollingObjects/ScrollingBlock.tscn similarity index 72% rename from Scenes/Obstacles/ScrollingBlock.tscn rename to Objects/ScrollingObjects/ScrollingBlock.tscn index b342a98..994d253 100644 --- a/Scenes/Obstacles/ScrollingBlock.tscn +++ b/Objects/ScrollingObjects/ScrollingBlock.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://Sprites/crate.png" type="Texture" id=1] -[ext_resource path="res://Scripts/Obstacles/ScrollingBlock.gd" type="Script" id=2] +[ext_resource path="res://Objects/ScrollingObjects/ConveyorScrollParent.tscn" type="PackedScene" id=2] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 20, 20 ) @@ -10,10 +10,11 @@ extents = Vector2( 20, 20 ) collision_layer = 8 collision_mask = 2 motion/sync_to_physics = true -script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) + +[node name="ConveyorScrollParent" parent="." instance=ExtResource( 2 )] diff --git a/Objects/ScrollingObjects/ScrollingPipe.tscn b/Objects/ScrollingObjects/ScrollingPipe.tscn new file mode 100644 index 0000000..a4c6296 --- /dev/null +++ b/Objects/ScrollingObjects/ScrollingPipe.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Objects/ScrollingObjects/ConveyorScrollParent.tscn" type="PackedScene" id=2] + +[node name="ScrollingPipe" type="KinematicBody2D"] +collision_layer = 8 +collision_mask = 2 +motion/sync_to_physics = true + +[node name="ConveyorScrollParent" parent="." instance=ExtResource( 2 )] diff --git a/Scenes/Obstacles/ScrollingPipesTileMap.tscn b/Objects/ScrollingObjects/ScrollingPipesTileMap.tscn similarity index 100% rename from Scenes/Obstacles/ScrollingPipesTileMap.tscn rename to Objects/ScrollingObjects/ScrollingPipesTileMap.tscn diff --git a/Scripts/Conductor.gd b/Objects/SpecialObjects/Conductor.gd similarity index 100% rename from Scripts/Conductor.gd rename to Objects/SpecialObjects/Conductor.gd diff --git a/Scenes/Conductor.tscn b/Objects/SpecialObjects/Conductor.tscn similarity index 64% rename from Scenes/Conductor.tscn rename to Objects/SpecialObjects/Conductor.tscn index 93099b7..305d82d 100644 --- a/Scenes/Conductor.tscn +++ b/Objects/SpecialObjects/Conductor.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://Scripts/Conductor.gd" type="Script" id=1] +[ext_resource path="res://Objects/SpecialObjects/Conductor.gd" type="Script" id=1] [node name="Conductor" type="Node"] script = ExtResource( 1 ) diff --git a/Scenes/Main.tscn b/Objects/SpecialObjects/Main.tscn similarity index 84% rename from Scenes/Main.tscn rename to Objects/SpecialObjects/Main.tscn index e71589e..86ff447 100644 --- a/Scenes/Main.tscn +++ b/Objects/SpecialObjects/Main.tscn @@ -1,28 +1,30 @@ [gd_scene load_steps=9 format=2] -[ext_resource path="res://Scenes/Player.tscn" type="PackedScene" id=1] -[ext_resource path="res://Scenes/Conductor.tscn" type="PackedScene" id=2] -[ext_resource path="res://Scenes/ConveyorBelt.tscn" type="PackedScene" id=3] -[ext_resource path="res://Scenes/SingleScreenWalls.tscn" type="PackedScene" id=4] -[ext_resource path="res://Scenes/Obstacles/Press.tscn" type="PackedScene" id=5] -[ext_resource path="res://Scenes/Obstacles/ScrollingPipe.tscn" type="PackedScene" id=6] -[ext_resource path="res://Scenes/Obstacles/Buzzsaw.tscn" type="PackedScene" id=7] -[ext_resource path="res://Scenes/Obstacles/ScrollingPipesTileMap.tscn" type="PackedScene" id=8] +[ext_resource path="res://Objects/SpecialObjects/Player.tscn" type="PackedScene" id=1] +[ext_resource path="res://Objects/SpecialObjects/Conductor.tscn" type="PackedScene" id=2] +[ext_resource path="res://Objects/ConveyorBelt/ConveyorBelt.tscn" type="PackedScene" id=3] +[ext_resource path="res://Objects/SpecialObjects/SingleScreenWalls.tscn" type="PackedScene" id=4] +[ext_resource path="res://Objects/ScrollingObjects/Press.tscn" type="PackedScene" id=5] +[ext_resource path="res://Objects/ScrollingObjects/ScrollingPipe.tscn" type="PackedScene" id=6] +[ext_resource path="res://Objects/ScrollingObjects/Buzzsaw.tscn" type="PackedScene" id=7] +[ext_resource path="res://Objects/ScrollingObjects/ScrollingPipesTileMap.tscn" type="PackedScene" id=8] + + [node name="Main" type="Node2D"] __meta__ = { "_edit_horizontal_guides_": [ ] } -[node name="Player" parent="." instance=ExtResource( 1 )] -position = Vector2( 340, 500 ) +[node name="Conductor" parent="." instance=ExtResource( 2 )] + +[node name="SingleScreenWalls" parent="." instance=ExtResource( 4 )] [node name="ConveyorBelt" parent="." instance=ExtResource( 3 )] position = Vector2( 640, 700 ) -[node name="SingleScreenWalls" parent="." instance=ExtResource( 4 )] - -[node name="Conductor" parent="." instance=ExtResource( 2 )] +[node name="Player" parent="." instance=ExtResource( 1 )] +position = Vector2( 340, 500 ) [node name="Buzzsaw" parent="." instance=ExtResource( 7 )] position = Vector2( 1000, 540 ) diff --git a/Scripts/Player.gd b/Objects/SpecialObjects/Player.gd similarity index 89% rename from Scripts/Player.gd rename to Objects/SpecialObjects/Player.gd index fe2a72d..3d2d5b5 100644 --- a/Scripts/Player.gd +++ b/Objects/SpecialObjects/Player.gd @@ -1,24 +1,33 @@ -extends ExtendedKinematicBody2D +extends KinematicBody2D class_name Player -export(Vector2) var gravity: Vector2 = Vector2(0, 10) -var speed: Vector2 = Vector2.ZERO +export(Vector2) var gravity: Vector2 = Vector2(0, 10) export(float) var move_speed: float = 300 export(float) var jump_speed: float = 425 export(float) var jump_buffer_msec: float = 80 export(float) var quick_fall_gravity_multiplier: float = 4 export(bool) var stop_jump_on_bonk: bool = true +var speed: Vector2 = Vector2.ZERO var can_jump: bool = false var jump_buffer: int = 0 - var is_quick_falling: bool = false var quick_fall_buffer: int = 0 + +func get_floor(): + for slide in get_slide_count(): + var collision = get_slide_collision(slide) + if collision.normal != get_floor_normal(): + continue + return collision.collider + + func up_normal(): return -gravity.normalized() + func _physics_process(delta): var up_normal = up_normal() var floor_normal = get_floor_normal() diff --git a/Scenes/Player.tscn b/Objects/SpecialObjects/Player.tscn similarity index 86% rename from Scenes/Player.tscn rename to Objects/SpecialObjects/Player.tscn index 7a856d8..9d4c4f6 100644 --- a/Scenes/Player.tscn +++ b/Objects/SpecialObjects/Player.tscn @@ -1,7 +1,8 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://Sprites/player_danny_devito.png" type="Texture" id=1] -[ext_resource path="res://Scripts/Player.gd" type="Script" id=2] +[ext_resource path="res://Objects/SpecialObjects/Player.gd" type="Script" id=2] + [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 16, 16 ) diff --git a/Scenes/SingleScreenWalls.tscn b/Objects/SpecialObjects/SingleScreenWalls.tscn similarity index 59% rename from Scenes/SingleScreenWalls.tscn rename to Objects/SpecialObjects/SingleScreenWalls.tscn index ce91539..837e238 100644 --- a/Scenes/SingleScreenWalls.tscn +++ b/Objects/SpecialObjects/SingleScreenWalls.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=2] -[ext_resource path="res://Scenes/Wall.tscn" type="PackedScene" id=1] +[ext_resource path="res://Objects/SpecialObjects/Wall.tscn" type="PackedScene" id=1] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 20, 360 ) @@ -10,25 +10,19 @@ extents = Vector2( 680, 20 ) [node name="SingleScreenWalls" type="Node2D"] -[node name="WallLeft" type="StaticBody2D" parent="." instance=ExtResource( 1 )] -collision_layer = 16 -collision_mask = 2 +[node name="WallLeft" parent="." instance=ExtResource( 1 )] [node name="CollisionShape2D" type="CollisionShape2D" parent="WallLeft"] position = Vector2( -20, 360 ) shape = SubResource( 1 ) -[node name="WallRight" type="StaticBody2D" parent="." instance=ExtResource( 1 )] -collision_layer = 16 -collision_mask = 2 +[node name="WallRight" parent="." instance=ExtResource( 1 )] [node name="CollisionShape2D" type="CollisionShape2D" parent="WallRight"] position = Vector2( 1300, 360 ) shape = SubResource( 1 ) -[node name="WallTop" type="StaticBody2D" parent="." instance=ExtResource( 1 )] -collision_layer = 16 -collision_mask = 2 +[node name="WallTop" parent="." instance=ExtResource( 1 )] [node name="CollisionShape2D" type="CollisionShape2D" parent="WallTop"] position = Vector2( 640, -20 ) diff --git a/Scenes/Wall.tscn b/Objects/SpecialObjects/Wall.tscn similarity index 100% rename from Scenes/Wall.tscn rename to Objects/SpecialObjects/Wall.tscn diff --git a/Scenes/Obstacles/ScrollingPipe.tscn b/Scenes/Obstacles/ScrollingPipe.tscn deleted file mode 100644 index 4b238fc..0000000 --- a/Scenes/Obstacles/ScrollingPipe.tscn +++ /dev/null @@ -1,9 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://Scripts/Obstacles/ScrollingBlock.gd" type="Script" id=2] - -[node name="ScrollingPipe" type="KinematicBody2D"] -collision_layer = 8 -collision_mask = 2 -motion/sync_to_physics = true -script = ExtResource( 2 ) diff --git a/Scripts/ExtendedKinematicBody2D.gd b/Scripts/ExtendedKinematicBody2D.gd deleted file mode 100644 index 36efc37..0000000 --- a/Scripts/ExtendedKinematicBody2D.gd +++ /dev/null @@ -1,10 +0,0 @@ -extends KinematicBody2D -class_name ExtendedKinematicBody2D - - -func get_floor(): - for slide in get_slide_count(): - var collision = get_slide_collision(slide) - if collision.normal != get_floor_normal(): - continue - return collision.collider diff --git a/Scripts/Obstacles/ScrollingBlock.gd b/Scripts/Obstacles/ScrollingBlock.gd deleted file mode 100644 index 8e17b53..0000000 --- a/Scripts/Obstacles/ScrollingBlock.gd +++ /dev/null @@ -1,9 +0,0 @@ -extends ExtendedKinematicBody2D -class_name ScrollingBlock - - -export(Vector2) var scroll_velocity: Vector2 = Vector2(-100, 0) - - -func _physics_process(delta): - position += scroll_velocity * delta diff --git a/ScrollingArea.gd b/ScrollingArea.gd index bc2e479..472249f 100644 --- a/ScrollingArea.gd +++ b/ScrollingArea.gd @@ -1,9 +1,4 @@ -extends Area2D +extends ScrollingObject2D class_name ScrollingArea -export(Vector2) var scroll_velocity: Vector2 = Vector2(-100, 0) - - -func _physics_process(delta): - position += scroll_velocity * delta diff --git a/project.godot b/project.godot index 3f565d5..0bb4dba 100644 --- a/project.godot +++ b/project.godot @@ -9,61 +9,61 @@ config_version=4 _global_script_classes=[ { -"base": "ScrollingArea", +"base": "Area2D", "class": "Buzzsaw", "language": "GDScript", -"path": "res://Scripts/Obstacles/Buzzsaw.gd" +"path": "res://Objects/ScrollingObjects/Buzzsaw.gd" }, { "base": "Node", "class": "Conductor", "language": "GDScript", -"path": "res://Scripts/Conductor.gd" +"path": "res://Objects/SpecialObjects/Conductor.gd" }, { "base": "StaticBody2D", "class": "ConveyorBelt", "language": "GDScript", -"path": "res://Scripts/ConveyorBelt.gd" +"path": "res://Objects/ConveyorBelt/ConveyorBelt.gd" +}, { +"base": "ScrollParent", +"class": "ConveyorScrollParent", +"language": "GDScript", +"path": "res://Objects/ScrollingObjects/ConveyorScrollParent.gd" }, { "base": "KinematicBody2D", -"class": "ExtendedKinematicBody2D", -"language": "GDScript", -"path": "res://Scripts/ExtendedKinematicBody2D.gd" -}, { -"base": "ExtendedKinematicBody2D", "class": "Player", "language": "GDScript", -"path": "res://Scripts/Player.gd" +"path": "res://Objects/SpecialObjects/Player.gd" }, { -"base": "ScrollingBlock", +"base": "KinematicBody2D", "class": "Press", "language": "GDScript", -"path": "res://Scripts/Obstacles/Press.gd" +"path": "res://Objects/ScrollingObjects/Press.gd" }, { -"base": "Area2D", +"base": "Node", +"class": "ScrollParent", +"language": "GDScript", +"path": "res://Objects/ScrollingObjects/ScrollParent.gd" +}, { +"base": "ScrollingObject2D", "class": "ScrollingArea", "language": "GDScript", "path": "res://ScrollingArea.gd" -}, { -"base": "ExtendedKinematicBody2D", -"class": "ScrollingBlock", -"language": "GDScript", -"path": "res://Scripts/Obstacles/ScrollingBlock.gd" } ] _global_script_class_icons={ "Buzzsaw": "", "Conductor": "", "ConveyorBelt": "", -"ExtendedKinematicBody2D": "", +"ConveyorScrollParent": "", "Player": "", "Press": "", -"ScrollingArea": "", -"ScrollingBlock": "" +"ScrollParent": "", +"ScrollingArea": "" } [application] config/name="ld47" -run/main_scene="res://Scenes/Main.tscn" +run/main_scene="res://Objects/SpecialObjects/Main.tscn" [display]