Splash screen at start, GUI refactoring

master
Luke Hubmayer-Werner 2020-04-20 23:45:33 +09:30
parent 97b0946c06
commit afa41007bf
17 changed files with 407 additions and 230 deletions

View File

@ -21,12 +21,14 @@ var cursor_sprites = [
]
func _draw():
var p1_s = $"/root/Main".p1_selection
var x_offsets = [0, 16, 28, 44, 68, 96, 128, 164]
var pos1 = Vector2(x_offsets[p1_s]+4, 336)
var p1_s_rect = $Hotbar.get_child(p1_s).get_global_rect()
var pos1 = p1_s_rect.position + Vector2(p1_s_rect.size.x/2-4, -7 + sin(OS.get_ticks_msec()*TAU*0.001))
draw_texture(cursor, pos1, Color.yellow)
if p1_s > 0:
var mouse_pos = get_viewport().get_mouse_position()
if $Hotbar.get_rect().has_point(mouse_pos):
return
mouse_pos = Vector2(floor(mouse_pos.x/8)*8, floor(mouse_pos.y/8)*8)
draw_texture(cursor_sprites[p1_s], mouse_pos, Color(0.75, 0.75, 0.75, 0.75))
@ -34,9 +36,9 @@ func _draw():
func _input(event):
if event is InputEventMouseButton and event.pressed:
if event.button_mask & BUTTON_MASK_LEFT:
if $HBoxContainer.get_rect().has_point(event.position):
if $Hotbar.get_rect().has_point(event.position):
for i in 8:
if $HBoxContainer.get_child(i).get_global_rect().has_point(event.position):
if $Hotbar.get_child(i).get_global_rect().has_point(event.position):
$"/root/Main".p1_selection = i
break
elif event is InputEventMouseMotion:

131
Hotbar.tscn 100644
View File

@ -0,0 +1,131 @@
[gd_scene load_steps=14 format=2]
[ext_resource path="res://assets/sprites/smelter.tres" type="Texture" id=1]
[ext_resource path="res://assets/sprites/welder.tres" type="Texture" id=2]
[ext_resource path="res://assets/sprites/lathe.tres" type="Texture" id=3]
[ext_resource path="res://assets/sprites/forge.tres" type="Texture" id=4]
[ext_resource path="res://bgm_slider.gd" type="Script" id=5]
[ext_resource path="res://assets/sprites/cursor_16.tres" type="Texture" id=6]
[ext_resource path="res://assets/sprites/channel.tres" type="Texture" id=7]
[ext_resource path="res://assets/sprites/belt.tres" type="Texture" id=8]
[ext_resource path="res://assets/sprites/2x2belt.tres" type="Texture" id=9]
[ext_resource path="res://assets/UI_Hotbar_Label.tres" type="DynamicFont" id=10]
[ext_resource path="res://assets/sprites/downarrow.png" type="Texture" id=11]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.117647, 0.117647, 0.117647, 1 )
border_width_left = 8
border_width_top = 2
border_width_right = 8
border_width_bottom = 2
border_color = Color( 0.654902, 0.654902, 0.654902, 1 )
corner_detail = 2
shadow_size = 2
[sub_resource type="StyleBoxFlat" id=2]
bg_color = Color( 0.74902, 0.709804, 0.976471, 1 )
[node name="Hotbar" type="HBoxContainer"]
show_behind_parent = true
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
grow_vertical = 0
size_flags_horizontal = 3
size_flags_vertical = 4
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="Cursor" type="TextureRect" parent="."]
show_behind_parent = true
margin_right = 16.0
margin_bottom = 16.0
texture = ExtResource( 6 )
[node name="Belt" type="TextureRect" parent="."]
show_behind_parent = true
margin_left = 20.0
margin_right = 28.0
margin_bottom = 16.0
texture = ExtResource( 8 )
[node name="Channel" type="TextureRect" parent="."]
show_behind_parent = true
margin_left = 32.0
margin_right = 40.0
margin_bottom = 16.0
texture = ExtResource( 7 )
[node name="Widebelt" type="TextureRect" parent="."]
show_behind_parent = true
margin_left = 44.0
margin_right = 60.0
margin_bottom = 16.0
texture = ExtResource( 9 )
[node name="Smelter" type="TextureRect" parent="."]
show_behind_parent = true
margin_left = 64.0
margin_right = 88.0
margin_bottom = 16.0
texture = ExtResource( 1 )
[node name="Forge" type="TextureRect" parent="."]
show_behind_parent = true
margin_left = 92.0
margin_right = 116.0
margin_bottom = 16.0
texture = ExtResource( 4 )
[node name="Lathe" type="TextureRect" parent="."]
show_behind_parent = true
margin_left = 120.0
margin_right = 152.0
margin_bottom = 16.0
texture = ExtResource( 3 )
[node name="Welder" type="TextureRect" parent="."]
show_behind_parent = true
margin_left = 156.0
margin_right = 188.0
margin_bottom = 16.0
texture = ExtResource( 2 )
[node name="BGMSlider" type="HBoxContainer" parent="."]
show_behind_parent = true
margin_left = 192.0
margin_right = 480.0
margin_bottom = 16.0
size_flags_horizontal = 3
size_flags_vertical = 4
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="BGMSlider"]
show_behind_parent = true
margin_right = 25.0
margin_bottom = 16.0
custom_fonts/font = ExtResource( 10 )
custom_constants/line_spacing = -1
text = "BGM"
[node name="HSlider" type="HSlider" parent="BGMSlider"]
show_behind_parent = true
margin_left = 29.0
margin_top = 5.0
margin_right = 288.0
margin_bottom = 10.0
size_flags_horizontal = 3
size_flags_vertical = 4
custom_icons/grabber_disabled = ExtResource( 11 )
custom_icons/grabber_highlight = ExtResource( 11 )
custom_icons/grabber = ExtResource( 11 )
custom_styles/slider = SubResource( 1 )
custom_styles/grabber_area = SubResource( 2 )
max_value = 1.0
step = 0.01
value = 0.5
script = ExtResource( 5 )

28
Main.gd
View File

@ -1,6 +1,8 @@
extends Node2D
var p1_selection = 0
var map1 = preload("res://maps/Map1.tscn")
var crosshair_16 = preload("res://assets/sprites/cursor_16.tres")
var crosshair_32 = preload("res://assets/sprites/cursor_32.tres")
var crosshair_48 = preload("res://assets/sprites/cursor_48.tres")
@ -20,3 +22,29 @@ func update_cursor(size):
3:
Input.set_custom_mouse_cursor(crosshair_64, Input.CURSOR_ARROW, Vector2(32, 32))
var game_starting_tween = null
func _on_MainSplash_start_pressed():
if not game_starting_tween:
start_game()
const splash_scroll_time = 0.67
func start_game():
game_starting_tween = Tween.new()
add_child(game_starting_tween)
game_starting_tween.interpolate_property($"GUI/MainSplash", "anchor_top", 0, 1, splash_scroll_time)
game_starting_tween.interpolate_property($"GUI/MainSplash", "anchor_bottom", 1, 2, splash_scroll_time)
game_starting_tween.interpolate_property($"GUI/Hotbar", "anchor_top", 2, 1, splash_scroll_time)
game_starting_tween.interpolate_property($"GUI/Hotbar", "anchor_bottom", 2, 1, splash_scroll_time)
game_starting_tween.start()
var timer = get_tree().create_timer(splash_scroll_time)
timer.connect("timeout", self, "remove_splash")
add_child_below_node($bgm, map1.instance())
func remove_splash():
remove_child(game_starting_tween)
game_starting_tween.queue_free()
game_starting_tween = null
var splash = $"GUI/MainSplash"
$GUI.remove_child(splash)
splash.queue_free()

195
Main.tscn

File diff suppressed because one or more lines are too long

9
MainSplash.gd 100644
View File

@ -0,0 +1,9 @@
extends Control
signal start_pressed
func _ready():
pass
func _on_StartButton_pressed():
emit_signal("start_pressed")

View File

@ -1,54 +1,59 @@
[gd_scene load_steps=18 format=2]
[gd_scene load_steps=23 format=2]
[ext_resource path="res://FranticFactoryLogo.png" type="Texture" id=1]
[ext_resource path="res://assets/UI_Start_Button.tres" type="DynamicFont" id=2]
[ext_resource path="res://assets/styles/MainSplashButton.tres" type="StyleBox" id=3]
[ext_resource path="res://assets/styles/MainSplashButtonYellow.tres" type="StyleBox" id=4]
[ext_resource path="res://assets/styles/MainSplashButtonBlack.tres" type="StyleBox" id=5]
[ext_resource path="res://MainSplash.gd" type="Script" id=6]
[sub_resource type="VisualShaderNodeInput" id=6]
[sub_resource type="VisualShaderNodeInput" id=1]
input_name = "color"
[sub_resource type="VisualShaderNodeColorOp" id=7]
[sub_resource type="VisualShaderNodeColorOp" id=2]
output_port_for_preview = 0
operator = 2
[sub_resource type="VisualShaderNodeScalarFunc" id=8]
[sub_resource type="VisualShaderNodeScalarFunc" id=3]
output_port_for_preview = 0
function = 0
[sub_resource type="VisualShaderNodeScalarOp" id=9]
[sub_resource type="VisualShaderNodeScalarOp" id=4]
[sub_resource type="VisualShaderNodeScalarFunc" id=10]
[sub_resource type="VisualShaderNodeScalarFunc" id=5]
output_port_for_preview = 0
function = 12
[sub_resource type="VisualShaderNodeScalarOp" id=11]
[sub_resource type="VisualShaderNodeScalarOp" id=6]
default_input_values = [ 0, 0.0, 1, 0.15708 ]
operator = 2
[sub_resource type="VisualShaderNodeInput" id=12]
[sub_resource type="VisualShaderNodeInput" id=7]
input_name = "time"
[sub_resource type="VisualShaderNodeInput" id=13]
[sub_resource type="VisualShaderNodeInput" id=8]
input_name = "screen_uv"
[sub_resource type="VisualShaderNodeScalarOp" id=14]
[sub_resource type="VisualShaderNodeScalarOp" id=9]
operator = 1
[sub_resource type="VisualShaderNodeVectorDecompose" id=15]
[sub_resource type="VisualShaderNodeVectorDecompose" id=10]
[sub_resource type="VisualShaderNodeScalarOp" id=16]
[sub_resource type="VisualShaderNodeScalarOp" id=11]
[sub_resource type="VisualShaderNodeScalarFunc" id=17]
[sub_resource type="VisualShaderNodeScalarFunc" id=12]
function = 17
[sub_resource type="VisualShaderNodeScalarOp" id=18]
[sub_resource type="VisualShaderNodeScalarOp" id=13]
output_port_for_preview = 0
default_input_values = [ 0, 0.0, 1, 0.33 ]
operator = 9
[sub_resource type="VisualShaderNodeScalarOp" id=19]
[sub_resource type="VisualShaderNodeScalarOp" id=14]
default_input_values = [ 0, 0.0, 1, 20.0 ]
operator = 2
[sub_resource type="VisualShader" id=20]
[sub_resource type="VisualShader" id=15]
code = "shader_type canvas_item;
@ -118,50 +123,51 @@ void light() {
mode = 1
flags/light_only = false
nodes/fragment/0/position = Vector2( 1120, 20 )
nodes/fragment/2/node = SubResource( 12 )
nodes/fragment/2/node = SubResource( 7 )
nodes/fragment/2/position = Vector2( 20, 220 )
nodes/fragment/3/node = SubResource( 13 )
nodes/fragment/3/node = SubResource( 8 )
nodes/fragment/3/position = Vector2( 0, 60 )
nodes/fragment/4/node = SubResource( 14 )
nodes/fragment/4/node = SubResource( 9 )
nodes/fragment/4/position = Vector2( 220, 40 )
nodes/fragment/5/node = SubResource( 15 )
nodes/fragment/5/node = SubResource( 10 )
nodes/fragment/5/position = Vector2( 0, 120 )
nodes/fragment/6/node = SubResource( 16 )
nodes/fragment/6/node = SubResource( 11 )
nodes/fragment/6/position = Vector2( 500, 160 )
nodes/fragment/7/node = SubResource( 17 )
nodes/fragment/7/node = SubResource( 12 )
nodes/fragment/7/position = Vector2( 620, 80 )
nodes/fragment/8/node = SubResource( 18 )
nodes/fragment/8/node = SubResource( 13 )
nodes/fragment/8/position = Vector2( 800, 80 )
nodes/fragment/9/node = SubResource( 19 )
nodes/fragment/9/node = SubResource( 14 )
nodes/fragment/9/position = Vector2( 380, 40 )
nodes/fragment/10/node = SubResource( 6 )
nodes/fragment/10/node = SubResource( 1 )
nodes/fragment/10/position = Vector2( 780, 20 )
nodes/fragment/11/node = SubResource( 7 )
nodes/fragment/11/node = SubResource( 2 )
nodes/fragment/11/position = Vector2( 960, 20 )
nodes/fragment/12/node = SubResource( 8 )
nodes/fragment/12/node = SubResource( 3 )
nodes/fragment/12/position = Vector2( 180, 300 )
nodes/fragment/13/node = SubResource( 9 )
nodes/fragment/13/node = SubResource( 4 )
nodes/fragment/13/position = Vector2( 320, 180 )
nodes/fragment/14/node = SubResource( 10 )
nodes/fragment/14/node = SubResource( 5 )
nodes/fragment/14/position = Vector2( 360, 320 )
nodes/fragment/15/node = SubResource( 11 )
nodes/fragment/15/node = SubResource( 6 )
nodes/fragment/15/position = Vector2( 20, 280 )
nodes/fragment/connections = PoolIntArray( 5, 0, 4, 0, 5, 1, 4, 1, 6, 0, 7, 0, 7, 0, 8, 0, 4, 0, 9, 0, 10, 0, 11, 0, 8, 0, 11, 1, 11, 0, 0, 0, 3, 0, 5, 0, 2, 0, 13, 0, 9, 0, 6, 0, 13, 0, 6, 1, 12, 0, 14, 0, 14, 0, 8, 1, 12, 0, 13, 1, 15, 0, 12, 0, 2, 0, 15, 0 )
[sub_resource type="ShaderMaterial" id=21]
shader = SubResource( 20 )
[sub_resource type="ShaderMaterial" id=16]
shader = SubResource( 15 )
[node name="MainSplash" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource( 6 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ColorRect" type="ColorRect" parent="."]
material = SubResource( 21 )
material = SubResource( 16 )
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 1, 1, 0, 1 )
@ -182,3 +188,25 @@ stretch_mode = 6
__meta__ = {
"_edit_use_anchors_": false
}
[node name="StartButton" type="Button" parent="."]
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -50.0
margin_top = -40.0
margin_right = 50.0
margin_bottom = -10.0
focus_mode = 0
custom_styles/hover = ExtResource( 3 )
custom_styles/pressed = ExtResource( 4 )
custom_styles/normal = ExtResource( 5 )
custom_fonts/font = ExtResource( 2 )
shortcut_in_tooltip = false
text = "Start Game"
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[connection signal="pressed" from="StartButton" to="." method="_on_StartButton_pressed"]

View File

@ -0,0 +1,9 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/NotoSans.tres" type="DynamicFontData" id=1]
[resource]
size = 11
outline_size = 1
outline_color = Color( 0, 0, 0, 1 )
font_data = ExtResource( 1 )

View File

@ -0,0 +1,9 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/NotoSans.tres" type="DynamicFontData" id=1]
[resource]
size = 15
outline_size = 1
outline_color = Color( 0, 0, 0, 1 )
font_data = ExtResource( 1 )

View File

@ -0,0 +1,15 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
bg_color = Color( 1, 1, 0, 0.596078 )
border_width_left = 7
border_width_top = 7
border_width_right = 7
border_width_bottom = 7
border_color = Color( 1, 1, 0, 1 )
border_blend = true
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
shadow_size = 4

View File

@ -0,0 +1,15 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
bg_color = Color( 0, 0, 0, 1 )
border_width_left = 7
border_width_top = 7
border_width_right = 7
border_width_bottom = 7
border_color = Color( 1, 1, 0, 1 )
border_blend = true
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
shadow_size = 4

View File

@ -0,0 +1,15 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
bg_color = Color( 1, 1, 0, 0.882353 )
border_width_left = 7
border_width_top = 7
border_width_right = 7
border_width_bottom = 7
border_color = Color( 1, 1, 0, 1 )
border_blend = true
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
shadow_size = 4

View File

@ -7,7 +7,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="build/web/Frantic Factory.html"
export_path="build/web/FranticFactory.html"
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""

View File

@ -13,7 +13,7 @@ onready var width = rect.size.x
onready var height = rect.size.y
onready var w_cells = width/8
onready var h_cells = height/8
onready var beltmap = $"/root/Main/TileMap/BeltTiles"
onready var beltmap = $"../../BeltTiles"
var surrounding_tilename_indices
var surrounding_tilename_indices_internal
var surrounding_tilename_indices_dir
@ -116,7 +116,7 @@ func output():
product.rotation_degrees = dir_angles[surrounding_tilename_indices_dir[i]]
outpos -= dir_vectors[surrounding_tilename_indices_dir[i]] # Hack to make feed exit work
product.leave_machine(self, outpos)
$"/root/Main/TileMap/Objects".add_child(product)
$"../../Objects".add_child(product)
return
func set_working(state):

90
maps/Map1.tscn 100644

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@ var leaving_machine = null
var feed_position: Vector2
var held = false
var grabbed_vector = null
onready var beltmap = $"/root/Main/TileMap/BeltTiles"
onready var beltmap = $"../../BeltTiles"
var dir_vectors = [Vector2(1,0), Vector2(0,-1), Vector2(-1,0), Vector2(0,1)]
@ -51,7 +51,8 @@ func _physics_process(delta):
var belt_speed = 8
if entering_machine:
move_and_slide(position.direction_to(feed_position) * belt_speed)
# move_and_slide(position.direction_to(feed_position) * belt_speed) # Don't want it getting stuck on other feed objects
position += (position.direction_to(feed_position) * belt_speed * delta)
if position.distance_to(feed_position) <= 1.0:
entering_machine.feed(self)
return

View File

@ -8,7 +8,7 @@ func spawn_ore():
var product = Constants.MATERIAL_SCENES[Constants.MATERIAL_TYPE.iORE].instance()
var outpos = position
product.position = outpos
$"/root/Main/TileMap/Objects".add_child(product)
$"../../Objects".add_child(product)
func _on_Timer_timeout():

View File

@ -38,6 +38,10 @@ window/size/height=360
window/stretch/mode="2d"
window/stretch/aspect="keep"
[gui]
theme/use_hidpi=true
[physics]
2d/default_gravity=0