From ed06c37822d4b7dbe8f27eb47c93ac7863fb8eab Mon Sep 17 00:00:00 2001 From: Jonathan Herrewijnen Date: Sat, 8 Oct 2022 20:42:29 +0200 Subject: [PATCH] Cleaning up. Changed tile and scene loading. Still not able to pick up items from vegetation/interaction layer. --- Global_structures.gd | 7 +------ MiscCodes/KinematicBody2D.gd | 9 +++------ Other/base_tilemap/init.gd | 25 ++++++++++++++++--------- Other/ring_of_races_font.tres | 5 ----- project.godot | 5 +++++ 5 files changed, 25 insertions(+), 26 deletions(-) delete mode 100644 Other/ring_of_races_font.tres diff --git a/Global_structures.gd b/Global_structures.gd index bda94ea..d8ac700 100644 --- a/Global_structures.gd +++ b/Global_structures.gd @@ -25,12 +25,7 @@ class base_tilemap: self.vegetation_map = vegetation_map func t(): - print("woo") + print("woo! We're printing text!") func _ready(): pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass diff --git a/MiscCodes/KinematicBody2D.gd b/MiscCodes/KinematicBody2D.gd index 7a04aed..ca4d3e7 100644 --- a/MiscCodes/KinematicBody2D.gd +++ b/MiscCodes/KinematicBody2D.gd @@ -21,7 +21,7 @@ func _physics_process(delta): player_interaction.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y) , 0) player_interaction.set_cell(previous_position.x, previous_position.y, -1) previous_position = Vector2(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y)) - if Input.is_key_pressed(KEY_SPACE) or Input.is_mouse_button_pressed(BUTTON_LEFT): + if Input.is_action_just_pressed("interact_with_cell"): _interaction_process() velocity.y += delta * GRAVITY if Input.is_action_pressed("move_left"): @@ -63,11 +63,8 @@ func InteractWithCell(): pass func _interaction_process(): - if Input.is_mouse_button_pressed(BUTTON_LEFT) or Input.is_key_pressed(KEY_SPACE): - world_position = get_global_mouse_position() - InteractWithCell() - else: - pass + world_position = get_global_mouse_position() + InteractWithCell() func AnimationOnInteraction(Item): print("Item = ", Item, " Animation") diff --git a/Other/base_tilemap/init.gd b/Other/base_tilemap/init.gd index 85e8299..86f0fc8 100644 --- a/Other/base_tilemap/init.gd +++ b/Other/base_tilemap/init.gd @@ -4,14 +4,21 @@ func load_scene(map_data): $background.tile_set = load("base_tilemap/tilesets/background_ts.tres") $vegetation.tile_set = load("res://river_intersection_home2.tscn::1") - for x in range(map_data.width): - for y in range(map_data.height): - $background.set_cell(x, y, map_data.background_map[x][y]) - $vegetation.set_cell(x, y, -1) - $interaction_map.set_cell(x, y, -1) - $player_interaction.set_cell(x, y, -1) +# for x in range(map_data.width): +# for y in range(map_data.height): +# $background.set_cell(x, y, map_data.background_map[x][y]) +# $vegetation.set_cell(x, y, -1) +# $interaction_map.set_cell(x, y, -1) +# $player_interaction.set_cell(x, y, -1) + + var scene = load(map_data+".tscn") + print("MAP NAME ",map_data+".tscn") + var map = scene.instance() + return map + func _ready(): - var scene = load("res://Maps/river_intersection.tscn") - var map = scene.instance() - self.add_child(map) + self.add_child(load_scene("res://Maps/river_intersection")) +# var scene = load("res://Maps/river_intersection.tscn") +# var map = scene.instance() +# self.add_child(map) diff --git a/Other/ring_of_races_font.tres b/Other/ring_of_races_font.tres deleted file mode 100644 index 92adcc4..0000000 --- a/Other/ring_of_races_font.tres +++ /dev/null @@ -1,5 +0,0 @@ -[gd_resource type="DynamicFontData" format=2] - -[resource] -resource_local_to_scene = true -font_path = "res://ring_of_races_font.ttf" diff --git a/project.godot b/project.godot index 46612cf..e05cb6a 100644 --- a/project.godot +++ b/project.godot @@ -112,6 +112,11 @@ open_inventory={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":73,"unicode":0,"echo":false,"script":null) ] } +interact_with_cell={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) + ] +} [input_devices]