Have not figured out the tile map interaction part..

This commit is contained in:
Jonathan Herrewijnen 2022-10-17 21:02:44 +02:00
parent 7ee29cbe98
commit 91d651b3f3
7 changed files with 25 additions and 32 deletions

View File

@ -49,6 +49,13 @@ func RemoveScene(scene):
print("Removing scene ", scene) print("Removing scene ", scene)
var camera = get_node("/root/base_scene/Camera2D") var camera = get_node("/root/base_scene/Camera2D")
camera.remove_child(scene) camera.remove_child(scene)
func AddMap(mapname):
var maps = load(mapname).instance().get_children()
for i in maps:
print(get_tree().get_root())
get_tree().get_root().add_child(i)
print('Added ', i)
#Go to scene by name #Go to scene by name
func GoToScene(scene): func GoToScene(scene):

View File

@ -86,3 +86,4 @@ func AnimationOnInteraction(Item):
func _ready(): func _ready():
Global.player_inventory_items = Database.GetInventoryItems().duplicate() Global.player_inventory_items = Database.GetInventoryItems().duplicate()
print("Map = ", Global.map_name) print("Map = ", Global.map_name)

View File

@ -6,6 +6,7 @@ onready var background_map = get_node("/root/base_scene/background")
onready var screen_size = self.get_viewport_rect().size onready var screen_size = self.get_viewport_rect().size
func _ready(): func _ready():
var map_name = "res://Maps/river_intersection"
calculate_bounds() calculate_bounds()
Global.current_camera = self Global.current_camera = self
$dev_statistics.visible = Global.dev_stats $dev_statistics.visible = Global.dev_stats
@ -21,6 +22,8 @@ var max_y_pixel = 0
#function that calculates the borders/bounds of the map #function that calculates the borders/bounds of the map
func calculate_bounds(): func calculate_bounds():
for _i in self.get_parent().get_children():
print("Nodes visible ", _i)
var used_cells = background_map.get_used_cells() var used_cells = background_map.get_used_cells()
for pos in used_cells: for pos in used_cells:
if pos.x < min_x: if pos.x < min_x:

View File

@ -54,6 +54,5 @@ text = "Load Game"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[connection signal="pressed" from="Btn_PlayGame" to="." method="_on_Btn_PlayGame_pressed"] [connection signal="pressed" from="Btn_PlayGame" to="." method="_on_Btn_PlayGame_pressed"]
[connection signal="pressed" from="Btn_LoadGame" to="." method="_on_Btn_LoadGame_pressed"] [connection signal="pressed" from="Btn_LoadGame" to="." method="_on_Btn_LoadGame_pressed"]

View File

@ -1,7 +1,6 @@
[gd_scene load_steps=19 format=2] [gd_scene load_steps=18 format=2]
[ext_resource path="res://pictures/gui/player_interaction.tres" type="TileSet" id=1] [ext_resource path="res://pictures/gui/player_interaction.tres" type="TileSet" id=1]
[ext_resource path="res://MiscCodes/background_script.gd" type="Script" id=2]
[ext_resource path="res://MiscCodes/Tilemap_CameraView.gd" type="Script" id=3] [ext_resource path="res://MiscCodes/Tilemap_CameraView.gd" type="Script" id=3]
[ext_resource path="res://MiscCodes/TouchScreenButton.gd" type="Script" id=4] [ext_resource path="res://MiscCodes/TouchScreenButton.gd" type="Script" id=4]
[ext_resource path="res://MiscCodes/KinematicBody2D.gd" type="Script" id=5] [ext_resource path="res://MiscCodes/KinematicBody2D.gd" type="Script" id=5]
@ -25,29 +24,6 @@ radius = 20.0
[node name="base_scene" type="Node2D"] [node name="base_scene" type="Node2D"]
script = ExtResource( 6 ) script = ExtResource( 6 )
[node name="background" type="TileMap" parent="."]
cell_size = Vector2( 32, 32 )
cell_custom_transform = Transform2D( 16, 0, 0, 16, 0, 0 )
format = 1
script = ExtResource( 2 )
[node name="vegetation" type="TileMap" parent="."]
cell_size = Vector2( 32, 32 )
format = 1
[node name="interaction_map" type="TileMap" parent="."]
cell_size = Vector2( 32, 32 )
cell_custom_transform = Transform2D( 16, 0, 0, 16, 0, 0 )
centered_textures = true
format = 1
[node name="player_interaction" type="TileMap" parent="."]
tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 32 )
cell_custom_transform = Transform2D( 16, 0, 0, 16, 0, 0 )
format = 1
tile_data = PoolIntArray( 9371749, 0, 0 )
[node name="Camera2D" type="Camera2D" parent="."] [node name="Camera2D" type="Camera2D" parent="."]
position = Vector2( 705.297, 1197.88 ) position = Vector2( 705.297, 1197.88 )
z_index = 15 z_index = 15
@ -192,7 +168,6 @@ shape = SubResource( 2 )
action = "map_interaction" action = "map_interaction"
[node name="Tween" type="Tween" parent="."] [node name="Tween" type="Tween" parent="."]
[connection signal="released" from="Camera2D/Interactive/GameButtons/Inventory" to="background" method="_on_Inventory_released"]
[connection signal="pressed" from="Camera2D/Interactive/GameButtons/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/Interactive/GameButtons/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/Interactive/GameButtons/MoveUp" to="Player" method="_on_TouchScreenButton_pressed"] [connection signal="pressed" from="Camera2D/Interactive/GameButtons/MoveUp" to="Player" method="_on_TouchScreenButton_pressed"]

View File

@ -1,5 +1,13 @@
extends Node2D extends Node2D
func _ready(): func _init():
var map_name = "res://Maps/river_intersection" var map_name = "res://Maps/river_intersection.tscn"
self.add_child(Global.load_scene(map_name)) Global.AddMap(map_name)
# for _i in self.get_children():
# print("Nodes visible ",_i)
# if _i is TileMap:
# print("Checking ", _i)
# for x in 300:
# for y in 300:
# if _i.get_cell(x, y) != -1:
# print(_i.get_cell(x, y))

View File

@ -130,9 +130,9 @@ pointing/emulate_touch_from_mouse=true
[rendering] [rendering]
quality/driver/driver_name="GLES2" quality/driver/driver_name="GLES2"
2d/snapping/use_gpu_pixel_snap=true
vram_compression/import_etc=true
quality/2d/use_pixel_snap=true quality/2d/use_pixel_snap=true
vram_compression/import_etc=true
2d/snapping/use_gpu_pixel_snap=true
[tiled_importer] [tiled_importer]