diff --git a/Objects/ConveyorBelt/ConveyorBelt.gd b/Objects/ConveyorBelt/ConveyorBelt.gd index a37ffc4..0d48cdf 100644 --- a/Objects/ConveyorBelt/ConveyorBelt.gd +++ b/Objects/ConveyorBelt/ConveyorBelt.gd @@ -3,11 +3,14 @@ class_name ConveyorBelt # Speed (and direction) of the conveyor belt -export(float) var cb_speed = 100 setget set_cb_speed, get_cb_speed -export(bool) var randomize_gear_starting_position = false +export(float) var cb_speed: float = 100 setget set_cb_speed, get_cb_speed +export(bool) var randomize_gear_starting_position: bool = false signal cb_speed_changed(old, new) +func _ready(): + set_cb_speed(cb_speed) + func set_cb_speed(value): var old = cb_speed cb_speed = value diff --git a/Objects/ConveyorBelt/ConveyorBelt.tscn b/Objects/ConveyorBelt/ConveyorBelt.tscn index 2a239a0..ea06efe 100644 --- a/Objects/ConveyorBelt/ConveyorBelt.tscn +++ b/Objects/ConveyorBelt/ConveyorBelt.tscn @@ -5,9 +5,6 @@ [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] extents = Vector2( 640, 20 ) diff --git a/Objects/SpecialObjects/Main.tscn b/Objects/Main.tscn similarity index 99% rename from Objects/SpecialObjects/Main.tscn rename to Objects/Main.tscn index 86ff447..85e230b 100644 --- a/Objects/SpecialObjects/Main.tscn +++ b/Objects/Main.tscn @@ -9,8 +9,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_": [ ] @@ -22,6 +20,7 @@ __meta__ = { [node name="ConveyorBelt" parent="." instance=ExtResource( 3 )] position = Vector2( 640, 700 ) +cb_speed = 100.0 [node name="Player" parent="." instance=ExtResource( 1 )] position = Vector2( 340, 500 ) diff --git a/Objects/ScrollingObjects/ConveyorScrollParent.gd b/Objects/ScrollingObjects/ConveyorScrollParent.gd index 0bf9baa..de843ed 100644 --- a/Objects/ScrollingObjects/ConveyorScrollParent.gd +++ b/Objects/ScrollingObjects/ConveyorScrollParent.gd @@ -10,4 +10,4 @@ func _enter_tree(): conveyor_belt.connect("cb_speed_changed", self, "_on_ConveyorBelt_cb_speed_changed") func _on_ConveyorBelt_cb_speed_changed(old, new): - scroll_velocity.x = new + scroll_velocity.x = -conveyor_belt.get_relative_cb_speed(parent.position)