diff --git a/addons/godot-git-plugin/win64/~libgit_plugin.windows.editor.x86_64.dll b/addons/godot-git-plugin/win64/~libgit_plugin.windows.editor.x86_64.dll new file mode 100644 index 0000000..47bbb1d Binary files /dev/null and b/addons/godot-git-plugin/win64/~libgit_plugin.windows.editor.x86_64.dll differ diff --git a/assets/sprites/tiles/iso_tileset_with_select.png b/assets/sprites/tiles/iso_tileset_with_select.png new file mode 100644 index 0000000..b98b826 Binary files /dev/null and b/assets/sprites/tiles/iso_tileset_with_select.png differ diff --git a/assets/sprites/tiles/iso_tileset_with_select.png.import b/assets/sprites/tiles/iso_tileset_with_select.png.import new file mode 100644 index 0000000..e735648 --- /dev/null +++ b/assets/sprites/tiles/iso_tileset_with_select.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bsox4y2fftlh8" +path="res://.godot/imported/iso_tileset_with_select.png-ffd5c8774cc61a06e608c6b93e2ee00f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/tiles/iso_tileset_with_select.png" +dest_files=["res://.godot/imported/iso_tileset_with_select.png-ffd5c8774cc61a06e608c6b93e2ee00f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/sprites/tiles/iso_tileset_with_select.xcf b/assets/sprites/tiles/iso_tileset_with_select.xcf new file mode 100644 index 0000000..b8450d7 Binary files /dev/null and b/assets/sprites/tiles/iso_tileset_with_select.xcf differ diff --git a/scenes/debug_level.tscn b/scenes/debug_level.tscn new file mode 100644 index 0000000..b43c8be --- /dev/null +++ b/scenes/debug_level.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=4 format=3 uid="uid://c87m8r007ned1"] + +[ext_resource type="Script" uid="uid://0aqxvhvqbtr" path="res://scripts/debug_level.gd" id="1_8d50e"] +[ext_resource type="PackedScene" uid="uid://dg0qxdwe2rlcn" path="res://scenes/isometric_map_layer_holder.tscn" id="1_ln2x5"] +[ext_resource type="PackedScene" uid="uid://d1jhpluu86cbd" path="res://scenes/player.tscn" id="2_6or15"] + +[node name="DebugLevel" type="Node2D"] +y_sort_enabled = true +script = ExtResource("1_8d50e") + +[node name="IsometricMapLayerHolder" parent="." instance=ExtResource("1_ln2x5")] + +[node name="Player" parent="." instance=ExtResource("2_6or15")] +visible = false +z_index = 99 diff --git a/scenes/isometric_map_layer_holder.tscn b/scenes/isometric_map_layer_holder.tscn index 7bf0489..baedc59 100644 --- a/scenes/isometric_map_layer_holder.tscn +++ b/scenes/isometric_map_layer_holder.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://dg0qxdwe2rlcn"] +[gd_scene load_steps=7 format=3 uid="uid://dg0qxdwe2rlcn"] [ext_resource type="Script" uid="uid://dxcfy8xypdde6" path="res://scripts/isometric_map_layer_holder.gd" id="1_4o54u"] [ext_resource type="Texture2D" uid="uid://p8iyle6kr3nf" path="res://assets/sprites/tiles/iso_tileset.png" id="1_fme3d"] +[ext_resource type="Texture2D" uid="uid://bsox4y2fftlh8" path="res://assets/sprites/tiles/iso_tileset_with_select.png" id="3_s16iq"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_4o54u"] texture = ExtResource("1_fme3d") @@ -21,12 +22,61 @@ texture_region_size = Vector2i(32, 32) 6:0/0 = 0 6:0/0/texture_origin = Vector2i(0, -8) +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_wvhlo"] +texture = ExtResource("3_s16iq") +texture_region_size = Vector2i(32, 32) +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, -8) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, -8) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, -8) +3:0/0 = 0 +3:0/0/texture_origin = Vector2i(0, -8) +4:0/0 = 0 +4:0/0/texture_origin = Vector2i(0, -8) +5:0/0 = 0 +5:0/0/texture_origin = Vector2i(0, -8) +6:0/0 = 0 +6:0/0/texture_origin = Vector2i(0, -8) +7:0/0 = 0 +7:0/0/texture_origin = Vector2i(0, -8) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, -8) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, -8) +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, -8) +3:1/0 = 0 +3:1/0/texture_origin = Vector2i(0, -8) +4:1/0 = 0 +4:1/0/texture_origin = Vector2i(0, -8) +5:1/0 = 0 +5:1/0/texture_origin = Vector2i(0, -8) +6:1/0 = 0 +6:1/0/texture_origin = Vector2i(0, -8) +0:2/0 = 0 +1:2/0 = 0 +2:2/0 = 0 +3:2/0 = 0 +4:2/0 = 0 +5:2/0 = 0 +6:2/0 = 0 +0:3/0 = 0 +1:3/0 = 0 +2:3/0 = 0 +3:3/0 = 0 +4:3/0 = 0 +5:3/0 = 0 +6:3/0 = 0 + [sub_resource type="TileSet" id="TileSet_s16iq"] tile_shape = 1 tile_layout = 5 tile_offset_axis = 1 tile_size = Vector2i(32, 16) sources/0 = SubResource("TileSetAtlasSource_4o54u") +sources/1 = SubResource("TileSetAtlasSource_wvhlo") [node name="IsometricMapLayerHolder" type="Node2D"] script = ExtResource("1_4o54u") diff --git a/scenes/isometric_map_layer_holder.tscn38204884929.tmp b/scenes/isometric_map_layer_holder.tscn38204884929.tmp new file mode 100644 index 0000000..baedc59 --- /dev/null +++ b/scenes/isometric_map_layer_holder.tscn38204884929.tmp @@ -0,0 +1,171 @@ +[gd_scene load_steps=7 format=3 uid="uid://dg0qxdwe2rlcn"] + +[ext_resource type="Script" uid="uid://dxcfy8xypdde6" path="res://scripts/isometric_map_layer_holder.gd" id="1_4o54u"] +[ext_resource type="Texture2D" uid="uid://p8iyle6kr3nf" path="res://assets/sprites/tiles/iso_tileset.png" id="1_fme3d"] +[ext_resource type="Texture2D" uid="uid://bsox4y2fftlh8" path="res://assets/sprites/tiles/iso_tileset_with_select.png" id="3_s16iq"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_4o54u"] +texture = ExtResource("1_fme3d") +texture_region_size = Vector2i(32, 32) +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, -8) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, -8) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, -8) +3:0/0 = 0 +3:0/0/texture_origin = Vector2i(0, -8) +4:0/0 = 0 +4:0/0/texture_origin = Vector2i(0, -8) +5:0/0 = 0 +5:0/0/texture_origin = Vector2i(0, -8) +6:0/0 = 0 +6:0/0/texture_origin = Vector2i(0, -8) + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_wvhlo"] +texture = ExtResource("3_s16iq") +texture_region_size = Vector2i(32, 32) +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, -8) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, -8) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, -8) +3:0/0 = 0 +3:0/0/texture_origin = Vector2i(0, -8) +4:0/0 = 0 +4:0/0/texture_origin = Vector2i(0, -8) +5:0/0 = 0 +5:0/0/texture_origin = Vector2i(0, -8) +6:0/0 = 0 +6:0/0/texture_origin = Vector2i(0, -8) +7:0/0 = 0 +7:0/0/texture_origin = Vector2i(0, -8) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, -8) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, -8) +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, -8) +3:1/0 = 0 +3:1/0/texture_origin = Vector2i(0, -8) +4:1/0 = 0 +4:1/0/texture_origin = Vector2i(0, -8) +5:1/0 = 0 +5:1/0/texture_origin = Vector2i(0, -8) +6:1/0 = 0 +6:1/0/texture_origin = Vector2i(0, -8) +0:2/0 = 0 +1:2/0 = 0 +2:2/0 = 0 +3:2/0 = 0 +4:2/0 = 0 +5:2/0 = 0 +6:2/0 = 0 +0:3/0 = 0 +1:3/0 = 0 +2:3/0 = 0 +3:3/0 = 0 +4:3/0 = 0 +5:3/0 = 0 +6:3/0 = 0 + +[sub_resource type="TileSet" id="TileSet_s16iq"] +tile_shape = 1 +tile_layout = 5 +tile_offset_axis = 1 +tile_size = Vector2i(32, 16) +sources/0 = SubResource("TileSetAtlasSource_4o54u") +sources/1 = SubResource("TileSetAtlasSource_wvhlo") + +[node name="IsometricMapLayerHolder" type="Node2D"] +script = ExtResource("1_4o54u") + +[node name="Camera2D" type="Camera2D" parent="."] +zoom = Vector2(0.5, 0.5) + +[node name="TileMapLayer" type="TileMapLayer" parent="."] +tile_set = SubResource("TileSet_s16iq") + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="ResetButton" type="Button" parent="CanvasLayer"] +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -25.5 +offset_top = -31.0 +offset_right = 25.5 +grow_horizontal = 2 +grow_vertical = 0 +size_flags_horizontal = 4 +size_flags_vertical = 4 +text = "Reset" + +[node name="Z_CW" type="Button" parent="CanvasLayer"] +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -34.0 +offset_top = -15.5 +offset_bottom = 15.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "Rotate CW Z-Axis" + +[node name="Z_CCW" type="Button" parent="CanvasLayer"] +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_top = -15.5 +offset_right = 44.0 +offset_bottom = 15.5 +grow_vertical = 2 +text = "Rotate CCW Z-Axis" + +[node name="X_CW" type="Button" parent="CanvasLayer"] +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -140.0 +offset_top = -31.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "Rotate CW X-Axis" + +[node name="X_CCW" type="Button" parent="CanvasLayer"] +offset_right = 150.0 +offset_bottom = 31.0 +text = "Rotate CCW X-Axis" + +[node name="Y_CW" type="Button" parent="CanvasLayer"] +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -31.0 +offset_right = 139.0 +grow_vertical = 0 +text = "Rotate CW Y-Axis" + +[node name="Y_CCW" type="Button" parent="CanvasLayer"] +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -150.0 +offset_bottom = 31.0 +grow_horizontal = 0 +text = "Rotate CCW Y-Axis" + +[connection signal="pressed" from="CanvasLayer/ResetButton" to="." method="_on_reset_button_pressed"] +[connection signal="pressed" from="CanvasLayer/Z_CW" to="." method="_on_cw_pressed"] +[connection signal="pressed" from="CanvasLayer/Z_CCW" to="." method="_on_ccw_pressed"] +[connection signal="pressed" from="CanvasLayer/X_CW" to="." method="_on_x_cw_pressed"] +[connection signal="pressed" from="CanvasLayer/X_CCW" to="." method="_on_x_ccw_pressed"] +[connection signal="pressed" from="CanvasLayer/Y_CW" to="." method="_on_y_cw_pressed"] +[connection signal="pressed" from="CanvasLayer/Y_CCW" to="." method="_on_y_ccw_pressed"] diff --git a/scenes/player.tscn b/scenes/player.tscn index 0198c6d..e7547cf 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,9 +1,7 @@ -[gd_scene load_steps=16 format=3 uid="uid://d1jhpluu86cbd"] +[gd_scene load_steps=17 format=3 uid="uid://d1jhpluu86cbd"] [ext_resource type="Texture2D" uid="uid://d3tfo61gemayy" path="res://assets/sprites/units/$Cat_Female (2).png" id="1_3vyb7"] - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_v6fml"] -size = Vector2(36, 51) +[ext_resource type="Script" uid="uid://jfojoaymauh2" path="res://scripts/player.gd" id="1_g2els"] [sub_resource type="AtlasTexture" id="AtlasTexture_3li8b"] atlas = ExtResource("1_3vyb7") @@ -112,13 +110,18 @@ animations = [{ "speed": 5.0 }] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_v6fml"] +size = Vector2(36, 51) + [node name="Player" type="CharacterBody2D"] +script = ExtResource("1_g2els") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +scale = Vector2(0.5, 0.5) +sprite_frames = SubResource("SpriteFrames_0rnld") +animation = &"down" +frame_progress = 0.830149 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, 4.5) shape = SubResource("RectangleShape2D_v6fml") - -[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] -sprite_frames = SubResource("SpriteFrames_0rnld") -animation = &"down" -frame_progress = 0.830149 diff --git a/scripts/debug_level.gd b/scripts/debug_level.gd new file mode 100644 index 0000000..a6cb297 --- /dev/null +++ b/scripts/debug_level.gd @@ -0,0 +1,4 @@ +extends Node2D + +func _process(delta: float) -> void: + pass diff --git a/scripts/debug_level.gd.uid b/scripts/debug_level.gd.uid new file mode 100644 index 0000000..d7aef5a --- /dev/null +++ b/scripts/debug_level.gd.uid @@ -0,0 +1 @@ +uid://0aqxvhvqbtr diff --git a/scripts/isometric_map_layer_holder.gd b/scripts/isometric_map_layer_holder.gd index cab5c7f..f65219c 100644 --- a/scripts/isometric_map_layer_holder.gd +++ b/scripts/isometric_map_layer_holder.gd @@ -69,7 +69,10 @@ func create_debug_map_array(): "x": coord_x, "y": coord_y, "z": z, - "atlas_position": null, + "atlas_base_position": null, + "atlas_highlight_position": null, + "highlighted": false, + "selected": false, "hp": 100, "armour": 0, "destroyable": false, @@ -78,40 +81,47 @@ func create_debug_map_array(): "gravity": null } _debug_map[x][y][z] = tile_data - # Bottum + + var tile = _debug_map[0][0][0] for y in INITIAL_GRID_SIZE_LENGTH: for x in INITIAL_GRID_SIZE_WIDTH: - var tile = _debug_map[x][y][0] - tile["atlas_position"] = BLUE_ISOMETRICTILE_ATLAS_POSITION - tile["visibility"] = true - # Top - for y in INITIAL_GRID_SIZE_LENGTH: - for x in INITIAL_GRID_SIZE_WIDTH: - var tile = _debug_map[x][y][INITIAL_GRID_SIZE_HEIGHT-1] - tile["atlas_position"] = BLUE_ISOMETRICTILE_ATLAS_POSITION + tile = _debug_map[x][y][0] + tile["atlas_base_position"] = BLUE_ISOMETRICTILE_ATLAS_POSITION + tile["atlas_highlight_position"] = WHITE_ISOMETRICTILE_ATLAS_POSITION tile["visibility"] = true + for i in range(1,10): + tile = _debug_map[5][5][i] + tile["atlas_base_position"] = RED_ISOMETRICTILE_ATLAS_POSITION + tile["atlas_highlight_position"] = WHITE_ISOMETRICTILE_ATLAS_POSITION + tile["visibility"] = true + + # for y in INITIAL_GRID_SIZE_LENGTH: + # for x in INITIAL_GRID_SIZE_WIDTH: + # tile = _debug_map[x][y][INITIAL_GRID_SIZE_HEIGHT-1] + # tile["atlas_position"] = BLUE_ISOMETRICTILE_ATLAS_POSITION + # tile["visibility"] = true - for z in range(1,INITIAL_GRID_SIZE_HEIGHT-1): - for x in INITIAL_GRID_SIZE_WIDTH: - var tile = _debug_map[x][0][z] - tile["atlas_position"] = GREEN_ISOMETRICTILE_ATLAS_POSITION - tile["visibility"] = true - for z in range(1,INITIAL_GRID_SIZE_HEIGHT-1): - for x in INITIAL_GRID_SIZE_WIDTH: - var tile = _debug_map[x][INITIAL_GRID_SIZE_LENGTH-1][z] - tile["atlas_position"] = GREEN_ISOMETRICTILE_ATLAS_POSITION - tile["visibility"] = true + # for z in range(1,INITIAL_GRID_SIZE_HEIGHT-1): + # for x in INITIAL_GRID_SIZE_WIDTH: + # tile = _debug_map[x][0][z] + # tile["atlas_position"] = GREEN_ISOMETRICTILE_ATLAS_POSITION + # tile["visibility"] = true + # for z in range(1,INITIAL_GRID_SIZE_HEIGHT-1): + # for x in INITIAL_GRID_SIZE_WIDTH: + # tile = _debug_map[x][INITIAL_GRID_SIZE_LENGTH-1][z] + # tile["atlas_position"] = GREEN_ISOMETRICTILE_ATLAS_POSITION + # tile["visibility"] = true - for z in range(1,INITIAL_GRID_SIZE_HEIGHT-1): - for y in range(1,INITIAL_GRID_SIZE_LENGTH-1): - var tile = _debug_map[0][y][z] - tile["atlas_position"] = BLACK_ISOMETRICTILE_ATLAS_POSITION - tile["visibility"] = true - for z in range(1,INITIAL_GRID_SIZE_HEIGHT-1): - for y in range(1,INITIAL_GRID_SIZE_LENGTH-1): - var tile = _debug_map[INITIAL_GRID_SIZE_WIDTH-1][y][z] - tile["atlas_position"] = RED_ISOMETRICTILE_ATLAS_POSITION - tile["visibility"] = true + # for z in range(1,INITIAL_GRID_SIZE_HEIGHT-1): + # for y in range(1,INITIAL_GRID_SIZE_LENGTH-1): + # tile = _debug_map[0][y][z] + # tile["atlas_position"] = BLACK_ISOMETRICTILE_ATLAS_POSITION + # tile["visibility"] = true + # for z in range(1,INITIAL_GRID_SIZE_HEIGHT-1): + # for y in range(1,INITIAL_GRID_SIZE_LENGTH-1): + # tile = _debug_map[INITIAL_GRID_SIZE_WIDTH-1][y][z] + # tile["atlas_position"] = RED_ISOMETRICTILE_ATLAS_POSITION + # tile["visibility"] = true GRID_SIZE_WIDTH = INITIAL_GRID_SIZE_WIDTH # play area size x @@ -357,9 +367,78 @@ func draw_visible_tiles(): isometric_map_layers[z].set_cell( Vector2i(tile["x"], tile["y"]), MAIN_SOURCE_ID, - tile["atlas_position"] + tile["atlas_base_position"] ) + +var highlighted_tiles = {} # Dictionary to store all currently highlighted tiles + +func isometric_grid_hover(): + var hover_tile_position = isometric_map_layers[0].local_to_map(get_global_mouse_position()) + var new_highlighted_tiles = {} # Will store tiles to highlight this frame + + # First find all tiles that should be highlighted + for z in GRID_SIZE_HEIGHT: + for x in GRID_SIZE_WIDTH: + for y in GRID_SIZE_LENGTH: + var tile = debug_map[x][y][z] + + if tile != null and tile["visibility"]: + if tile["x"] == hover_tile_position.x and tile["y"] == hover_tile_position.y: + # Store this tile for highlighting + var tile_key = str(x) + "_" + str(y) + "_" + str(z) + new_highlighted_tiles[tile_key] = { + "x": x, + "y": y, + "z": z + } + + # Highlight new tiles + 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"]), + MAIN_SOURCE_ID, + tile["atlas_highlight_position"] + ) + else: + isometric_map_layers[tile_data.z].set_cell( + Vector2i(tile["x"], tile["y"]), + 1, + Vector2i(3,1) # + ) + + tile["highlighted"] = true + + # De-highlight tiles that are no longer under the cursor + for tile_key in highlighted_tiles: + if not (tile_key in new_highlighted_tiles): + var tile_data = highlighted_tiles[tile_key] + var tile = debug_map[tile_data.x][tile_data.y][tile_data.z] + + if tile != null and tile["visibility"]: + + if not tile["selected"]: + isometric_map_layers[tile_data.z].set_cell( + Vector2i(tile["x"], tile["y"]), + MAIN_SOURCE_ID, + tile["atlas_base_position"] # Original appearance + ) + else: + isometric_map_layers[tile_data.z].set_cell( + Vector2i(tile["x"], tile["y"]), + 1, + Vector2i(0,1) # + ) + tile["highlighted"] = false + + # Update the highlighted tiles list + highlighted_tiles = new_highlighted_tiles + + func _ready() -> void: # Store initial camera position @@ -368,10 +447,16 @@ func _ready() -> void: initialize_map_layers() draw_visible_tiles() +func _process(delta: float) -> void: + pass + # isometric_grid_hover() + func _input(event): + if event is InputEventMouseMotion: + isometric_grid_hover() # Camera drag (pan) control if event is InputEventMouseButton: - if event.button_index == MOUSE_BUTTON_LEFT: + if event.button_index == MOUSE_BUTTON_RIGHT: if event.pressed: drag_start = event.position drag_active = true @@ -379,9 +464,9 @@ func _input(event): drag_active = false # Zoom control with mouse wheel - if event.button_index == MOUSE_BUTTON_WHEEL_UP: + if event.button_index == MOUSE_BUTTON_WHEEL_DOWN: zoom_camera(-zoom_speed) - elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN: + elif event.button_index == MOUSE_BUTTON_WHEEL_UP: zoom_camera(zoom_speed) # Handle camera movement while dragging @@ -403,31 +488,90 @@ func zoom_camera(zoom_amount): camera.zoom = Vector2(new_zoom, new_zoom) func _on_cw_pressed() -> void: + _reset_class_values() rotate_map_around_z_axis(3) initialize_map_layers() draw_visible_tiles() func _on_ccw_pressed() -> void: + _reset_class_values() rotate_map_around_z_axis(1) initialize_map_layers() draw_visible_tiles() func _on_x_cw_pressed() -> void: + _reset_class_values() rotate_map_around_x_axis(1) initialize_map_layers() draw_visible_tiles() func _on_x_ccw_pressed() -> void: + _reset_class_values() rotate_map_around_x_axis(3) initialize_map_layers() draw_visible_tiles() func _on_y_cw_pressed() -> void: + _reset_class_values() rotate_map_around_y_axis(3) initialize_map_layers() draw_visible_tiles() func _on_y_ccw_pressed() -> void: + _reset_class_values() rotate_map_around_y_axis(1) initialize_map_layers() draw_visible_tiles() + + + +func _reset_class_values(): + highlighted_tiles = {} + last_click_time = 0.0 + clicked_position = Vector2i(1, 1) + is_tile_selected = false + +var click_delay: float = 0.2 +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): + for z in GRID_SIZE_HEIGHT: + for x in GRID_SIZE_WIDTH: + for y in GRID_SIZE_LENGTH: + var tile = debug_map[x][y][z] + if tile["selected"] and tile["highlighted"]: + isometric_map_layers[z].set_cell( + Vector2i(tile["x"], tile["y"]), + 1, + Vector2i(0,1) # + ) + tile["selected"] = false + if tile["selected"] and not tile["highlighted"]: + isometric_map_layers[z].set_cell( + Vector2i(tile["x"], tile["y"]), + 0, + Vector2i(0,0) # + ) + tile["selected"] = false + if not tile["selected"] and tile["highlighted"]: + isometric_map_layers[z].set_cell( + Vector2i(tile["x"], tile["y"]), + 1, + Vector2i(3,1) # + ) + tile["selected"] = true + + + +func _unhandled_input(event: InputEvent) -> void: + if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT: + 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) + elif event is InputEventKey and event.pressed and event.keycode == KEY_ESCAPE: + pass + #deselect_tile() diff --git a/scripts/main_menu.gd b/scripts/main_menu.gd index fd894ba..5ab5c51 100644 --- a/scripts/main_menu.gd +++ b/scripts/main_menu.gd @@ -12,7 +12,7 @@ func _process(delta): func _on_start_button_pressed(): - get_tree().change_scene_to_file("res://scenes/isometric_map_layer_holder.tscn") + get_tree().change_scene_to_file("res://scenes/debug_level.tscn") func _on_option_button_pressed(): diff --git a/scripts/player.gd b/scripts/player.gd new file mode 100644 index 0000000..2c5167d --- /dev/null +++ b/scripts/player.gd @@ -0,0 +1,12 @@ +extends CharacterBody2D + +@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D +@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D + + +func _process(delta: float): + play_idle_animation() + + +func play_idle_animation(): + animated_sprite.play("down") diff --git a/scripts/player.gd.uid b/scripts/player.gd.uid new file mode 100644 index 0000000..d208de9 --- /dev/null +++ b/scripts/player.gd.uid @@ -0,0 +1 @@ +uid://jfojoaymauh2