tried to change the higlighting, did not work

This commit is contained in:
Jonas 2025-03-24 22:21:28 +01:00
parent 48ee4b49ea
commit e55dc546e3
4 changed files with 519 additions and 501 deletions

View File

@ -1,4 +1,4 @@
extends Node2D
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
pass

View File

@ -345,7 +345,6 @@ func initialize_map_layers():
new_layer.tile_set = $TileMapLayer.tile_set # Set your tileset
new_layer.z_index = z # Set the z-index to match the layer's height
# Add other TileMap settings as needed
add_child(new_layer)
isometric_map_layers.append(new_layer)
@ -385,8 +384,28 @@ func isometric_grid_hover():
if tile != null and tile["visibility"]:
if tile["x"] == hover_tile_position.x and tile["y"] == hover_tile_position.y:
# TODO: change highlighing so when the mouse is over an drawn tile and not the grid
var tile_above = isometric_map_layers[z+1].get_cell_source_id(
Vector2i(tile["x"]-1, tile["y"]-1)
)
# Store this tile for highlighting
var tile_key = str(x) + "_" + str(y) + "_" + str(z)
# print(tile_above)
# print(tile["x"], " ", tile["y"], " ", z)
# print(hover_tile_position)
if not tile_above:
new_highlighted_tiles[tile_key] = {
"x": x,
"y": y,
"z": z+1
}
else:
new_highlighted_tiles[tile_key] = {
"x": x,
"y": y,
"z": z
}
new_highlighted_tiles[tile_key] = {
"x": x,
"y": y,
@ -397,7 +416,6 @@ func isometric_grid_hover():
for tile_key in new_highlighted_tiles:
var tile_data = new_highlighted_tiles[tile_key]
var tile = debug_map[tile_data.x][tile_data.y][tile_data.z]
if not tile["selected"]:
isometric_map_layers[tile_data.z].set_cell(
Vector2i(tile["x"], tile["y"]),
@ -411,6 +429,7 @@ func isometric_grid_hover():
Vector2i(3,1) #
)
tile["highlighted"] = true
# De-highlight tiles that are no longer under the cursor
@ -447,7 +466,7 @@ func _ready() -> void:
initialize_map_layers()
draw_visible_tiles()
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
pass
# isometric_grid_hover()
@ -536,7 +555,7 @@ var last_click_time: float = 0.0
var clicked_position: Vector2i = Vector2i(1, 1)
var is_tile_selected: bool = false
func tile_selction_logic(position: Vector2i):
func tile_selction_logic():
for z in GRID_SIZE_HEIGHT:
for x in GRID_SIZE_WIDTH:
for y in GRID_SIZE_LENGTH:
@ -570,8 +589,7 @@ func _unhandled_input(event: InputEvent) -> void:
var current_time = Time.get_ticks_msec() / 1000.0
if current_time - last_click_time >= click_delay:
last_click_time = current_time
var new_clicked_position = isometric_map_layers[0].local_to_map(get_global_mouse_position())
tile_selction_logic(new_clicked_position)
tile_selction_logic()
elif event is InputEventKey and event.pressed and event.keycode == KEY_ESCAPE:
pass
#deselect_tile()

View File

@ -7,7 +7,7 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
func _process(_delta):
pass

View File

@ -4,7 +4,7 @@ extends CharacterBody2D
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
func _process(delta: float):
func _process(_delta: float):
play_idle_animation()