forked from interstellar_development/freettrpg
Version: 0.0.3
Slight code fixups and changed some map stuff, Also added a stat viewer for the current player in the game itself.
This commit is contained in:
parent
8496773e69
commit
21bcce37fa
12 changed files with 115 additions and 51 deletions
23
scenes/map/map.tscn
Normal file
23
scenes/map/map.tscn
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://mie5ckydb8k5"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://brmtkn1ddxrp1" path="res://testing/test/level.tscn" id="1_sw0jh"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://btl7r0wvecyd3" path="res://scenes/menu/view.tscn" id="2_7des0"]
|
||||||
|
|
||||||
|
[node name="map" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="level" parent="." instance=ExtResource("1_sw0jh")]
|
||||||
|
|
||||||
|
[node name="characterViewer" parent="." instance=ExtResource("2_7des0")]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="back" type="Button" parent="."]
|
||||||
|
visible = false
|
||||||
|
offset_left = 512.0
|
||||||
|
offset_top = 400.0
|
||||||
|
offset_right = 638.0
|
||||||
|
offset_bottom = 435.0
|
||||||
|
scale = Vector2(2, 2)
|
||||||
|
disabled = true
|
||||||
|
text = "Back to game"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="back" to="level" method="_on_back_pressed"]
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/createStats.gd" id="1_xsj3b"]
|
[ext_resource type="Script" path="res://scripts/createStats.gd" id="1_xsj3b"]
|
||||||
|
|
||||||
[node name="character_creator" type="Control"]
|
[node name="characterCreator" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/menu.gd" id="1_xc6y7"]
|
[ext_resource type="Script" path="res://scripts/menu.gd" id="1_xc6y7"]
|
||||||
|
|
||||||
[node name="main_menu" type="Control"]
|
[node name="mainMenu" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
@ -42,7 +42,7 @@ offset_top = 432.0
|
||||||
offset_right = 592.0
|
offset_right = 592.0
|
||||||
offset_bottom = 455.0
|
offset_bottom = 455.0
|
||||||
scale = Vector2(3, 3)
|
scale = Vector2(3, 3)
|
||||||
text = "Version: 0.0.2"
|
text = "Version: 0.0.3"
|
||||||
|
|
||||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||||
[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"]
|
[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/getStats.gd" id="1_dcehj"]
|
[ext_resource type="Script" path="res://scripts/getStats.gd" id="1_dcehj"]
|
||||||
|
|
||||||
[node name="character_creator" type="Control"]
|
[node name="characterVsiewer" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var field = preload("res://scenes/menu/input-output.tscn")
|
var field = preload("res://scenes/menu/inputOutput.tscn")
|
||||||
var data:Dictionary
|
var data:Dictionary
|
||||||
|
|
||||||
func loadJSON(save_path):
|
func loadJSON(savePath):
|
||||||
if not FileAccess.file_exists(save_path):
|
if not FileAccess.file_exists(savePath):
|
||||||
return false
|
return false
|
||||||
var file_access = FileAccess.open(save_path, FileAccess.READ)
|
var fileAccess = FileAccess.open(savePath, FileAccess.READ)
|
||||||
var json_string = file_access.get_line()
|
var jsonString = fileAccess.get_line()
|
||||||
file_access.close()
|
fileAccess.close()
|
||||||
|
|
||||||
var json = JSON.new()
|
var json = JSON.new()
|
||||||
var error = json.parse(json_string)
|
var error = json.parse(jsonString)
|
||||||
if error:
|
if error:
|
||||||
print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line ", json.get_error_line())
|
print("JSON Parse Error: ", json.get_error_message(), " in ", jsonString, " at line ", json.get_error_line())
|
||||||
return false
|
return false
|
||||||
|
|
||||||
data = json.data
|
data = json.data
|
||||||
|
@ -22,33 +22,31 @@ func loadJSON(save_path):
|
||||||
func _ready():
|
func _ready():
|
||||||
if loadJSON("res://content/stats.json"):
|
if loadJSON("res://content/stats.json"):
|
||||||
for i in range(int(data.get("amount"))):
|
for i in range(int(data.get("amount"))):
|
||||||
var field_instance = field.instantiate()
|
var fieldInstance = field.instantiate()
|
||||||
add_child(field_instance)
|
add_child(fieldInstance)
|
||||||
field.resource_name = str("field_"+str(i))
|
|
||||||
for i in range(int(data.get("amount"))):
|
|
||||||
get_child(i+1).position = Vector2(16,(16+i*88))
|
get_child(i+1).position = Vector2(16,(16+i*88))
|
||||||
get_child(i+1).placeholder_text = data.get(str(i))
|
get_child(i+1).placeholder_text = data.get(str(i))
|
||||||
|
|
||||||
func saveJSON(save_path):
|
func saveJSON(savePath):
|
||||||
var save_data = {}
|
var saveData = {}
|
||||||
|
|
||||||
for i in range(int(data.get("amount"))):
|
for i in range(int(data.get("amount"))):
|
||||||
if i > 0:
|
if i > 0:
|
||||||
save_data[data.get(str(i))] = get_child(i+1).text
|
saveData[data.get(str(i))] = get_child(i+1).text
|
||||||
|
|
||||||
var json_string = JSON.stringify(save_data)
|
var jsonString = JSON.stringify(saveData)
|
||||||
|
|
||||||
var file_access = FileAccess.open(save_path, FileAccess.WRITE)
|
var fileAccess = FileAccess.open(savePath, FileAccess.WRITE)
|
||||||
if not file_access:
|
if not fileAccess:
|
||||||
print("An error happened while saving data: ", FileAccess.get_open_error())
|
print("An error happened while saving data: ", FileAccess.get_open_error())
|
||||||
return
|
return
|
||||||
|
|
||||||
file_access.store_line(json_string)
|
fileAccess.store_line(jsonString)
|
||||||
file_access.close()
|
fileAccess.close()
|
||||||
|
|
||||||
func _on_button_pressed():
|
func _on_button_pressed():
|
||||||
var save_path = str("user://player_data"+get_child(1).text+".json")
|
var savePath = str("user://player_data"+get_child(1).text+".json")
|
||||||
saveJSON(save_path)
|
saveJSON(savePath)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if Input.is_action_pressed("escape"):
|
if Input.is_action_pressed("escape"):
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var field = preload("res://scenes/menu/input-output.tscn")
|
var field = preload("res://scenes/menu/inputOutput.tscn")
|
||||||
var data:Dictionary
|
var data:Dictionary
|
||||||
var amount
|
var amount
|
||||||
|
|
||||||
func loadJSON(save_path):
|
func loadJSON(savePath):
|
||||||
if not FileAccess.file_exists(save_path):
|
if not FileAccess.file_exists(savePath):
|
||||||
return false
|
return false
|
||||||
var file_access = FileAccess.open(save_path, FileAccess.READ)
|
var fileAccess = FileAccess.open(savePath, FileAccess.READ)
|
||||||
var json_string = file_access.get_line()
|
var json_string = fileAccess.get_line()
|
||||||
file_access.close()
|
fileAccess.close()
|
||||||
|
|
||||||
var json = JSON.new()
|
var json = JSON.new()
|
||||||
var error = json.parse(json_string)
|
var error = json.parse(json_string)
|
||||||
|
@ -23,10 +23,8 @@ func loadJSON(save_path):
|
||||||
func _ready():
|
func _ready():
|
||||||
if loadJSON("res://content/stats.json"):
|
if loadJSON("res://content/stats.json"):
|
||||||
for i in range(int(data.get("amount"))):
|
for i in range(int(data.get("amount"))):
|
||||||
var field_instance = field.instantiate()
|
var fieldInstance = field.instantiate()
|
||||||
add_child(field_instance)
|
add_child(fieldInstance)
|
||||||
field.resource_name = str("field_"+str(i))
|
|
||||||
for i in range(int(data.get("amount"))):
|
|
||||||
get_child(i+1).position = Vector2(16,(16+i*88))
|
get_child(i+1).position = Vector2(16,(16+i*88))
|
||||||
get_child(i+1).placeholder_text = data.get(str(i))
|
get_child(i+1).placeholder_text = data.get(str(i))
|
||||||
if i > 0:
|
if i > 0:
|
||||||
|
@ -34,11 +32,15 @@ func _ready():
|
||||||
amount = data.get("amount")
|
amount = data.get("amount")
|
||||||
|
|
||||||
func _on_button_pressed():
|
func _on_button_pressed():
|
||||||
var save_path = str("user://player_data"+get_child(1).text+".json")
|
var savePath = str("user://player_data"+get_child(1).text+".json")
|
||||||
if loadJSON(save_path):
|
if loadJSON(savePath):
|
||||||
for i in range(int(amount)-1):
|
for i in range(int(amount)-1):
|
||||||
get_child(i+2).text = data.get(str(get_child(i+2).placeholder_text))
|
get_child(i+2).text = data.get(str(get_child(i+2).placeholder_text))
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if Input.is_action_pressed("escape"):
|
if Input.is_action_pressed("escape"):
|
||||||
get_tree().change_scene_to_file("res://scenes/menu/main.tscn")
|
get_tree().change_scene_to_file("res://scenes/menu/main.tscn")
|
||||||
|
|
||||||
|
func hideGet():
|
||||||
|
$button.visible = false
|
||||||
|
$button.disabled = true
|
||||||
|
|
|
@ -5,6 +5,7 @@ var playerIndex=0
|
||||||
var objectName
|
var objectName
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
$"../characterViewer".hideGet()
|
||||||
next()
|
next()
|
||||||
|
|
||||||
func next():
|
func next():
|
||||||
|
@ -15,3 +16,22 @@ func next():
|
||||||
get_node(objectName).start()
|
get_node(objectName).start()
|
||||||
playerIndex += 1
|
playerIndex += 1
|
||||||
|
|
||||||
|
func stats():
|
||||||
|
visible = false
|
||||||
|
$"../characterViewer".visible = true
|
||||||
|
get_node(objectName).stop()
|
||||||
|
$"../back".disabled = false
|
||||||
|
$"../back".visible = true
|
||||||
|
$"../characterViewer".get_child(1).text = str(playerIndex-1)
|
||||||
|
$"../characterViewer".get_child(1).editable = false
|
||||||
|
$"../characterViewer"._on_button_pressed()
|
||||||
|
|
||||||
|
func restart():
|
||||||
|
visible = true
|
||||||
|
$"../characterViewer".visible = false
|
||||||
|
get_node(objectName).start()
|
||||||
|
$"../back".disabled = true
|
||||||
|
$"../back".visible = false
|
||||||
|
|
||||||
|
func _on_back_pressed():
|
||||||
|
restart()
|
||||||
|
|
|
@ -3,7 +3,7 @@ extends Node
|
||||||
|
|
||||||
|
|
||||||
func _on_button_pressed():
|
func _on_button_pressed():
|
||||||
get_tree().change_scene_to_file("res://testing/test/map.tscn")
|
get_tree().change_scene_to_file("res://scenes/map/map.tscn")
|
||||||
|
|
||||||
|
|
||||||
func _on_button_2_pressed():
|
func _on_button_2_pressed():
|
||||||
|
|
|
@ -18,8 +18,7 @@ func _physics_process(delta):
|
||||||
distanceTo += position.distance_to(toCalculate)
|
distanceTo += position.distance_to(toCalculate)
|
||||||
print(distanceTo)
|
print(distanceTo)
|
||||||
if distanceTo > 500 and active:
|
if distanceTo > 500 and active:
|
||||||
active = false
|
stop()
|
||||||
$camera.enabled = false
|
|
||||||
distanceTo = 0
|
distanceTo = 0
|
||||||
get_parent().next()
|
get_parent().next()
|
||||||
|
|
||||||
|
@ -27,4 +26,14 @@ func _physics_process(delta):
|
||||||
func start():
|
func start():
|
||||||
$camera.enabled = true
|
$camera.enabled = true
|
||||||
active = true
|
active = true
|
||||||
|
$stats.disabled = false
|
||||||
|
$stats.visible = true
|
||||||
|
|
||||||
|
func stop():
|
||||||
|
$camera.enabled = false
|
||||||
|
active = false
|
||||||
|
$stats.disabled = true
|
||||||
|
$stats.visible = false
|
||||||
|
|
||||||
|
func _on_stats_pressed():
|
||||||
|
get_parent().stats()
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -17,3 +17,15 @@ shape = SubResource("RectangleShape2D_kf6qt")
|
||||||
|
|
||||||
[node name="camera" type="Camera2D" parent="."]
|
[node name="camera" type="Camera2D" parent="."]
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
|
[node name="stats" type="Button" parent="."]
|
||||||
|
visible = false
|
||||||
|
offset_left = 112.0
|
||||||
|
offset_top = 152.0
|
||||||
|
offset_right = 238.0
|
||||||
|
offset_bottom = 187.0
|
||||||
|
scale = Vector2(2, 2)
|
||||||
|
disabled = true
|
||||||
|
text = "Stats"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="stats" to="." method="_on_stats_pressed"]
|
||||||
|
|
Loading…
Reference in a new issue