1
Fork 0
mirror of https://github.com/Steffo99/looping-for-loops.git synced 2024-11-21 15:44:24 +00:00

Fix RNG not working on Firefox

This commit is contained in:
Steffo 2020-10-06 12:02:10 +02:00
parent ac1d2279ee
commit d175e42eb8
4 changed files with 96 additions and 23 deletions

View file

@ -1,8 +1,6 @@
extends Node2D
var rng = RandomNumberGenerator.new()
var cb_speed: float setget set_cb_speed, get_cb_speed
var randomize_start_position: bool = false
@ -11,8 +9,7 @@ func set_cb_speed(value):
$AnimationPlayer.playback_speed = -value / 80
$AnimationPlayer.play("SpinClockwise")
if randomize_start_position:
rng.randomize()
var offset = rng.randf_range(0.0, 1.0)
var offset = GLOBAL.rng.randf_range(0.0, 1.0)
$AnimationPlayer.seek(offset, true)
randomize_start_position = false

View file

@ -2,3 +2,8 @@ extends Node
var loops_collected: int = 0
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
func _init():
rng.randomize()

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=35 format=2]
[gd_scene load_steps=34 format=2]
[ext_resource path="res://Objects/SpecialObjects/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Objects/SpecialObjects/Conductor.tscn" type="PackedScene" id=2]
@ -32,7 +32,6 @@
[ext_resource path="res://Objects/Levels/Bridge.tscn" type="PackedScene" id=30]
[ext_resource path="res://Objects/Levels/max_level_2.tscn" type="PackedScene" id=31]
[ext_resource path="res://Music/RetroFuture Clean.ogg" type="AudioStream" id=32]
[ext_resource path="res://Objects/Levels/max_level_3.tscn" type="PackedScene" id=33]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.294118 )
@ -817,9 +816,82 @@ position = Vector2( 580, 240 )
[node name="Loop16" parent="Safe/Loops" instance=ExtResource( 20 )]
position = Vector2( 500, 240 )
[node name="Node2D" parent="." instance=ExtResource( 33 )]
[node name="Node2D" type="Node2D" parent="."]
position = Vector2( 11520, 0 )
[node name="Buzzsaw2" parent="Node2D" instance=ExtResource( 18 )]
position = Vector2( 660, 440 )
[node name="ScrollingLaser" parent="Node2D" instance=ExtResource( 29 )]
position = Vector2( 780, 320 )
[node name="ScrollingLaser7" parent="Node2D" instance=ExtResource( 29 )]
position = Vector2( 1140, 80 )
[node name="ScrollingLaser2" parent="Node2D" instance=ExtResource( 29 )]
position = Vector2( 420, 480 )
[node name="ScrollingLaser4" parent="Node2D" instance=ExtResource( 29 )]
position = Vector2( 500, 480 )
[node name="ScrollingLaser5" parent="Node2D" instance=ExtResource( 29 )]
position = Vector2( 260, 600 )
[node name="ScrollingLaser6" parent="Node2D" instance=ExtResource( 29 )]
position = Vector2( 180, 600 )
[node name="ScrollingLaser3" parent="Node2D" instance=ExtResource( 29 )]
position = Vector2( 860, 320 )
[node name="ScrollingPipe" parent="Node2D" instance=ExtResource( 23 )]
position = Vector2( 2560, 0 )
[node name="TileMap" parent="Node2D/ScrollingPipe" instance=ExtResource( 21 )]
tile_data = PoolIntArray( 393171, 0, 0, 393172, 0, 65537, 393173, 0, 1, 458707, 0, 131072, 458708, 0, 65536, 458709, 0, 131073, 524244, 0, 65536, 589780, 0, 65536, 589787, 0, 0, 589788, 0, 65537, 589789, 0, 1, 655306, 0, 0, 655307, 0, 65537, 655308, 0, 1, 655316, 0, 65536, 655323, 0, 131072, 655324, 0, 65536, 655325, 0, 131073, 720842, 0, 131072, 720843, 0, 65536, 720844, 0, 131073, 720860, 0, 65536, 786379, 0, 65536, 786384, 0, 65536, 786396, 0, 65536, 851908, 0, 0, 851909, 0, 65537, 851910, 0, 1, 851915, 0, 65536, 851920, 0, 65536, 851932, 0, 65536, 917444, 0, 131072, 917445, 0, 65536, 917446, 0, 131073, 917451, 0, 65536, 917456, 0, 65536, 917460, 0, 65536, 917461, 0, 65537, 917462, 0, 65537, 917463, 0, 65537, 917464, 0, 65537, 917465, 0, 65537, 917466, 0, 65537, 917467, 0, 65537, 917468, 0, 131073, 982981, 0, 65536, 982987, 0, 65536, 982992, 0, 65536, 982996, 0, 65536, 1048517, 0, 65536, 1048523, 0, 65536, 1048528, 0, 65536, 1114053, 0, 65536, 1114059, 0, 65536, 1114064, 0, 65536 )
[node name="GameButton" parent="Node2D" instance=ExtResource( 28 )]
position = Vector2( 820, 420 )
color = Color( 1, 0.490196, 0, 1 )
[node name="GhostGroup" parent="Node2D" instance=ExtResource( 17 )]
position = Vector2( 680, 480 )
[node name="GhostBlock4" parent="Node2D/GhostGroup" instance=ExtResource( 24 )]
position = Vector2( 100, -60 )
[node name="GhostBlock6" parent="Node2D/GhostGroup" instance=ExtResource( 24 )]
position = Vector2( 180, -60 )
is_active = false
[node name="Loops" type="Node2D" parent="Node2D"]
[node name="Loop" parent="Node2D/Loops" instance=ExtResource( 20 )]
position = Vector2( 820, 160 )
[node name="Loop2" parent="Node2D/Loops" instance=ExtResource( 20 )]
position = Vector2( 220, 440 )
[node name="Loop3" parent="Node2D/Loops" instance=ExtResource( 20 )]
position = Vector2( 460, 320 )
[node name="Loop4" parent="Node2D/Loops" instance=ExtResource( 20 )]
position = Vector2( 1100, 500 )
[node name="Loop5" parent="Node2D/Loops" instance=ExtResource( 20 )]
position = Vector2( 1080, 500 )
[node name="Loop6" parent="Node2D/Loops" instance=ExtResource( 20 )]
position = Vector2( 1080, 480 )
[node name="Loop7" parent="Node2D/Loops" instance=ExtResource( 20 )]
position = Vector2( 1100, 480 )
[node name="Loop8" parent="Node2D/Loops" instance=ExtResource( 20 )]
position = Vector2( 820, 480 )
[node name="Background" parent="Node2D" instance=ExtResource( 13 )]
texture = ExtResource( 26 )
[node name="Background" parent="." instance=ExtResource( 13 )]
position = Vector2( 14720, 360 )
@ -830,38 +902,40 @@ autoplay = true
[connection signal="loop_collected" from="Player" to="LoopCountPanel" method="_on_Player_loop_collected"]
[connection signal="body_entered" from="Intro/WinDoor" to="Player" method="_on_WinDoor_body_entered"]
[connection signal="clicked" from="BuzzsawChoice/CBSpeedChangeButton" to="BuzzsawChoice/GhostGroup" method="toggle"]
[connection signal="clicked" from="LongJump/GhostGroup/CBSpeedChangeButton" to="LongJump/GhostGroup/CBSpeedChangeButton" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup/CBSpeedChangeButton" to="LongJump/GhostGroup" method="deactivate"]
[connection signal="clicked" from="LongJump/GhostGroup/CBSpeedChangeButton" to="LongJump/GhostGroup/CBSpeedChangeButton" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup/CBSpeedChangeButton2" to="LongJump/GhostGroup" method="deactivate"]
[connection signal="clicked" from="LongJump/GhostGroup/CBSpeedChangeButton2" to="LongJump/GhostGroup/CBSpeedChangeButton2" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup/CBSpeedChangeButton3" to="LongJump/GhostGroup/CBSpeedChangeButton3" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup/CBSpeedChangeButton3" to="LongJump/GhostGroup" method="deactivate"]
[connection signal="clicked" from="LongJump/GhostGroup/CBSpeedChangeButton3" to="LongJump/GhostGroup/CBSpeedChangeButton3" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton" to="BuzzsawChoice/GhostGroup2" method="activate"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton" to="LongJump/GhostGroup2/CBSpeedChangeButton" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton" to="LongJump/GhostGroup2" method="deactivate"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton" to="LongJump/GhostGroup2/CBSpeedChangeButton" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton2" to="BuzzsawChoice/GhostGroup2" method="activate"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton2" to="LongJump/GhostGroup2/CBSpeedChangeButton2" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton2" to="LongJump/GhostGroup2" method="deactivate"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton2" to="LongJump/GhostGroup2/CBSpeedChangeButton2" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton3" to="BuzzsawChoice/GhostGroup2" method="activate"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton3" to="LongJump/GhostGroup2/CBSpeedChangeButton3" method="_on_GameButton_clicked"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton3" to="LongJump/GhostGroup2" method="deactivate"]
[connection signal="clicked" from="LongJump/GhostGroup2/CBSpeedChangeButton3" to="LongJump/GhostGroup2/CBSpeedChangeButton3" method="_on_GameButton_clicked"]
[connection signal="clicked" from="Tower/GameButtonChain/GameButton6" to="Tower/GhostGroup" method="deactivate"]
[connection signal="clicked" from="MaxLevel1/Node2D/GameButton" to="MaxLevel1/Node2D/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D/GameButton" to="MaxLevel1/Node2D/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D2/GameButton" to="MaxLevel1/Node2D2/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D/GameButton" to="MaxLevel1/Node2D/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D2/GameButton" to="MaxLevel1/Node2D2/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D3/GameButton" to="MaxLevel1/Node2D3/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D2/GameButton" to="MaxLevel1/Node2D2/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D3/GameButton" to="MaxLevel1/Node2D3/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D4/GameButton" to="MaxLevel1/Node2D4/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D4/GameButton" to="MaxLevel1/Node2D4/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D3/GameButton" to="MaxLevel1/Node2D3/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D4/GameButton" to="Tower/GhostGroup2" method="deactivate"]
[connection signal="clicked" from="MaxLevel1/Node2D5/GameButton" to="MaxLevel1/Node2D5/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D4/GameButton" to="MaxLevel1/Node2D4/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D4/GameButton" to="MaxLevel1/Node2D4/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D5/GameButton" to="MaxLevel1/Node2D5/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D5/GameButton" to="MaxLevel1/Node2D5/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D6/GameButton" to="MaxLevel1/Node2D6/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D6/GameButton" to="MaxLevel1/Node2D6/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D7/GameButton" to="MaxLevel1/Node2D7/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D7/GameButton" to="MaxLevel1/Node2D7/Laser" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D8/GameButton" to="MaxLevel1/Node2D8/GameButton" method="toggle"]
[connection signal="clicked" from="MaxLevel1/Node2D8/GameButton" to="MaxLevel1/Node2D8/Laser" method="toggle"]
[connection signal="clicked" from="Safe/GameButtonChain/GameButton9" to="Safe/GhostGroup" method="deactivate"]
[connection signal="clicked" from="Safe/GameButtonChain/GameButton9" to="Intro/GhostGroup" method="deactivate"]
[connection signal="clicked" from="Safe/GameButtonChain/GameButton9" to="Safe/GhostGroup" method="deactivate"]
[connection signal="clicked" from="Node2D/GameButton" to="Node2D/GameButton" method="activate"]
[connection signal="clicked" from="Node2D/GameButton" to="Node2D/GhostGroup" method="toggle"]

View file

@ -1,15 +1,12 @@
extends Area2D
class_name Loop
var rng = RandomNumberGenerator.new()
signal picked_up
func _ready():
rng.randomize()
$Sprite.self_modulate = Color.from_hsv(rng.randf_range(0.0, 1.0), 0.4, 1)
$Sprite.self_modulate = Color.from_hsv(GLOBAL.rng.randf_range(0.0, 1.0), 0.4, 1)
func _on_Loop_body_entered(body):