1
Fork 0
mirror of https://github.com/Steffo99/looping-for-loops.git synced 2024-11-24 17:14:22 +00:00

❇️ Add loop clock

This commit is contained in:
Steffo 2020-10-05 14:31:00 +02:00
parent 9b4c0d39f2
commit f5161186c7
4 changed files with 88 additions and 18 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=12 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]
@ -9,6 +9,7 @@
[ext_resource path="res://Objects/ScrollingObjects/Loop.tscn" type="PackedScene" id=7]
[ext_resource path="res://Objects/ScrollingObjects/Buttons/GameButton.tscn" type="PackedScene" id=8]
[ext_resource path="res://Objects/ScrollingObjects/Buttons/GameButtonChain.tscn" type="PackedScene" id=9]
[ext_resource path="res://Objects/SpecialObjects/Clock.tscn" type="PackedScene" id=10]
[ext_resource path="res://Objects/ScrollingObjects/Laser.tscn" type="PackedScene" id=11]
[node name="Main" type="Node2D"]
@ -30,55 +31,55 @@ position = Vector2( 640, 700 )
position = Vector2( 360, 640 )
[node name="ScrollingBlock" parent="." instance=ExtResource( 6 )]
position = Vector2( 1040, 480 )
position = Vector2( 660, 480 )
[node name="ScrollingBlock2" parent="." instance=ExtResource( 6 )]
position = Vector2( 1080, 480 )
position = Vector2( 700, 480 )
[node name="ScrollingBlock3" parent="." instance=ExtResource( 6 )]
position = Vector2( 920, 480 )
position = Vector2( 540, 480 )
[node name="ScrollingBlock4" parent="." instance=ExtResource( 6 )]
position = Vector2( 1000, 480 )
position = Vector2( 620, 480 )
[node name="ScrollingBlock5" parent="." instance=ExtResource( 6 )]
position = Vector2( 1120, 480 )
position = Vector2( 740, 480 )
[node name="ScrollingBlock6" parent="." instance=ExtResource( 6 )]
position = Vector2( 960, 480 )
position = Vector2( 580, 480 )
[node name="Loop" parent="." instance=ExtResource( 7 )]
position = Vector2( 1200, 580 )
position = Vector2( 520, 560 )
[node name="Loop2" parent="." instance=ExtResource( 7 )]
position = Vector2( 1260, 580 )
position = Vector2( 580, 560 )
[node name="Loop3" parent="." instance=ExtResource( 7 )]
position = Vector2( 1320, 580 )
position = Vector2( 640, 560 )
[node name="Loop4" parent="." instance=ExtResource( 7 )]
position = Vector2( 1380, 580 )
position = Vector2( 700, 560 )
[node name="Loop5" parent="." instance=ExtResource( 7 )]
position = Vector2( 1440, 580 )
position = Vector2( 760, 560 )
[node name="Loop6" parent="." instance=ExtResource( 7 )]
position = Vector2( 1200, 640 )
position = Vector2( 520, 620 )
[node name="Loop7" parent="." instance=ExtResource( 7 )]
position = Vector2( 1260, 640 )
position = Vector2( 580, 620 )
[node name="Loop8" parent="." instance=ExtResource( 7 )]
position = Vector2( 1320, 640 )
position = Vector2( 640, 620 )
[node name="Loop9" parent="." instance=ExtResource( 7 )]
position = Vector2( 1380, 640 )
position = Vector2( 700, 620 )
[node name="Loop10" parent="." instance=ExtResource( 7 )]
position = Vector2( 1440, 640 )
position = Vector2( 760, 620 )
[node name="GameButtonChain" parent="." instance=ExtResource( 9 )]
position = Vector2( 1160, 480 )
position = Vector2( 860, 660 )
[node name="GameButton" parent="GameButtonChain" instance=ExtResource( 8 )]
@ -94,4 +95,7 @@ color = Color( 0.956863, 0.196078, 0.0941176, 1 )
[node name="Laser2" parent="." instance=ExtResource( 11 )]
position = Vector2( 640, 300 )
[node name="Clock" parent="." instance=ExtResource( 10 )]
position = Vector2( 40, 40 )
[connection signal="clicked" from="GameButtonChain/GameButton4" to="Laser2" method="deactivate"]

View file

@ -0,0 +1,22 @@
extends Node2D
class_name Clock
var conveyor_belt: ConveyorBelt = null
var wrapper: Wrapper = null
var current_position: float = 0
func _ready():
conveyor_belt = get_tree().current_scene.get_node("ConveyorBelt")
wrapper = get_tree().current_scene.get_node("Wrapper")
_on_ConveyorBelt_cb_speed_changed(0, conveyor_belt.cb_speed)
conveyor_belt.connect("cb_speed_changed", self, "_on_ConveyorBelt_cb_speed_changed")
func _physics_process(delta):
current_position += delta * conveyor_belt.cb_speed
$Hand.rotation = int(current_position) % int(wrapper.total_length) / wrapper.total_length * TAU
func _on_ConveyorBelt_cb_speed_changed(old, new):
$AnimationPlayer.playback_speed = new / 400
$AnimationPlayer.play("SpinCCW")

View file

@ -0,0 +1,37 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Sprites/clock.png" type="Texture" id=1]
[ext_resource path="res://Objects/SpecialObjects/Clock.gd" type="Script" id=2]
[ext_resource path="res://Sprites/clock_lancetta.png" type="Texture" id=3]
[sub_resource type="Animation" id=1]
resource_name = "SpinCCW"
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:rotation_degrees")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, -360.0 ]
}
[node name="Clock" type="Node2D"]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
rotation = -3.50922
texture = ExtResource( 1 )
[node name="Hand" type="Sprite" parent="."]
rotation = -6.28319
texture = ExtResource( 3 )
centered = false
offset = Vector2( -5, -40 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/SpinCCW = SubResource( 1 )

View file

@ -19,6 +19,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://Objects/ScrollingObjects/Buttons/CBSpeedChangeButton.gd"
}, {
"base": "Node2D",
"class": "Clock",
"language": "GDScript",
"path": "res://Objects/SpecialObjects/Clock.gd"
}, {
"base": "Node",
"class": "Conductor",
"language": "GDScript",
@ -87,6 +92,7 @@ _global_script_classes=[ {
_global_script_class_icons={
"Buzzsaw": "",
"CBSpeedChangeButton": "",
"Clock": "",
"Conductor": "",
"ConveyorBelt": "",
"ConveyorScrollParent": "",
@ -106,6 +112,7 @@ _global_script_class_icons={
config/name="ld47"
run/main_scene="res://Objects/Menu.tscn"
config/icon="res://Sprites/clock.png"
[display]