Revert from public gitea to normal one. Also added fps counter
This commit is contained in:
parent
359613895b
commit
217d4b27a1
14
Global.gd
14
Global.gd
@ -6,6 +6,8 @@ var player_inventory_items = []
|
|||||||
var river_intersection_home_2 = preload("res://river_intersection_home2.tscn").instance()
|
var river_intersection_home_2 = preload("res://river_intersection_home2.tscn").instance()
|
||||||
var inventory_screen = preload("res://MiscScenes/Inventory.tscn").instance()
|
var inventory_screen = preload("res://MiscScenes/Inventory.tscn").instance()
|
||||||
var current_scene = null
|
var current_scene = null
|
||||||
|
var current_camera = null
|
||||||
|
var dev_stats = true
|
||||||
|
|
||||||
func AddInventoryItem(itemid, amount):
|
func AddInventoryItem(itemid, amount):
|
||||||
for x in range(40):
|
for x in range(40):
|
||||||
@ -21,7 +23,6 @@ func AddInventoryItem(itemid, amount):
|
|||||||
player_inventory_items[x].shortdesc = "desc"
|
player_inventory_items[x].shortdesc = "desc"
|
||||||
player_inventory_items[x].item_id = itemid
|
player_inventory_items[x].item_id = itemid
|
||||||
player_inventory_items[x].amount = amount
|
player_inventory_items[x].amount = amount
|
||||||
return
|
|
||||||
|
|
||||||
func GoToScene(scene):
|
func GoToScene(scene):
|
||||||
if current_scene != null:
|
if current_scene != null:
|
||||||
@ -30,12 +31,10 @@ func GoToScene(scene):
|
|||||||
"river_intersection_home_2":
|
"river_intersection_home_2":
|
||||||
current_scene = river_intersection_home_2
|
current_scene = river_intersection_home_2
|
||||||
get_tree().get_root().add_child(river_intersection_home_2)
|
get_tree().get_root().add_child(river_intersection_home_2)
|
||||||
#.change_scene_to(river_intersection_home_2)
|
|
||||||
"inventory_screen":
|
"inventory_screen":
|
||||||
current_scene = inventory_screen
|
current_scene = inventory_screen
|
||||||
get_tree().get_root().add_child(inventory_screen)
|
get_tree().get_root().add_child(inventory_screen)
|
||||||
|
|
||||||
|
|
||||||
func LoadSave():
|
func LoadSave():
|
||||||
Database.OpenConnection()
|
Database.OpenConnection()
|
||||||
|
|
||||||
@ -46,3 +45,12 @@ func _ready():
|
|||||||
get_tree().get_root().add_child(river_intersection_home_2)
|
get_tree().get_root().add_child(river_intersection_home_2)
|
||||||
get_tree().get_root().add_child(inventory_screen)
|
get_tree().get_root().add_child(inventory_screen)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func Log(msg, level=1):
|
||||||
|
match level:
|
||||||
|
1:
|
||||||
|
print("[Log]" + msg)
|
||||||
|
2:
|
||||||
|
print("[Warn]" + msg)
|
||||||
|
3:
|
||||||
|
print("[Err]" + msg)
|
||||||
|
@ -28,6 +28,7 @@ func _physics_process(delta):
|
|||||||
velocity.x = 0
|
velocity.x = 0
|
||||||
velocity.y = 0
|
velocity.y = 0
|
||||||
move_and_slide(velocity, Vector2(0, -1))
|
move_and_slide(velocity, Vector2(0, -1))
|
||||||
|
Global.current_camera.Update()
|
||||||
# if(interaction.get_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y)) == -1):
|
# if(interaction.get_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y)) == -1):
|
||||||
# interaction.clear()
|
# interaction.clear()
|
||||||
# interaction.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), 0)
|
# interaction.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), 0)
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
extends Node2D
|
|
||||||
|
|
||||||
#func _draw():
|
|
||||||
# var center = Vector2(200, 200)
|
|
||||||
# var radius = 80
|
|
||||||
# var angle_from = 75
|
|
||||||
# var angle_to = 195
|
|
||||||
# var color = Color(1.0, 0.0, 0.0)
|
|
||||||
# draw_circle_arc(center, radius, angle_from, angle_to, color)
|
|
||||||
#
|
|
||||||
#func draw_circle_arc(center, radius, angle_from, angle_to, color):
|
|
||||||
# var nb_points = 32
|
|
||||||
# var points_arc = PoolVector2Array()
|
|
||||||
#
|
|
||||||
# for i in range(nb_points + 1):
|
|
||||||
# var angle_point = deg2rad(angle_from + i * (angle_to-angle_from) / nb_points - 90)
|
|
||||||
# points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius)
|
|
||||||
#
|
|
||||||
# for index_point in range(nb_points):
|
|
||||||
# draw_line(points_arc[index_point], points_arc[index_point + 1], color)
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
#func _process(delta):
|
|
||||||
# pass
|
|
@ -2,12 +2,42 @@
|
|||||||
|
|
||||||
[ext_resource path="res://pictures/gui/backgrounds/inventory/inventory_background.png" type="Texture" id=1]
|
[ext_resource path="res://pictures/gui/backgrounds/inventory/inventory_background.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://Scenes/Inventory_Script.gd" type="Script" id=2]
|
[ext_resource path="res://Scenes/Inventory_Script.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://Scenes/Inventory.gd" type="Script" id=3]
|
|
||||||
[ext_resource path="res://Scenes/TextureRect2.gd" type="Script" id=4]
|
[ext_resource path="res://Scenes/TextureRect2.gd" type="Script" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id=1]
|
||||||
|
script/source = "extends Node2D
|
||||||
|
|
||||||
|
#func _draw():
|
||||||
|
# var center = Vector2(200, 200)
|
||||||
|
# var radius = 80
|
||||||
|
# var angle_from = 75
|
||||||
|
# var angle_to = 195
|
||||||
|
# var color = Color(1.0, 0.0, 0.0)
|
||||||
|
# draw_circle_arc(center, radius, angle_from, angle_to, color)
|
||||||
|
#
|
||||||
|
#func draw_circle_arc(center, radius, angle_from, angle_to, color):
|
||||||
|
# var nb_points = 32
|
||||||
|
# var points_arc = PoolVector2Array()
|
||||||
|
#
|
||||||
|
# for i in range(nb_points + 1):
|
||||||
|
# var angle_point = deg2rad(angle_from + i * (angle_to-angle_from) / nb_points - 90)
|
||||||
|
# points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius)
|
||||||
|
#
|
||||||
|
# for index_point in range(nb_points):
|
||||||
|
# draw_line(points_arc[index_point], points_arc[index_point + 1], color)
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
||||||
|
"
|
||||||
|
|
||||||
[node name="Inventory" type="Node2D"]
|
[node name="Inventory" type="Node2D"]
|
||||||
z_index = 1
|
z_index = 1
|
||||||
script = ExtResource( 3 )
|
script = SubResource( 1 )
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="."]
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
margin_right = 40.0
|
margin_right = 40.0
|
||||||
|
@ -40,7 +40,7 @@ func OpenConnection():
|
|||||||
if !file.file_exists(path):
|
if !file.file_exists(path):
|
||||||
create = true
|
create = true
|
||||||
self.db.open_db()
|
self.db.open_db()
|
||||||
if create:
|
if create:
|
||||||
CreateWorldDatabase()
|
CreateWorldDatabase()
|
||||||
|
|
||||||
func OpenConnectionIfClosed():
|
func OpenConnectionIfClosed():
|
||||||
@ -52,6 +52,13 @@ func GetInventoryItems():
|
|||||||
var ret = []
|
var ret = []
|
||||||
ret = db.select_rows("player_inventory", "",["*"])
|
ret = db.select_rows("player_inventory", "",["*"])
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
func SaveInventory(inventory):
|
||||||
|
if(inventory == null or len(inventory) != 40):
|
||||||
|
Global.Log("Bad inventory save!", 3)
|
||||||
|
return
|
||||||
|
OpenConnectionIfClosed()
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(delta):
|
#func _process(delta):
|
||||||
# pass
|
# pass
|
||||||
|
@ -7,6 +7,8 @@ onready var screen_size = self.get_viewport_rect().size
|
|||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
calculate_bounds()
|
calculate_bounds()
|
||||||
|
Global.current_camera = self
|
||||||
|
$dev_statistics.visible = Global.dev_stats
|
||||||
|
|
||||||
var once = true
|
var once = true
|
||||||
var lockedPlayerCamera = false
|
var lockedPlayerCamera = false
|
||||||
@ -35,6 +37,8 @@ func calculate_bounds():
|
|||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
if(Global.dev_stats):
|
||||||
|
$dev_statistics/fps_stats.text = "FPS: " + str(Performance.get_monitor(Performance.TIME_FPS))
|
||||||
CameraToPlayer()
|
CameraToPlayer()
|
||||||
if once:
|
if once:
|
||||||
once = false
|
once = false
|
||||||
@ -57,7 +61,7 @@ func MoveCamera(x, y):
|
|||||||
|
|
||||||
func _on_Tween_tween_completed(object, key):
|
func _on_Tween_tween_completed(object, key):
|
||||||
print(object, key)
|
print(object, key)
|
||||||
lockedPlayerCamera = false
|
lockedPlayerCamera = false
|
||||||
|
|
||||||
func AnimateMoveCamera(source, destination, key, time):
|
func AnimateMoveCamera(source, destination, key, time):
|
||||||
lockedPlayerCamera = true
|
lockedPlayerCamera = true
|
||||||
@ -69,4 +73,5 @@ func CameraToPlayer():
|
|||||||
if lockedPlayerCamera == false:
|
if lockedPlayerCamera == false:
|
||||||
MoveCamera(player.position.x, player.position.y)
|
MoveCamera(player.position.x, player.position.y)
|
||||||
|
|
||||||
|
func Update():
|
||||||
|
CameraToPlayer()
|
||||||
|
@ -103,8 +103,8 @@ scale = Vector2( 1.73434, 1.80493 )
|
|||||||
z_index = 13
|
z_index = 13
|
||||||
normal = ExtResource( 14 )
|
normal = ExtResource( 14 )
|
||||||
|
|
||||||
[node name="MoveDown" type="TouchScreenButton" parent="Camera2D"]
|
[node name="MoveDown" type="TouchScreenButton" parent="Camera2D/Interactive/GameButtons"]
|
||||||
position = Vector2( -480.965, 178.192 )
|
position = Vector2( 224.332, 1376.07 )
|
||||||
scale = Vector2( 14.9928, 14.9987 )
|
scale = Vector2( 14.9928, 14.9987 )
|
||||||
z_index = 11
|
z_index = 11
|
||||||
normal = ExtResource( 9 )
|
normal = ExtResource( 9 )
|
||||||
@ -114,8 +114,8 @@ action = "move_down"
|
|||||||
visibility_mode = 1
|
visibility_mode = 1
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="MoveRight" type="TouchScreenButton" parent="Camera2D"]
|
[node name="MoveRight" type="TouchScreenButton" parent="Camera2D/Interactive/GameButtons"]
|
||||||
position = Vector2( 478.572, -173.651 )
|
position = Vector2( 1183.87, 1024.23 )
|
||||||
scale = Vector2( 16.7497, 5.49206 )
|
scale = Vector2( 16.7497, 5.49206 )
|
||||||
z_index = 11
|
z_index = 11
|
||||||
normal = ExtResource( 3 )
|
normal = ExtResource( 3 )
|
||||||
@ -124,8 +124,8 @@ action = "move_right"
|
|||||||
visibility_mode = 1
|
visibility_mode = 1
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="MoveUp" type="TouchScreenButton" parent="Camera2D"]
|
[node name="MoveUp" type="TouchScreenButton" parent="Camera2D/Interactive/GameButtons"]
|
||||||
position = Vector2( -480.936, -298.537 )
|
position = Vector2( 224.361, 899.343 )
|
||||||
scale = Vector2( 14.9907, 15.5676 )
|
scale = Vector2( 14.9907, 15.5676 )
|
||||||
z_index = 11
|
z_index = 11
|
||||||
normal = ExtResource( 9 )
|
normal = ExtResource( 9 )
|
||||||
@ -134,8 +134,8 @@ action = "move_up"
|
|||||||
visibility_mode = 1
|
visibility_mode = 1
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="MoveLeft" type="TouchScreenButton" parent="Camera2D"]
|
[node name="MoveLeft" type="TouchScreenButton" parent="Camera2D/Interactive/GameButtons"]
|
||||||
position = Vector2( -615.955, -175.335 )
|
position = Vector2( 89.342, 1022.54 )
|
||||||
scale = Vector2( 16.8861, 5.52137 )
|
scale = Vector2( 16.8861, 5.52137 )
|
||||||
z_index = 11
|
z_index = 11
|
||||||
z_as_relative = false
|
z_as_relative = false
|
||||||
@ -146,6 +146,20 @@ action = "move_left"
|
|||||||
visibility_mode = 1
|
visibility_mode = 1
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
|
[node name="dev_statistics" type="MarginContainer" parent="Camera2D"]
|
||||||
|
margin_left = -615.0
|
||||||
|
margin_top = -300.0
|
||||||
|
margin_right = 614.0
|
||||||
|
margin_bottom = 297.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="fps_stats" type="Label" parent="Camera2D/dev_statistics"]
|
||||||
|
margin_top = 291.0
|
||||||
|
margin_right = 1229.0
|
||||||
|
margin_bottom = 305.0
|
||||||
|
|
||||||
[node name="Player" type="KinematicBody2D" parent="."]
|
[node name="Player" type="KinematicBody2D" parent="."]
|
||||||
position = Vector2( 700, 1200 )
|
position = Vector2( 700, 1200 )
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
@ -168,8 +182,8 @@ action = "map_interaction"
|
|||||||
|
|
||||||
[node name="Tween" type="Tween" parent="."]
|
[node name="Tween" type="Tween" parent="."]
|
||||||
[connection signal="pressed" from="Camera2D/Interactive/GameButtons/Inventory" to="background" method="_on_Inventory_pressed"]
|
[connection signal="pressed" from="Camera2D/Interactive/GameButtons/Inventory" to="background" method="_on_Inventory_pressed"]
|
||||||
[connection signal="pressed" from="Camera2D/MoveDown" to="Player" method="_on_TouchScreenButton_pressed"]
|
[connection signal="pressed" from="Camera2D/Interactive/GameButtons/MoveDown" to="Player" method="_on_TouchScreenButton_pressed"]
|
||||||
[connection signal="pressed" from="Camera2D/MoveRight" to="Player" method="_on_TouchScreenButton_pressed"]
|
[connection signal="pressed" from="Camera2D/Interactive/GameButtons/MoveRight" to="Player" method="_on_TouchScreenButton_pressed"]
|
||||||
[connection signal="pressed" from="Camera2D/MoveUp" to="Player" method="_on_TouchScreenButton_pressed"]
|
[connection signal="pressed" from="Camera2D/Interactive/GameButtons/MoveUp" to="Player" method="_on_TouchScreenButton_pressed"]
|
||||||
[connection signal="released" from="Player/CollisionShape2D/MapInteraction" to="Player" method="_interaction_process"]
|
[connection signal="released" from="Player/CollisionShape2D/MapInteraction" to="Player" method="_interaction_process"]
|
||||||
[connection signal="tween_completed" from="Tween" to="Camera2D" method="_on_Tween_tween_completed"]
|
[connection signal="tween_completed" from="Tween" to="Camera2D" method="_on_Tween_tween_completed"]
|
||||||
|
Loading…
Reference in New Issue
Block a user