Cleaning up. Changed tile and scene loading. Still not able to pick up items from vegetation/interaction layer.

This commit is contained in:
Jonathan Herrewijnen 2022-10-08 20:42:29 +02:00
parent c9394f7813
commit ed06c37822
5 changed files with 25 additions and 26 deletions

View File

@ -25,12 +25,7 @@ class base_tilemap:
self.vegetation_map = vegetation_map self.vegetation_map = vegetation_map
func t(): func t():
print("woo") print("woo! We're printing text!")
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -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(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) 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)) 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() _interaction_process()
velocity.y += delta * GRAVITY velocity.y += delta * GRAVITY
if Input.is_action_pressed("move_left"): if Input.is_action_pressed("move_left"):
@ -63,11 +63,8 @@ func InteractWithCell():
pass pass
func _interaction_process(): func _interaction_process():
if Input.is_mouse_button_pressed(BUTTON_LEFT) or Input.is_key_pressed(KEY_SPACE): world_position = get_global_mouse_position()
world_position = get_global_mouse_position() InteractWithCell()
InteractWithCell()
else:
pass
func AnimationOnInteraction(Item): func AnimationOnInteraction(Item):
print("Item = ", Item, " Animation") print("Item = ", Item, " Animation")

View File

@ -4,14 +4,21 @@ func load_scene(map_data):
$background.tile_set = load("base_tilemap/tilesets/background_ts.tres") $background.tile_set = load("base_tilemap/tilesets/background_ts.tres")
$vegetation.tile_set = load("res://river_intersection_home2.tscn::1") $vegetation.tile_set = load("res://river_intersection_home2.tscn::1")
for x in range(map_data.width): # for x in range(map_data.width):
for y in range(map_data.height): # for y in range(map_data.height):
$background.set_cell(x, y, map_data.background_map[x][y]) # $background.set_cell(x, y, map_data.background_map[x][y])
$vegetation.set_cell(x, y, -1) # $vegetation.set_cell(x, y, -1)
$interaction_map.set_cell(x, y, -1) # $interaction_map.set_cell(x, y, -1)
$player_interaction.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(): func _ready():
var scene = load("res://Maps/river_intersection.tscn") self.add_child(load_scene("res://Maps/river_intersection"))
var map = scene.instance() # var scene = load("res://Maps/river_intersection.tscn")
self.add_child(map) # var map = scene.instance()
# self.add_child(map)

View File

@ -1,5 +0,0 @@
[gd_resource type="DynamicFontData" format=2]
[resource]
resource_local_to_scene = true
font_path = "res://ring_of_races_font.ttf"

View File

@ -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) "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] [input_devices]