mirror of
https://github.com/Steffo99/looping-for-loops.git
synced 2024-11-22 08:04:23 +00:00
🐞 Fix conveyor belt speed bug
This commit is contained in:
parent
dbc52c5be7
commit
d4dbb4c55c
4 changed files with 7 additions and 8 deletions
|
@ -3,11 +3,14 @@ class_name ConveyorBelt
|
||||||
|
|
||||||
|
|
||||||
# Speed (and direction) of the conveyor belt
|
# Speed (and direction) of the conveyor belt
|
||||||
export(float) var cb_speed = 100 setget set_cb_speed, get_cb_speed
|
export(float) var cb_speed: float = 100 setget set_cb_speed, get_cb_speed
|
||||||
export(bool) var randomize_gear_starting_position = false
|
export(bool) var randomize_gear_starting_position: bool = false
|
||||||
|
|
||||||
signal cb_speed_changed(old, new)
|
signal cb_speed_changed(old, new)
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
set_cb_speed(cb_speed)
|
||||||
|
|
||||||
func set_cb_speed(value):
|
func set_cb_speed(value):
|
||||||
var old = cb_speed
|
var old = cb_speed
|
||||||
cb_speed = value
|
cb_speed = value
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
[ext_resource path="res://Objects/ConveyorBelt/Gear.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://Objects/ConveyorBelt/Gear.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://Objects/ConveyorBelt/Gears.gd" type="Script" id=5]
|
[ext_resource path="res://Objects/ConveyorBelt/Gears.gd" type="Script" id=5]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 640, 20 )
|
extents = Vector2( 640, 20 )
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
[ext_resource path="res://Objects/ScrollingObjects/Buzzsaw.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://Objects/ScrollingObjects/Buzzsaw.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://Objects/ScrollingObjects/ScrollingPipesTileMap.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://Objects/ScrollingObjects/ScrollingPipesTileMap.tscn" type="PackedScene" id=8]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_horizontal_guides_": [ ]
|
"_edit_horizontal_guides_": [ ]
|
||||||
|
@ -22,6 +20,7 @@ __meta__ = {
|
||||||
|
|
||||||
[node name="ConveyorBelt" parent="." instance=ExtResource( 3 )]
|
[node name="ConveyorBelt" parent="." instance=ExtResource( 3 )]
|
||||||
position = Vector2( 640, 700 )
|
position = Vector2( 640, 700 )
|
||||||
|
cb_speed = 100.0
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||||
position = Vector2( 340, 500 )
|
position = Vector2( 340, 500 )
|
|
@ -10,4 +10,4 @@ func _enter_tree():
|
||||||
conveyor_belt.connect("cb_speed_changed", self, "_on_ConveyorBelt_cb_speed_changed")
|
conveyor_belt.connect("cb_speed_changed", self, "_on_ConveyorBelt_cb_speed_changed")
|
||||||
|
|
||||||
func _on_ConveyorBelt_cb_speed_changed(old, new):
|
func _on_ConveyorBelt_cb_speed_changed(old, new):
|
||||||
scroll_velocity.x = new
|
scroll_velocity.x = -conveyor_belt.get_relative_cb_speed(parent.position)
|
||||||
|
|
Loading…
Reference in a new issue