intro and scene switch test stuff

This commit is contained in:
Robin Hübner 2018-09-21 04:11:14 +02:00
parent cd0ed4b891
commit 43f3cf9d50
11 changed files with 73 additions and 29 deletions

1
dialog/first_scene.txt Normal file
View File

@ -0,0 +1 @@
<BRAIN> ... Looking around, it definitely wasn't time to get up just yet.

View File

@ -1,2 +1,3 @@
<BRAIN> ... You wake up to the sound of sirens blaring.
... maybe it's time to go to school?
> SWITCH_SCENE [FIRST_SCENE]

View File

@ -15,13 +15,16 @@ func _ready():
# set up params
dialog_box.set_dialog_path(dialog_path)
func _on_scene_ready():
# init after yes
dialog_box.initialize_dialog()
func _on_scene_ready():
# then entero
dialog_box.enter_frame()
func _on_dialog_init(d):
pass

14
game.gd
View File

@ -47,15 +47,22 @@ const Scenes = {
MAIN_MENU = "res://menus/main_menu.tscn",
# GAME
SCENE = "res://scene.tscn"
INTRO = "res://scenes/intro.tscn",
FIRST_SCENE = "res://scenes/first_scene.tscn"
}
func _register_functions():
pass
current_registry["SWITCH_SCENE"] = funcref(self, "_switch_scene_fnc")
func _switch_scene_fnc(args):
if args.size() == 1:
var scene_name = args[0]
SceneSwitcher.goto_scene(Scenes[scene_name])
func _on_game_started_set(v):
if v and not game_started:
print("STARTO")
_on_game_start()
game_started = v
@ -63,6 +70,9 @@ func _on_game_start():
# all game state here
current_registry = {}
print("YAH")
# register all de stuff
_register_functions()
func _ready():

View File

@ -15,7 +15,7 @@ func _ready():
func _on_start_pressed():
SceneSwitcher.goto_scene(Game.Scenes.SCENE)
SceneSwitcher.goto_scene(Game.Scenes.INTRO)
func _on_load_pressed():
pass

View File

@ -1,8 +1,15 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://menus/main_menu.gd" type="Script" id=1]
[node name="main_menu" type="Control" index="0"]
[sub_resource type="StyleBoxEmpty" id=1]
content_margin_left = -1.0
content_margin_right = -1.0
content_margin_top = -1.0
content_margin_bottom = -1.0
[node name="main_menu" type="Control"]
anchor_left = 0.0
anchor_top = 0.0
@ -87,6 +94,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_styles/focus = SubResource( 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
@ -114,6 +122,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_styles/focus = SubResource( 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
@ -141,6 +150,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_styles/focus = SubResource( 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
@ -168,6 +178,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_styles/focus = SubResource( 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )

25
scenes/first_scene.tscn Normal file
View File

@ -0,0 +1,25 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://common/scene.gd" type="Script" id=1]
[ext_resource path="res://dialog_layer.gd" type="Script" id=2]
[ext_resource path="res://ui/dialog_box.tscn" type="PackedScene" id=3]
[node name="first_scene" type="Node2D" index="0"]
script = ExtResource( 1 )
[node name="background" type="Sprite" parent="." index="0"]
[node name="dialog_layer" type="CanvasLayer" parent="." index="1"]
layer = 1
offset = Vector2( 0, 0 )
rotation = 0.0
scale = Vector2( 1, 1 )
transform = Transform2D( 1, 0, 0, 1, 0, 0 )
script = ExtResource( 2 )
dialog_path = "res://dialog/first_scene.txt"
[node name="dialog_box" parent="dialog_layer" index="0" instance=ExtResource( 3 )]

View File

@ -1,10 +1,10 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://scene.gd" type="Script" id=1]
[ext_resource path="res://common/scene.gd" type="Script" id=1]
[ext_resource path="res://dialog_layer.gd" type="Script" id=2]
[ext_resource path="res://ui/dialog_box.tscn" type="PackedScene" id=3]
[node name="scene" type="Node2D"]
[node name="intro" type="Node2D"]
script = ExtResource( 1 )

View File

@ -148,21 +148,6 @@ func _register_functions():
# anim shite, also yieldy
_register_func(r, "PLAY_ANIM", "_play_anim_fnc")
# PLAY AND WAIT; HOW ABOUT DEM APPLES
_register_func(r, "PLAY_ANIM_WITH_WAIT", "_play_wait_with_anim_fnc")
func _play_wait_with_anim_fnc(args):
if args.size() == 2:
var anim_name = args[0]
var wait_time = float(args[1])
if anim_player:
anim_player.play(anim_name)
timer.one_shot = true
timer.wait_time = wait_time
timer.start()
return [timer, "timeout"]
func _play_anim_fnc(args):
if args.size() == 1:
@ -264,7 +249,6 @@ func initialize_dialog():
func _on_dialog_completed(d):
emit_signal("on_dialog_completed", self)
exit_frame()
func _on_update_dialog(s):
_update_dialog(s)

View File

@ -1,7 +1,14 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://ui/dialog_box.gd" type="Script" id=1]
[sub_resource type="StyleBoxEmpty" id=2]
content_margin_left = -1.0
content_margin_right = -1.0
content_margin_top = -1.0
content_margin_bottom = -1.0
[sub_resource type="StyleBoxEmpty" id=1]
content_margin_left = -1.0
@ -11,7 +18,6 @@ content_margin_bottom = -1.0
[node name="dialog_box" type="Control" index="0"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
@ -66,6 +72,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_styles/focus = SubResource( 2 )
custom_colors/font_color_disabled = Color( 0.378906, 0.378906, 0.378906, 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_hover = Color( 1, 0.647059, 0, 1 )
@ -95,6 +102,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_styles/focus = SubResource( 2 )
custom_colors/font_color_disabled = Color( 0.378906, 0.378906, 0.378906, 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_hover = Color( 1, 0.647059, 0, 1 )
@ -123,6 +131,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
custom_styles/focus = SubResource( 2 )
custom_colors/font_color_disabled = Color( 0.378906, 0.378906, 0.378906, 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_hover = Color( 1, 0.647059, 0, 1 )