From 9ba66410a47430869d85ba6e1822447a82d7fb1d Mon Sep 17 00:00:00 2001 From: Anthony Foxclaw <35226681+tonytins@users.noreply.github.com> Date: Tue, 7 Apr 2020 11:47:40 -0400 Subject: [PATCH] Title screen - Title screen that lets you decide to the set the city name. Still figuring out the dropdown menu. - Made city status script --- project.godot | 4 +-- src/autoload/{bank.gd => citydata.gd} | 4 ++- src/gpanel.gd | 7 ++++ src/gui.tscn | 5 ++- src/newgame.gd | 7 ++++ src/titlescreen.tscn | 49 +++++++++++++++++++++++++++ src/world.gd | 9 ----- 7 files changed, 72 insertions(+), 13 deletions(-) rename src/autoload/{bank.gd => citydata.gd} (86%) create mode 100644 src/gpanel.gd create mode 100644 src/newgame.gd create mode 100644 src/titlescreen.tscn diff --git a/project.godot b/project.godot index 4cad026..0cf21f6 100644 --- a/project.godot +++ b/project.godot @@ -16,12 +16,12 @@ _global_script_class_icons={ [application] config/name="City Limits" -run/main_scene="res://src/world.tscn" +run/main_scene="res://src/titlescreen.tscn" config/icon="res://icon.png" [autoload] -bank="*res://src/autoload/bank.gd" +CityData="*res://src/autoload/citydata.gd" [display] diff --git a/src/autoload/bank.gd b/src/autoload/citydata.gd similarity index 86% rename from src/autoload/bank.gd rename to src/autoload/citydata.gd index 052594f..e542f62 100644 --- a/src/autoload/bank.gd +++ b/src/autoload/citydata.gd @@ -1,5 +1,7 @@ extends Node +var city_name: String + var budget: int var prev_budget: int @@ -13,7 +15,7 @@ var power_tax: int func starting_budget(lev: int): - if lev == 1: + if lev == 1 or lev == 0: budget = 20000 elif lev == 2: budget = 10000 diff --git a/src/gpanel.gd b/src/gpanel.gd new file mode 100644 index 0000000..7b5b2ed --- /dev/null +++ b/src/gpanel.gd @@ -0,0 +1,7 @@ +extends Panel + +func _ready(): + $CityMenus/CityNameLbl.text = CityData.city_name + +func _process(delta): + $CityStatus/MoneyLbl.text = str(CityData.budget) diff --git a/src/gui.tscn b/src/gui.tscn index 1f993ee..a47a90f 100644 --- a/src/gui.tscn +++ b/src/gui.tscn @@ -1,4 +1,6 @@ -[gd_scene format=2] +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/gpanel.gd" type="Script" id=2] [node name="GUI" type="Control"] anchor_right = 1.0 @@ -10,6 +12,7 @@ __meta__ = { [node name="GPanel" type="Panel" parent="."] anchor_right = 1.0 margin_bottom = 23.0 +script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false } diff --git a/src/newgame.gd b/src/newgame.gd new file mode 100644 index 0000000..99f865b --- /dev/null +++ b/src/newgame.gd @@ -0,0 +1,7 @@ +extends Control + +func _on_CreateBtn_pressed(): + var city_name = $CityNameEdit.text + CityData.city_name = city_name + + get_tree().change_scene("res://src/world.tscn") diff --git a/src/titlescreen.tscn b/src/titlescreen.tscn new file mode 100644 index 0000000..18ce1b9 --- /dev/null +++ b/src/titlescreen.tscn @@ -0,0 +1,49 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/newgame.gd" type="Script" id=1] + +[node name="SartMenu" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="."] +margin_left = 312.0 +margin_top = 235.0 +margin_right = 601.0 +margin_bottom = 249.0 +text = "Welcome to City Limits!" +align = 1 + +[node name="CityNameEdit" type="LineEdit" parent="."] +margin_left = 312.0 +margin_top = 261.0 +margin_right = 601.0 +margin_bottom = 285.0 +text = "City Name" +align = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="BudgetMenu" type="MenuButton" parent="."] +margin_left = 312.0 +margin_top = 294.0 +margin_right = 601.0 +margin_bottom = 314.0 +text = "Starting Budget" +items = [ "20000", null, 0, false, false, 0, 0, null, "", false, "10000", null, 0, false, false, 1, 0, null, "", false, "500", null, 0, false, false, 2, 0, null, "", false ] +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="CreateBtn" type="Button" parent="."] +margin_left = 312.0 +margin_top = 319.0 +margin_right = 601.0 +margin_bottom = 339.0 +text = "Create" +[connection signal="pressed" from="CreateBtn" to="." method="_on_CreateBtn_pressed"] diff --git a/src/world.gd b/src/world.gd index f975766..4dbbafc 100644 --- a/src/world.gd +++ b/src/world.gd @@ -4,17 +4,8 @@ var noise: OpenSimplexNoise var map_size = Vector2(80, 60) var terrian_cap = 0.3 -func _process(delta): - - $GUI/GPanel/CityStatus/MoneyLbl.text = str(bank.budget) - -func _input(event): - pass - func _ready(): - bank.starting_budget(1) - randomize() noise = OpenSimplexNoise.new() noise.seed = randi()