1
Fork 0
mirror of https://github.com/Steffo99/looping-for-loops.git synced 2024-10-16 06:27:28 +00:00

💥 idk, something with a main menu

This commit is contained in:
Steffo 2020-10-04 20:26:45 +02:00
parent 34900040c0
commit 008a31a3b2
28 changed files with 389 additions and 29 deletions

Binary file not shown.

View file

@ -8,6 +8,9 @@ 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

View file

@ -8,7 +8,7 @@ func set_randomize_start_position(value):
children.randomize_start_position = value
func _on_ConveyorBelt_cb_speed_changed(old, new):
func _on_ConveyorBelt_cb_speed_changed(_old, new):
for children in get_children():
children.set_cb_speed(new)

View file

@ -6,7 +6,7 @@
[ext_resource path="res://Objects/SpecialObjects/SingleScreenWalls.tscn" type="PackedScene" id=4]
[ext_resource path="res://Objects/SpecialObjects/Wrapper.tscn" type="PackedScene" id=5]
[ext_resource path="res://Objects/ScrollingObjects/ScrollingBlock.tscn" type="PackedScene" id=6]
[ext_resource path="res://Objects/ScrollingObjects/Buttons/GameButton.tscn" type="PackedScene" id=7]
[ext_resource path="res://Objects/ScrollingObjects/Loop.tscn" type="PackedScene" id=7]
[node name="Main" type="Node2D"]
__meta__ = {
@ -16,6 +16,7 @@ __meta__ = {
[node name="Conductor" parent="." instance=ExtResource( 2 )]
[node name="Wrapper" parent="." instance=ExtResource( 5 )]
total_length = 2000.0
[node name="SingleScreenWalls" parent="." instance=ExtResource( 4 )]
@ -26,13 +27,49 @@ position = Vector2( 640, 700 )
position = Vector2( 340, 500 )
[node name="ScrollingBlock" parent="." instance=ExtResource( 6 )]
position = Vector2( 700, 660 )
position = Vector2( 1140, 660 )
[node name="ScrollingBlock2" parent="." instance=ExtResource( 6 )]
position = Vector2( 840, 660 )
position = Vector2( 1140, 620 )
[node name="ScrollingBlock3" parent="." instance=ExtResource( 6 )]
position = Vector2( 980, 660 )
position = Vector2( 1140, 580 )
[node name="GameButton" parent="." instance=ExtResource( 7 )]
position = Vector2( 1000, 480 )
[node name="ScrollingBlock4" parent="." instance=ExtResource( 6 )]
position = Vector2( 1500, 660 )
[node name="ScrollingBlock5" parent="." instance=ExtResource( 6 )]
position = Vector2( 1500, 620 )
[node name="ScrollingBlock6" parent="." instance=ExtResource( 6 )]
position = Vector2( 1500, 580 )
[node name="Loop" parent="." instance=ExtResource( 7 )]
position = Vector2( 1200, 580 )
[node name="Loop2" parent="." instance=ExtResource( 7 )]
position = Vector2( 1260, 580 )
[node name="Loop3" parent="." instance=ExtResource( 7 )]
position = Vector2( 1320, 580 )
[node name="Loop4" parent="." instance=ExtResource( 7 )]
position = Vector2( 1380, 580 )
[node name="Loop5" parent="." instance=ExtResource( 7 )]
position = Vector2( 1440, 580 )
[node name="Loop6" parent="." instance=ExtResource( 7 )]
position = Vector2( 1200, 640 )
[node name="Loop7" parent="." instance=ExtResource( 7 )]
position = Vector2( 1260, 640 )
[node name="Loop8" parent="." instance=ExtResource( 7 )]
position = Vector2( 1320, 640 )
[node name="Loop9" parent="." instance=ExtResource( 7 )]
position = Vector2( 1380, 640 )
[node name="Loop10" parent="." instance=ExtResource( 7 )]
position = Vector2( 1440, 640 )

6
Objects/Menu.gd Normal file
View file

@ -0,0 +1,6 @@
extends Control
class_name Menu
func _on_Button_pressed():
get_tree().change_scene("res://Objects/Main.tscn")

83
Objects/Menu.tscn Normal file
View file

@ -0,0 +1,83 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Fonts/LiberationMono-Bold.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://Objects/Menu.gd" type="Script" id=2]
[ext_resource path="res://Resources/ryg_logo.png" type="Texture" id=3]
[sub_resource type="DynamicFont" id=1]
size = 32
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=2]
size = 256
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=3]
size = 64
font_data = ExtResource( 1 )
[node name="Menu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CenterContainer" type="CenterContainer" parent="."]
margin_right = 1280.0
margin_bottom = 160.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="CenterContainer"]
margin_left = 374.0
margin_top = 41.0
margin_right = 906.0
margin_bottom = 118.0
custom_fonts/font = SubResource( 1 )
text = "(titolo wip)
Brøther, can you give me the"
align = 1
valign = 1
[node name="CenterContainer2" type="CenterContainer" parent="."]
margin_top = 160.0
margin_right = 1280.0
margin_bottom = 480.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label2" type="Label" parent="CenterContainer2"]
margin_left = 178.0
margin_top = 14.0
margin_right = 1102.0
margin_bottom = 305.0
custom_fonts/font = SubResource( 2 )
text = "LÖÖPS?"
align = 1
valign = 1
[node name="Button" type="Button" parent="."]
margin_left = 480.0
margin_top = 520.0
margin_right = 800.0
margin_bottom = 680.0
custom_fonts/font = SubResource( 3 )
text = "Play"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="."]
margin_left = 40.0
margin_top = 520.0
margin_right = 200.0
margin_bottom = 680.0
texture = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]

View file

@ -0,0 +1,16 @@
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View file

@ -0,0 +1,14 @@
extends GameButton
class_name CBSpeedChangeButton
export(float) var change: float = -30
var conveyor_belt: ConveyorBelt = null
func _ready():
conveyor_belt = get_tree().current_scene.get_node("ConveyorBelt")
func _on_GameButton_clicked():
._on_GameButton_clicked()
conveyor_belt.cb_speed += change

View file

@ -0,0 +1,10 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Objects/ScrollingObjects/Buttons/CBSpeedChangeButton.gd" type="Script" id=1]
[ext_resource path="res://Objects/ScrollingObjects/Buttons/GameButton.tscn" type="PackedScene" id=2]
[ext_resource path="res://Sprites/button_left.png" type="Texture" id=3]
[node name="CBSpeedChangeButton" instance=ExtResource( 2 )]
script = ExtResource( 1 )
color = Color( 0.447059, 0.333333, 1, 1 )
icon = ExtResource( 3 )

View file

@ -2,11 +2,14 @@ extends Node2D
class_name GameButton
export(Color, RGB) var color: Color = Color.white setget set_color
export(Texture) var active_sprite: Texture = null
export(Texture) var pressed_sprite: Texture = null
export(Texture) var icon: Texture = null setget set_icon
export(bool) var is_active: bool = true setget set_active
var active_sprite: Texture = preload("res://Sprites/button.png")
var pressed_sprite: Texture = preload("res://Sprites/button_pressed.png")
signal clicked
@ -26,7 +29,25 @@ func set_active(value):
else:
$Sprite.texture = pressed_sprite
func activate():
set_active(true)
func deactivate():
set_active(false)
func _on_GameButton_input_event(viewport: Viewport, event: InputEvent, shape_idx: int):
func toggle():
set_active(not is_active)
func set_icon(value):
icon = value
$Icon.texture = value
func _on_GameButton_input_event(_viewport: Viewport, event: InputEvent, _shape_idx: int):
if is_active and event.is_pressed():
emit_signal("clicked")
func _on_GameButton_clicked():
deactivate()

View file

@ -1,11 +1,9 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Sprites/button.png" type="Texture" id=1]
[ext_resource path="res://Objects/ScrollingObjects/Buttons/GameButton.gd" type="Script" id=2]
[ext_resource path="res://Objects/ScrollingObjects/Utilities/ConveyorScrollParent.tscn" type="PackedScene" id=3]
[ext_resource path="res://Objects/ScrollingObjects/Utilities/WrapParent.tscn" type="PackedScene" id=4]
[ext_resource path="res://Sprites/button_pressed.png" type="Texture" id=5]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 20, 20 )
@ -14,16 +12,17 @@ extents = Vector2( 20, 20 )
collision_layer = 8
collision_mask = 2147483648
script = ExtResource( 2 )
active_sprite = ExtResource( 1 )
pressed_sprite = ExtResource( 5 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
[node name="Icon" type="Sprite" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="ConveyorScrollParent" parent="." instance=ExtResource( 3 )]
[node name="WrapParent" parent="." instance=ExtResource( 4 )]
[connection signal="clicked" from="." to="." method="_on_GameButton_clicked"]
[connection signal="input_event" from="." to="." method="_on_GameButton_input_event"]

View file

@ -0,0 +1,19 @@
extends Node2D
var chain_icons: Array = [
preload("res://Sprites/1.png"),
preload("res://Sprites/2.png"),
preload("res://Sprites/3.png")
]
func _ready():
var children: Array = get_children()
for i in len(children):
if i == 0:
children[i].set_active(true)
else:
children[i].set_active(false)
if i < len(children) - 1:
children[i].set_icon(chain_icons[i])
children[i].connect("clicked", children[i+1], "activate")

View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Objects/ScrollingObjects/Buttons/GameButtonChain.gd" type="Script" id=1]
[node name="GameButtonChain" type="Node2D"]
script = ExtResource( 1 )

View file

@ -0,0 +1,29 @@
extends Node2D
class_name GhostBlock
var active_sprite: Texture = preload("res://Sprites/ghost_block_active.png")
var inactive_sprite: Texture = preload("res://Sprites/ghost_block_inactive.png")
export(bool) var is_active: bool = true setget set_active
func _ready():
set_active(is_active)
func set_active(value):
is_active = value
$CollisionShape2D.disabled = not value
if value:
$Sprite.texture = active_sprite
else:
$Sprite.texture = inactive_sprite
func activate():
set_active(true)
func deactivate():
set_active(false)
func toggle():
set_active(not is_active)

View file

@ -0,0 +1,23 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Objects/ScrollingObjects/Ghosts/GhostBlock.gd" type="Script" id=1]
[ext_resource path="res://Sprites/ghost_block_active.png" type="Texture" id=2]
[ext_resource path="res://Objects/ScrollingObjects/Utilities/ConveyorScrollParent.tscn" type="PackedScene" id=3]
[ext_resource path="res://Objects/ScrollingObjects/Utilities/WrapParent.tscn" type="PackedScene" id=4]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 20, 20 )
[node name="GhostBlock" type="StaticBody2D"]
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="ConveyorScrollParent" parent="." instance=ExtResource( 3 )]
[node name="WrapParent" parent="." instance=ExtResource( 4 )]
position = Vector2( 20, 0 )

View file

@ -0,0 +1,19 @@
extends Node2D
func set_active(value):
for child in get_children():
child.set_active(value)
func activate():
for child in get_children():
child.activate()
func deactivate():
for child in get_children():
child.deactivate()
func toggle():
for child in get_children():
child.toggle()

View file

@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Objects/ScrollingObjects/Ghosts/GhostGroup.gd" type="Script" id=1]
[node name="GhostGroup" type="Node2D"]
script = ExtResource( 1 )

View file

@ -0,0 +1,17 @@
extends Area2D
class_name Loop
var rng = RandomNumberGenerator.new()
signal picked_up
func _ready():
rng.randomize()
$Sprite.modulate = Color.from_hsv(rng.randf_range(0.0, 1.0), 0.4, 1)
func _on_Loop_body_entered(body):
emit_signal("picked_up")
queue_free()

View file

@ -0,0 +1,27 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://Sprites/lööp.png" type="Texture" id=1]
[ext_resource path="res://Objects/ScrollingObjects/Loop.gd" type="Script" id=2]
[ext_resource path="res://Objects/ScrollingObjects/Utilities/ConveyorScrollParent.tscn" type="PackedScene" id=3]
[ext_resource path="res://Objects/ScrollingObjects/Utilities/WrapParent.tscn" type="PackedScene" id=4]
[sub_resource type="CapsuleShape2D" id=1]
radius = 5.52907
height = 4.30358
[node name="Loop" type="Area2D"]
collision_layer = 32
collision_mask = 2
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( 3 )]
[node name="WrapParent" parent="." instance=ExtResource( 4 )]
position = Vector2( 8.5, 0 )
[connection signal="body_entered" from="." to="." method="_on_Loop_body_entered"]

View file

@ -2,6 +2,5 @@
[ext_resource path="res://Objects/ScrollingObjects/Utilities/ConveyorScrollParent.gd" type="Script" id=1]
[node name="ConveyorScrollParent" type="Node"]
script = ExtResource( 1 )

View file

@ -7,6 +7,6 @@ onready var wrapper: Wrapper = get_tree().current_scene.get_node("Wrapper")
onready var absolute_position: Vector2 = parent.position
func _physics_process(delta):
func _physics_process(_delta):
if global_position.x <= 0:
parent.position.x += wrapper.total_length

View file

@ -48,7 +48,7 @@ func _ready():
play()
func _process(delta):
func _process(_delta):
var time = corrected_time()
if time - last_subbeat >= subbeat_usec():
emit_signal("subbeat", subbeat_count)

View file

@ -28,7 +28,7 @@ func up_normal():
return -gravity.normalized()
func _physics_process(delta):
func _physics_process(_delta):
var up_normal = up_normal()
var floor_normal = get_floor_normal()

BIN
Resources/ryg_logo.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/red_button.png-414b3db90d1cea22521067e11dd7d149.stex"
path="res://.import/ryg_logo.png-5605f215fbb39990d0e629bd40d12489.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/red_button.png"
dest_files=[ "res://.import/red_button.png-414b3db90d1cea22521067e11dd7d149.stex" ]
source_file="res://Resources/ryg_logo.png"
dest_files=[ "res://.import/ryg_logo.png-5605f215fbb39990d0e629bd40d12489.stex" ]
[params]

BIN
Sprites/loop.png (Stored with Git LFS)

Binary file not shown.

View file

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/loop.png-19b502405b67a3e6afb244dc5fd1a967.stex"
path="res://.import/lööp.png-1d1fc33a2c0a7331c0725497d80b0ce6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/loop.png"
dest_files=[ "res://.import/loop.png-19b502405b67a3e6afb244dc5fd1a967.stex" ]
source_file="res://Sprites/lööp.png"
dest_files=[ "res://.import/lööp.png-1d1fc33a2c0a7331c0725497d80b0ce6.stex" ]
[params]

View file

@ -14,6 +14,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://Objects/ScrollingObjects/Buzzsaw.gd"
}, {
"base": "GameButton",
"class": "CBSpeedChangeButton",
"language": "GDScript",
"path": "res://Objects/ScrollingObjects/Buttons/CBSpeedChangeButton.gd"
}, {
"base": "Node",
"class": "Conductor",
"language": "GDScript",
@ -34,6 +39,21 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://Objects/ScrollingObjects/Buttons/GameButton.gd"
}, {
"base": "Node2D",
"class": "GhostBlock",
"language": "GDScript",
"path": "res://Objects/ScrollingObjects/Ghosts/GhostBlock.gd"
}, {
"base": "Area2D",
"class": "Loop",
"language": "GDScript",
"path": "res://Objects/ScrollingObjects/Loop.gd"
}, {
"base": "Control",
"class": "Menu",
"language": "GDScript",
"path": "res://Objects/Menu.gd"
}, {
"base": "KinematicBody2D",
"class": "Player",
"language": "GDScript",
@ -61,10 +81,14 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
"Buzzsaw": "",
"CBSpeedChangeButton": "",
"Conductor": "",
"ConveyorBelt": "",
"ConveyorScrollParent": "",
"GameButton": "",
"GhostBlock": "",
"Loop": "",
"Menu": "",
"Player": "",
"Press": "",
"ScrollParent": "",
@ -75,7 +99,7 @@ _global_script_class_icons={
[application]
config/name="ld47"
run/main_scene="res://Objects/Main.tscn"
run/main_scene="res://Objects/Menu.tscn"
[display]
@ -113,6 +137,7 @@ plr_right={
2d_physics/layer_3="Conveyor Belt"
2d_physics/layer_4="Obstacles"
2d_physics/layer_5="Screen Walls"
2d_physics/layer_6="Lööps"
[rendering]