debug world 1

This commit is contained in:
Jonas 2025-03-22 13:20:31 +01:00
parent 969a3ac8de
commit 653eb4b423
29 changed files with 1924 additions and 192 deletions

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016-2023 The Godot Engine community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
[configuration]
entry_symbol = "git_plugin_init"
compatibility_minimum = "4.1.0"
[libraries]
macos.editor = "macos/libgit_plugin.macos.editor.universal.dylib"
windows.editor.x86_64 = "win64/libgit_plugin.windows.editor.x86_64.dll"
linux.editor.x86_64 = "linux/libgit_plugin.linux.editor.x86_64.so"
linux.editor.arm64 = "linux/libgit_plugin.linux.editor.arm64.so"
linux.editor.rv64 = ""

View File

@ -0,0 +1 @@
uid://bqps64s0q7a58

View File

@ -0,0 +1,7 @@
[plugin]
name="Godot Git Plugin"
description="This plugin lets you interact with Git without leaving the Godot editor. More information can be found at https://github.com/godotengine/godot-git-plugin/wiki"
author="twaritwaikar"
version="v3.1.1"
script="godot-git-plugin.gd"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dtam6k5eslalw"
path="res://.godot/imported/iso_tileset_with_wall.png-3fe0558a0ce40185088ec969f7ab5dc8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/tiles/iso_tileset_with_wall.png"
dest_files=["res://.godot/imported/iso_tileset_with_wall.png-3fe0558a0ce40185088ec969f7ab5dc8.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bpure4h16qey2"
path="res://.godot/imported/cursor.png-da07e5d4f697ea8da43ce051395e8ff6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/ui/cursor.png"
dest_files=["res://.godot/imported/cursor.png-da07e5d4f697ea8da43ce051395e8ff6.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

View File

@ -11,6 +11,11 @@ config_version=5
[application] [application]
config/name="isometrictacticalrpg" config/name="isometrictacticalrpg"
run/main_scene="uid://cwkfqadcknsen" run/main_scene="uid://dg0qxdwe2rlcn"
config/features=PackedStringArray("4.4", "Forward Plus") config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[editor]
version_control/plugin_name="GitPlugin"
version_control/autoload_on_startup=true

View File

@ -0,0 +1,14 @@
[gd_scene load_steps=4 format=3 uid="uid://gl6lc08v514x"]
[ext_resource type="Script" uid="uid://bl8akivwu0f7b" path="res://scripts/Main.gd" id="1_0bbpv"]
[ext_resource type="Script" uid="uid://d38jufiresiq0" path="res://scripts/GameManager.gd" id="2_rarhs"]
[ext_resource type="Script" uid="uid://buwxqixvbq6r8" path="res://scripts/TurnManager.gd" id="3_vcsgt"]
[node name="Main" type="Node2D"]
script = ExtResource("1_0bbpv")
[node name="GameManager" type="Node" parent="."]
script = ExtResource("2_rarhs")
[node name="TurnManager" type="Node" parent="."]
script = ExtResource("3_vcsgt")

View File

@ -0,0 +1,7 @@
[gd_scene format=3 uid="uid://gl6lc08v514x"]
[node name="Main" type="Node2D"]
[node name="GameManager" type="Node" parent="."]
[node name="TurnManager" type="Node" parent="."]

View File

@ -0,0 +1,7 @@
[gd_scene format=3 uid="uid://gl6lc08v514x"]
[node name="Main" type="Node2D"]
[node name="GameManager" type="Node" parent="."]
[node name="TurnManager" type="Node" parent="."]

View File

@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://gl6lc08v514x"]
[node name="Main" type="Node2D"]

View File

@ -0,0 +1,35 @@
[gd_scene load_steps=5 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"]
[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="TileSet" id="TileSet_s16iq"]
tile_shape = 1
tile_layout = 5
tile_offset_axis = 1
tile_size = Vector2i(32, 16)
sources/0 = SubResource("TileSetAtlasSource_4o54u")
[node name="IsometricMapLayerHolder" type="Node2D"]
script = ExtResource("1_4o54u")
[node name="TileMapLayer" type="TileMapLayer" parent="."]
tile_set = SubResource("TileSet_s16iq")

7
scenes/main.tscn Normal file
View File

@ -0,0 +1,7 @@
[gd_scene format=3 uid="uid://gl6lc08v514x"]
[node name="Main" type="Node2D"]
[node name="GameManager" type="Node" parent="."]
[node name="TurnManager" type="Node" parent="."]

124
scenes/player.tscn Normal file
View File

@ -0,0 +1,124 @@
[gd_scene load_steps=16 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)
[sub_resource type="AtlasTexture" id="AtlasTexture_3li8b"]
atlas = ExtResource("1_3vyb7")
region = Rect2(0, 0, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_mdl7e"]
atlas = ExtResource("1_3vyb7")
region = Rect2(48, 0, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_qu4a1"]
atlas = ExtResource("1_3vyb7")
region = Rect2(96, 0, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_70d11"]
atlas = ExtResource("1_3vyb7")
region = Rect2(0, 60, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_cw2d6"]
atlas = ExtResource("1_3vyb7")
region = Rect2(48, 60, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_khinc"]
atlas = ExtResource("1_3vyb7")
region = Rect2(96, 60, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_bruh7"]
atlas = ExtResource("1_3vyb7")
region = Rect2(0, 120, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_6eyey"]
atlas = ExtResource("1_3vyb7")
region = Rect2(48, 120, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_d3wef"]
atlas = ExtResource("1_3vyb7")
region = Rect2(96, 120, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_o4126"]
atlas = ExtResource("1_3vyb7")
region = Rect2(0, 180, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_lkdrv"]
atlas = ExtResource("1_3vyb7")
region = Rect2(48, 180, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_p7iby"]
atlas = ExtResource("1_3vyb7")
region = Rect2(96, 180, 48, 60)
[sub_resource type="SpriteFrames" id="SpriteFrames_0rnld"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_3li8b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_mdl7e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qu4a1")
}],
"loop": true,
"name": &"down",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_70d11")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_cw2d6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_khinc")
}],
"loop": true,
"name": &"left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_bruh7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6eyey")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_d3wef")
}],
"loop": true,
"name": &"right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_o4126")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lkdrv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_p7iby")
}],
"loop": true,
"name": &"up",
"speed": 5.0
}]
[node name="CharacterBody2D" type="CharacterBody2D"]
[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

View File

@ -1,42 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://cwkfqadcknsen"]
[ext_resource type="Script" uid="uid://6aeumnkn1ntj" path="res://scripts/ui/main_menu.gd" id="1_sl1te"]
[node name="MainMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_sl1te")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
[node name="StartButton" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Start"
[node name="OptionButton" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Option"
[node name="QuitButton" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "Quit"
[connection signal="pressed" from="VBoxContainer/StartButton" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="VBoxContainer/OptionButton" to="." method="_on_option_button_pressed"]
[connection signal="pressed" from="VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"]

View File

@ -1,125 +0,0 @@
[gd_scene load_steps=16 format=3 uid="uid://wtijljokgpot"]
[ext_resource type="Texture2D" uid="uid://d3tfo61gemayy" path="res://assets/sprites/units/$Cat_Female (2).png" id="1_pkbir"]
[sub_resource type="AtlasTexture" id="AtlasTexture_esfxm"]
atlas = ExtResource("1_pkbir")
region = Rect2(0, 0, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_15tbu"]
atlas = ExtResource("1_pkbir")
region = Rect2(48, 0, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_55td2"]
atlas = ExtResource("1_pkbir")
region = Rect2(96, 0, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_rwmet"]
atlas = ExtResource("1_pkbir")
region = Rect2(0, 60, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_xovxq"]
atlas = ExtResource("1_pkbir")
region = Rect2(48, 60, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_174p4"]
atlas = ExtResource("1_pkbir")
region = Rect2(96, 60, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_ts5o2"]
atlas = ExtResource("1_pkbir")
region = Rect2(0, 120, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_olx12"]
atlas = ExtResource("1_pkbir")
region = Rect2(48, 120, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_gxusr"]
atlas = ExtResource("1_pkbir")
region = Rect2(96, 120, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_oti7e"]
atlas = ExtResource("1_pkbir")
region = Rect2(0, 180, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_ad5rf"]
atlas = ExtResource("1_pkbir")
region = Rect2(48, 180, 48, 60)
[sub_resource type="AtlasTexture" id="AtlasTexture_da23m"]
atlas = ExtResource("1_pkbir")
region = Rect2(96, 180, 48, 60)
[sub_resource type="SpriteFrames" id="SpriteFrames_0rwas"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_esfxm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_15tbu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_55td2")
}],
"loop": true,
"name": &"down",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rwmet")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xovxq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_174p4")
}],
"loop": true,
"name": &"left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ts5o2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_olx12")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gxusr")
}],
"loop": true,
"name": &"right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_oti7e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ad5rf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_da23m")
}],
"loop": true,
"name": &"up",
"speed": 5.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_m4w27"]
size = Vector2(36, 48)
[node name="player" type="CharacterBody2D"]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_0rwas")
animation = &"down"
frame = 1
frame_progress = 0.383158
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 6)
shape = SubResource("RectangleShape2D_m4w27")

View File

@ -0,0 +1,262 @@
extends Node2D
var GRID_SIZE_WIDTH = 30 # play area size x
var GRID_SIZE_LENGTH = 30 # play area size y
var GRID_SIZE_HEIGHT = 30 # play area size z
var TILE_SIZE = 32 # in px
var TILE_SIZE_ISOMETRIC_X = 32 # in px
var TILE_SIZE_ISOMETRIC_Y = 16 # in px
var ROTATION = 0
const MAIN_SOURCE_ID = 0
const BLUE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(0,0)
const RED_ISOMETRICTILE_ATLAS_POSITION = Vector2i(1,0)
const GREEN_ISOMETRICTILE_ATLAS_POSITION = Vector2i(2,0)
const WHITE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(3,0)
const BLACK_ISOMETRICTILE_ATLAS_POSITION = Vector2i(4,0)
const PURPLE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(5,0)
const ORANGE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(6,0)
const OFFSET = 15
func create_debug_map_array():
var _debug_map = []
for x in GRID_SIZE_WIDTH:
var y_array = []
for y in GRID_SIZE_LENGTH:
var z_array = []
for z in GRID_SIZE_HEIGHT:
z_array.append(null)
y_array.append(z_array)
_debug_map.append(y_array)
for z in GRID_SIZE_HEIGHT:
for y in GRID_SIZE_LENGTH:
for x in GRID_SIZE_WIDTH:
var coord_x = x + (-1 * z) + OFFSET
var coord_y = y + (-1 * z) - OFFSET
var visibility = false
var atlas_position = BLUE_ISOMETRICTILE_ATLAS_POSITION
if z == 0:
visibility = true
atlas_position = RED_ISOMETRICTILE_ATLAS_POSITION
if z == 1:
if coord_x > 20 and coord_y > 10:
visibility = true
# print("Variable value: ", coord_x, " ", coord_y, " ", z, " ", visibility)
atlas_position = GREEN_ISOMETRICTILE_ATLAS_POSITION
var tile_data = {
"x": coord_x,
"y": coord_y,
"z": z,
"atlas_position": atlas_position,
"hp": 100,
"armour": 0,
"destroyable": false,
"visibility": visibility,
"unit": null,
"gravity": false
}
_debug_map[x][y][z] = tile_data
return _debug_map
func rotate_map_around_y_axis(rotation_steps = 1):
rotation_steps = rotation_steps % 4
if rotation_steps == 0:
return
# Create a temporary map with the correct dimensions
var temp_map = []
for x in GRID_SIZE_WIDTH:
var y_array = []
for y in GRID_SIZE_LENGTH:
var z_array = []
for z in GRID_SIZE_HEIGHT:
z_array.append(null)
y_array.append(z_array)
temp_map.append(y_array)
# For a y-axis rotation, we need to swap x and z coordinates
# but keep the isometric projection consistent
for x in GRID_SIZE_WIDTH:
for y in GRID_SIZE_LENGTH:
for z in GRID_SIZE_HEIGHT:
if debug_map[x][y][z] == null:
continue
var new_x = 0
var new_z = 0
match rotation_steps:
1: # 90 degrees clockwise around Y axis
new_x = GRID_SIZE_HEIGHT - 1 - z
new_z = x
2: # 180 degrees
new_x = GRID_SIZE_WIDTH - 1 - x
new_z = GRID_SIZE_HEIGHT - 1 - z
3: # 270 degrees
new_x = z
new_z = GRID_SIZE_WIDTH - 1 - x
# Ensure we're within bounds
if new_x >= 0 and new_x < GRID_SIZE_WIDTH and new_z >= 0 and new_z < GRID_SIZE_HEIGHT:
# Copy the tile data
temp_map[new_x][y][new_z] = debug_map[x][y][z].duplicate()
# The crucial part: preserve the visual arrangement by adapting the isometric projection
# We need to recalculate the display coordinates based on the new grid position
var new_coord_x = new_x + (-1 * new_z) + 15
var new_coord_y = y + (-1 * new_z) - 15
temp_map[new_x][y][new_z]["x"] = new_coord_x
temp_map[new_x][y][new_z]["y"] = new_coord_y
temp_map[new_x][y][new_z]["z"] = new_z
# Replace the original map
debug_map = temp_map
print("Map rotated around y-axis by %d steps" % rotation_steps)
func rotate_map_around_x_axis(rotation_steps = 1):
rotation_steps = rotation_steps % 4
if rotation_steps == 0:
return
var temp_map = []
# Initialize temp_map with same structure
for x in GRID_SIZE_WIDTH:
var y_array = []
for y in GRID_SIZE_LENGTH:
var z_array = []
for z in GRID_SIZE_HEIGHT:
z_array.append(null)
y_array.append(z_array)
temp_map.append(y_array)
for x in GRID_SIZE_WIDTH:
for y in GRID_SIZE_LENGTH:
for z in GRID_SIZE_HEIGHT:
if debug_map[x][y][z] == null:
continue
var new_y = 0
var new_z = 0
match rotation_steps:
1: # 90 degrees
new_y = z
new_z = GRID_SIZE_LENGTH - 1 - y
2: # 180 degrees
new_y = GRID_SIZE_LENGTH - 1 - y
new_z = GRID_SIZE_HEIGHT - 1 - z
3: # 270 degrees
new_y = GRID_SIZE_HEIGHT - 1 - z
new_z = y
if new_y >= 0 and new_y < GRID_SIZE_LENGTH and new_z >= 0 and new_z < GRID_SIZE_HEIGHT:
temp_map[x][new_y][new_z] = debug_map[x][y][z].duplicate()
var new_coord_x = x + (-1 * new_z) + OFFSET
var new_coord_y = new_y + (-1 * new_z) - OFFSET
temp_map[x][new_y][new_z]["x"] = new_coord_x
temp_map[x][new_y][new_z]["y"] = new_coord_y
temp_map[x][new_y][new_z]["z"] = new_z
debug_map = temp_map
func rotate_map_around_z_axis(rotation_steps = 1):
rotation_steps = rotation_steps % 4
if rotation_steps == 0:
return
var temp_map = []
# Initialize temp_map with same structure
for x in GRID_SIZE_WIDTH:
var y_array = []
for y in GRID_SIZE_LENGTH:
var z_array = []
for z in GRID_SIZE_HEIGHT:
z_array.append(null)
y_array.append(z_array)
temp_map.append(y_array)
for x in GRID_SIZE_WIDTH:
for y in GRID_SIZE_LENGTH:
for z in GRID_SIZE_HEIGHT:
if debug_map[x][y][z] == null:
continue
var new_x = 0
var new_y = 0
match rotation_steps:
1: # 90 degrees
new_x = y
new_y = GRID_SIZE_WIDTH - 1 - x
2: # 180 degrees
new_x = GRID_SIZE_WIDTH - 1 - x
new_y = GRID_SIZE_LENGTH - 1 - y
3: # 270 degrees
new_x = GRID_SIZE_LENGTH - 1 - y
new_y = x
if new_x >= 0 and new_x < GRID_SIZE_WIDTH and new_y >= 0 and new_y < GRID_SIZE_LENGTH:
temp_map[new_x][new_y][z] = debug_map[x][y][z].duplicate()
var new_coord_x = new_x + (-1 * z) + OFFSET
var new_coord_y = new_y + (-1 * z) - OFFSET
temp_map[new_x][new_y][z]["x"] = new_coord_x
temp_map[new_x][new_y][z]["y"] = new_coord_y
temp_map[new_x][new_y][z]["z"] = z
debug_map = temp_map
var isometric_map_layers = []
func initialize_map_layers():
# Clear any existing layers
for layer in isometric_map_layers:
if is_instance_valid(layer):
layer.queue_free()
isometric_map_layers.clear()
# Create new layers for each height level
for z in GRID_SIZE_HEIGHT:
var new_layer = TileMapLayer.new()
new_layer.set_name("IsometricMapLayer_" + str(z))
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)
var debug_map = create_debug_map_array()
# Draw the map
func draw_visible_tiles():
for z in GRID_SIZE_HEIGHT:
for y in GRID_SIZE_LENGTH:
for x in GRID_SIZE_WIDTH:
var tile = debug_map[x][y][z]
if tile != null and tile["visibility"]:
# Use the layer that corresponds to the tile's z-value
if z < isometric_map_layers.size():
isometric_map_layers[z].set_cell(
Vector2i(tile["x"], tile["y"]),
MAIN_SOURCE_ID,
tile["atlas_position"]
)
func _ready() -> void:
initialize_map_layers()
rotate_map_around_z_axis(0)
rotate_map_around_y_axis(0)
rotate_map_around_x_axis(0)
draw_visible_tiles()

View File

@ -0,0 +1 @@
uid://dxcfy8xypdde6

View File

@ -1,23 +0,0 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_start_button_pressed():
get_tree().change_scene_to_file("res://test_level.tscn")
func _on_option_button_pressed():
get_tree().quit()
func _on_quit_button_pressed():
get_tree().quit()

View File

@ -1 +0,0 @@
uid://6aeumnkn1ntj