added main menu and mm script
added main menu into game scene added input action for pausing commented on some sections of wiper.gdmaster
parent
1756b73824
commit
3758447ce6
@ -0,0 +1,199 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/MainMenu.gd" type="Script" id=1]
|
||||
[ext_resource path="res://textures/white_pixel.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="Shader" id=1]
|
||||
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform float blur : hint_range(0, 5);
|
||||
|
||||
void fragment() {
|
||||
COLOR = textureLod(SCREEN_TEXTURE, SCREEN_UV, blur);
|
||||
}"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=2]
|
||||
|
||||
render_priority = 0
|
||||
shader = SubResource( 1 )
|
||||
shader_param/blur = 1.986
|
||||
_sections_unfolded = [ "shader_param" ]
|
||||
|
||||
[node name="Menu" type="CanvasLayer"]
|
||||
|
||||
pause_mode = 2
|
||||
layer = 1
|
||||
offset = Vector2( 0, 0 )
|
||||
rotation = 0.0
|
||||
scale = Vector2( 1, 1 )
|
||||
transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Tween" type="Tween" parent="." index="0"]
|
||||
|
||||
repeat = false
|
||||
playback_process_mode = 1
|
||||
playback_speed = 1.0
|
||||
playback/active = false
|
||||
playback/repeat = false
|
||||
playback/speed = 1.0
|
||||
|
||||
[node name="blur" type="TextureRect" parent="." index="1"]
|
||||
|
||||
show_behind_parent = true
|
||||
material = SubResource( 2 )
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
texture = ExtResource( 2 )
|
||||
expand = true
|
||||
stretch_mode = 0
|
||||
_sections_unfolded = [ "Material" ]
|
||||
|
||||
[node name="MenuElements" type="Container" parent="." index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
|
||||
[node name="Label" type="Label" parent="MenuElements" index="0"]
|
||||
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -190.0
|
||||
margin_top = -212.0
|
||||
margin_right = -150.0
|
||||
margin_bottom = -198.0
|
||||
rect_scale = Vector2( 10, 10 )
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 4
|
||||
text = "Wiper"
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
_sections_unfolded = [ "Rect" ]
|
||||
|
||||
[node name="buttons" type="VBoxContainer" parent="MenuElements" index="1"]
|
||||
|
||||
editor/display_folded = true
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 288.0
|
||||
margin_top = 280.0
|
||||
margin_right = 763.0
|
||||
margin_bottom = 462.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 1
|
||||
_sections_unfolded = [ "Size Flags" ]
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
||||
|
||||
[node name="StartBtn" type="Button" parent="MenuElements/buttons" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 475.0
|
||||
margin_bottom = 58.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Start"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="AutoBtn" type="Button" parent="MenuElements/buttons" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 62.0
|
||||
margin_right = 475.0
|
||||
margin_bottom = 120.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Chill Mode"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="QuitBtn" type="Button" parent="MenuElements/buttons" index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 124.0
|
||||
margin_right = 475.0
|
||||
margin_bottom = 182.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Quit"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[connection signal="tween_completed" from="Tween" to="." method="_on_tween_completed"]
|
||||
|
||||
[connection signal="pressed" from="MenuElements/buttons/StartBtn" to="." method="_on_StartBtn_pressed"]
|
||||
|
||||
[connection signal="pressed" from="MenuElements/buttons/AutoBtn" to="." method="_on_AutoBtn_pressed"]
|
||||
|
||||
[connection signal="pressed" from="MenuElements/buttons/QuitBtn" to="." method="_on_QuitBtn_pressed"]
|
||||
|
||||
|
@ -0,0 +1,95 @@
|
||||
extends CanvasLayer
|
||||
|
||||
#-------------------------------
|
||||
# node refs
|
||||
|
||||
onready var _tweener = $Tween
|
||||
|
||||
#-------------------------------
|
||||
# constants
|
||||
|
||||
const _OffScreen = Vector2(0, -600)
|
||||
const _OnScreen = Vector2(0, 0)
|
||||
|
||||
#-------------------------------
|
||||
# vars
|
||||
|
||||
var _autoplay_mode
|
||||
var _started = false
|
||||
|
||||
#-------------------------------
|
||||
# signals
|
||||
|
||||
signal started
|
||||
|
||||
#-------------------------------
|
||||
# overloaded functions
|
||||
|
||||
func _ready():
|
||||
connect("started", self, "_on_game_start")
|
||||
|
||||
#-------------------------------
|
||||
# functions
|
||||
|
||||
# toggles the paused state of the game
|
||||
func toggle_pause():
|
||||
if is_paused():
|
||||
_unpause()
|
||||
_tween_screen_off()
|
||||
else:
|
||||
_pause()
|
||||
_tween_screen_on()
|
||||
|
||||
# pauses the game
|
||||
func _pause():
|
||||
get_tree().set_paused(true)
|
||||
|
||||
# unpauses the game
|
||||
func _unpause():
|
||||
get_tree().set_paused(false)
|
||||
|
||||
# returns the current paused state
|
||||
func is_paused():
|
||||
return get_tree().paused
|
||||
|
||||
# callback to start the game
|
||||
# TODO: make this better....
|
||||
# like actually have a check inside of
|
||||
# some main game function to have it start playing
|
||||
func _on_game_start():
|
||||
GameState.AutoPlay = _autoplay_mode
|
||||
_started = true
|
||||
|
||||
# callback for emitting the signal that the game has started
|
||||
func _on_tween_completed(object, key):
|
||||
if not _started:
|
||||
emit_signal("started")
|
||||
|
||||
|
||||
# handles the start button being pressed
|
||||
func _on_StartBtn_pressed():
|
||||
_autoplay_mode = false
|
||||
_tween_screen_off()
|
||||
|
||||
# handles the 'auto' button being pressed
|
||||
func _on_AutoBtn_pressed():
|
||||
_autoplay_mode = true
|
||||
_tween_screen_off()
|
||||
|
||||
# handles the quit button being pressed
|
||||
func _on_QuitBtn_pressed():
|
||||
get_tree().quit()
|
||||
|
||||
# helper func to tween the menu off the screen
|
||||
func _tween_screen_off():
|
||||
_tweener.interpolate_property(self, "offset", offset, _OffScreen,
|
||||
3, Tween.TRANS_QUART, Tween.EASE_IN_OUT)
|
||||
_tweener.start()
|
||||
|
||||
# helper func to tween the menu on to the screen
|
||||
func _tween_screen_on():
|
||||
_tweener.interpolate_property(self, "offset", offset, _OnScreen,
|
||||
3, Tween.TRANS_QUART, Tween.EASE_IN_OUT)
|
||||
_tweener.start()
|
||||
|
||||
|
Loading…
Reference in New Issue