change some rotation stuff handling and added some nodes so i can test it (camera, buttons)

This commit is contained in:
Jonas 2025-03-22 15:01:47 +01:00
parent 653eb4b423
commit 05d43c9876
8 changed files with 424 additions and 104 deletions

View File

@ -11,7 +11,7 @@ config_version=5
[application] [application]
config/name="isometrictacticalrpg" config/name="isometrictacticalrpg"
run/main_scene="uid://dg0qxdwe2rlcn" run/main_scene="uid://gl6lc08v514x"
config/features=PackedStringArray("4.4", "Forward Plus") config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"

View File

@ -31,5 +31,91 @@ sources/0 = SubResource("TileSetAtlasSource_4o54u")
[node name="IsometricMapLayerHolder" type="Node2D"] [node name="IsometricMapLayerHolder" type="Node2D"]
script = ExtResource("1_4o54u") script = ExtResource("1_4o54u")
[node name="Camera2D" type="Camera2D" parent="."]
zoom = Vector2(0.5, 0.5)
[node name="TileMapLayer" type="TileMapLayer" parent="."] [node name="TileMapLayer" type="TileMapLayer" parent="."]
tile_set = SubResource("TileSet_s16iq") 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"]

View File

@ -1,7 +1,13 @@
[gd_scene format=3 uid="uid://gl6lc08v514x"] [gd_scene load_steps=2 format=3 uid="uid://gl6lc08v514x"]
[ext_resource type="PackedScene" uid="uid://pq5ava2wcthl" path="res://scenes/main_menu.tscn" id="1_o5qli"]
[node name="Main" type="Node2D"] [node name="Main" type="Node2D"]
[node name="Camera2D" type="Camera2D" parent="."]
[node name="MainMenu" parent="." instance=ExtResource("1_o5qli")]
[node name="GameManager" type="Node" parent="."] [node name="GameManager" type="Node" parent="."]
[node name="TurnManager" type="Node" parent="."] [node name="TurnManager" type="Node" parent="."]

42
scenes/main_menu.tscn Normal file
View File

@ -0,0 +1,42 @@
[gd_scene load_steps=2 format=3 uid="uid://pq5ava2wcthl"]
[ext_resource type="Script" uid="uid://brnx5vaafj63x" path="res://scripts/main_menu.gd" id="1_l6cm7"]
[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_l6cm7")
[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

@ -112,7 +112,7 @@ animations = [{
"speed": 5.0 "speed": 5.0
}] }]
[node name="CharacterBody2D" type="CharacterBody2D"] [node name="Player" type="CharacterBody2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 4.5) position = Vector2(0, 4.5)

View File

@ -1,6 +1,18 @@
extends Node2D extends Node2D
var GRID_SIZE_WIDTH = 30 # play area size x # camera stuff
@onready var camera = $Camera2D
var drag_start = Vector2()
var drag_active = false
var zoom_min = 0.1
var zoom_max = 4.0
var zoom_speed = 0.1
var initial_camera_position = Vector2(0, 0)
var initial_camera_zoom = Vector2(1, 1)
var GRID_SIZE_WIDTH = 50 # play area size x
var GRID_SIZE_LENGTH = 30 # play area size y var GRID_SIZE_LENGTH = 30 # play area size y
var GRID_SIZE_HEIGHT = 30 # play area size z var GRID_SIZE_HEIGHT = 30 # play area size z
var TILE_SIZE = 32 # in px var TILE_SIZE = 32 # in px
@ -15,16 +27,31 @@ const WHITE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(3,0)
const BLACK_ISOMETRICTILE_ATLAS_POSITION = Vector2i(4,0) const BLACK_ISOMETRICTILE_ATLAS_POSITION = Vector2i(4,0)
const PURPLE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(5,0) const PURPLE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(5,0)
const ORANGE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(6,0) const ORANGE_ISOMETRICTILE_ATLAS_POSITION = Vector2i(6,0)
const OFFSET = 15 const OFFSET = 0
var MAX_ARRAY_SIZE = 0
func _set_max_array_size():
MAX_ARRAY_SIZE = 0
if MAX_ARRAY_SIZE < GRID_SIZE_WIDTH:
MAX_ARRAY_SIZE = GRID_SIZE_WIDTH
if MAX_ARRAY_SIZE < GRID_SIZE_LENGTH:
MAX_ARRAY_SIZE = GRID_SIZE_LENGTH
if MAX_ARRAY_SIZE < GRID_SIZE_HEIGHT:
MAX_ARRAY_SIZE = GRID_SIZE_HEIGHT
func create_debug_map_array(): func create_debug_map_array():
var _debug_map = [] var _debug_map = []
for x in GRID_SIZE_WIDTH: _set_max_array_size()
for x in MAX_ARRAY_SIZE:
var y_array = [] var y_array = []
for y in GRID_SIZE_LENGTH: for y in MAX_ARRAY_SIZE:
var z_array = [] var z_array = []
for z in GRID_SIZE_HEIGHT: for z in MAX_ARRAY_SIZE:
z_array.append(null) z_array.append(null)
y_array.append(z_array) y_array.append(z_array)
_debug_map.append(y_array) _debug_map.append(y_array)
@ -34,89 +61,56 @@ func create_debug_map_array():
for x in GRID_SIZE_WIDTH: for x in GRID_SIZE_WIDTH:
var coord_x = x + (-1 * z) + OFFSET var coord_x = x + (-1 * z) + OFFSET
var coord_y = y + (-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 = { var tile_data = {
"x": coord_x, "x": coord_x,
"y": coord_y, "y": coord_y,
"z": z, "z": z,
"atlas_position": atlas_position, "atlas_position": null,
"hp": 100, "hp": 100,
"armour": 0, "armour": 0,
"destroyable": false, "destroyable": false,
"visibility": visibility, "visibility": false,
"unit": null, "unit": null,
"gravity": false "gravity": null
} }
_debug_map[x][y][z] = tile_data _debug_map[x][y][z] = tile_data
for y in GRID_SIZE_LENGTH:
for x in GRID_SIZE_WIDTH:
var tile = _debug_map[x][y][0]
tile["atlas_position"] = BLUE_ISOMETRICTILE_ATLAS_POSITION
tile["visibility"] = true
for y in GRID_SIZE_LENGTH:
for x in GRID_SIZE_WIDTH:
var tile = _debug_map[x][y][GRID_SIZE_HEIGHT-1]
tile["atlas_position"] = BLUE_ISOMETRICTILE_ATLAS_POSITION
tile["visibility"] = true
for z in range(1,GRID_SIZE_HEIGHT-1):
for x in 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,GRID_SIZE_HEIGHT-1):
for x in GRID_SIZE_WIDTH:
var tile = _debug_map[x][GRID_SIZE_LENGTH-1][z]
tile["atlas_position"] = GREEN_ISOMETRICTILE_ATLAS_POSITION
tile["visibility"] = true
for z in range(1,GRID_SIZE_HEIGHT-1):
for y in range(1,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,GRID_SIZE_HEIGHT-1):
for y in range(1,GRID_SIZE_LENGTH-1):
var tile = _debug_map[GRID_SIZE_WIDTH-1][y][z]
tile["atlas_position"] = RED_ISOMETRICTILE_ATLAS_POSITION
tile["visibility"] = true
return _debug_map 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): func rotate_map_around_x_axis(rotation_steps = 1):
rotation_steps = rotation_steps % 4 rotation_steps = rotation_steps % 4
@ -125,18 +119,32 @@ func rotate_map_around_x_axis(rotation_steps = 1):
var temp_map = [] var temp_map = []
# Initialize temp_map with same structure # Initialize temp_map with same structure
for x in GRID_SIZE_WIDTH:
_set_max_array_size()
for x in MAX_ARRAY_SIZE:
var y_array = [] var y_array = []
for y in GRID_SIZE_LENGTH: for y in MAX_ARRAY_SIZE:
var z_array = [] var z_array = []
for z in GRID_SIZE_HEIGHT: for z in MAX_ARRAY_SIZE:
z_array.append(null) z_array.append(null)
y_array.append(z_array) y_array.append(z_array)
temp_map.append(y_array) temp_map.append(y_array)
# Create a new map with adjusted dimensions
var new_height = int(GRID_SIZE_LENGTH) if rotation_steps % 2 == 1 else int(GRID_SIZE_HEIGHT)
var new_length = int(GRID_SIZE_HEIGHT) if rotation_steps % 2 == 1 else int(GRID_SIZE_LENGTH)
# Store the original dimensions
var original_height = GRID_SIZE_HEIGHT
var original_length = GRID_SIZE_LENGTH
# Temporarily adjust grid dimensions for coordinate calculation
GRID_SIZE_HEIGHT = new_height
GRID_SIZE_LENGTH = new_length
for x in GRID_SIZE_WIDTH: for x in GRID_SIZE_WIDTH:
for y in GRID_SIZE_LENGTH: for y in original_length:
for z in GRID_SIZE_HEIGHT: for z in original_height:
if debug_map[x][y][z] == null: if debug_map[x][y][z] == null:
continue continue
@ -146,15 +154,15 @@ func rotate_map_around_x_axis(rotation_steps = 1):
match rotation_steps: match rotation_steps:
1: # 90 degrees 1: # 90 degrees
new_y = z new_y = z
new_z = GRID_SIZE_LENGTH - 1 - y new_z = original_length - 1 - y
2: # 180 degrees 2: # 180 degrees
new_y = GRID_SIZE_LENGTH - 1 - y new_y = original_length - 1 - y
new_z = GRID_SIZE_HEIGHT - 1 - z new_z = original_height - 1 - z
3: # 270 degrees 3: # 270 degrees
new_y = GRID_SIZE_HEIGHT - 1 - z new_y = original_height - 1 - z
new_z = y new_z = y
if new_y >= 0 and new_y < GRID_SIZE_LENGTH and new_z >= 0 and new_z < GRID_SIZE_HEIGHT: if new_y >= 0 and new_y < new_length and new_z >= 0 and new_z < new_height:
temp_map[x][new_y][new_z] = debug_map[x][y][z].duplicate() 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_x = x + (-1 * new_z) + OFFSET
@ -164,6 +172,76 @@ func rotate_map_around_x_axis(rotation_steps = 1):
temp_map[x][new_y][new_z]["y"] = new_coord_y temp_map[x][new_y][new_z]["y"] = new_coord_y
temp_map[x][new_y][new_z]["z"] = new_z temp_map[x][new_y][new_z]["z"] = new_z
# Update the grid dimensions
GRID_SIZE_HEIGHT = new_height
GRID_SIZE_LENGTH = new_length
debug_map = temp_map
func rotate_map_around_y_axis(rotation_steps = 1):
rotation_steps = rotation_steps % 4
if rotation_steps == 0:
return
var temp_map = []
# Initialize temp_map with same structure
_set_max_array_size()
for x in MAX_ARRAY_SIZE:
var y_array = []
for y in MAX_ARRAY_SIZE:
var z_array = []
for z in MAX_ARRAY_SIZE:
z_array.append(null)
y_array.append(z_array)
temp_map.append(y_array)
# Create a new map with adjusted dimensions
var new_width = int(GRID_SIZE_HEIGHT) if rotation_steps % 2 == 1 else int(GRID_SIZE_WIDTH)
var new_height = int(GRID_SIZE_WIDTH) if rotation_steps % 2 == 1 else int(GRID_SIZE_HEIGHT)
# Store the original dimensions
var original_width = GRID_SIZE_WIDTH
var original_height = GRID_SIZE_HEIGHT
# Temporarily adjust grid dimensions for coordinate calculation
GRID_SIZE_WIDTH = new_width
GRID_SIZE_HEIGHT = new_height
for x in original_width:
for y in GRID_SIZE_LENGTH:
for z in original_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 = original_height - 1 - z
new_z = x
2: # 180 degrees
new_x = original_width - 1 - x
new_z = original_height - 1 - z
3: # 270 degrees
new_x = z
new_z = original_width - 1 - x
if new_x >= 0 and new_x < new_width and new_z >= 0 and new_z < new_height:
temp_map[new_x][y][new_z] = debug_map[x][y][z].duplicate()
var new_coord_x = new_x + (-1 * new_z) + OFFSET
var new_coord_y = y + (-1 * new_z) - OFFSET
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
# Update the grid dimensions
GRID_SIZE_WIDTH = new_width
GRID_SIZE_HEIGHT = new_height
debug_map = temp_map debug_map = temp_map
func rotate_map_around_z_axis(rotation_steps = 1): func rotate_map_around_z_axis(rotation_steps = 1):
@ -174,17 +252,30 @@ func rotate_map_around_z_axis(rotation_steps = 1):
var temp_map = [] var temp_map = []
# Initialize temp_map with same structure # Initialize temp_map with same structure
for x in GRID_SIZE_WIDTH: _set_max_array_size()
for x in MAX_ARRAY_SIZE:
var y_array = [] var y_array = []
for y in GRID_SIZE_LENGTH: for y in MAX_ARRAY_SIZE:
var z_array = [] var z_array = []
for z in GRID_SIZE_HEIGHT: for z in MAX_ARRAY_SIZE:
z_array.append(null) z_array.append(null)
y_array.append(z_array) y_array.append(z_array)
temp_map.append(y_array) temp_map.append(y_array)
for x in GRID_SIZE_WIDTH: # Create a new map with adjusted dimensions based on rotation
for y in GRID_SIZE_LENGTH: var new_width = int(GRID_SIZE_LENGTH) if rotation_steps % 2 == 1 else int(GRID_SIZE_WIDTH)
var new_length = int(GRID_SIZE_WIDTH) if rotation_steps % 2 == 1 else int(GRID_SIZE_LENGTH)
# Store the original dimensions
var original_width = GRID_SIZE_WIDTH
var original_length = GRID_SIZE_LENGTH
# Temporarily adjust grid dimensions for coordinate calculation
GRID_SIZE_WIDTH = new_width
GRID_SIZE_LENGTH = new_length
for x in original_width:
for y in original_length:
for z in GRID_SIZE_HEIGHT: for z in GRID_SIZE_HEIGHT:
if debug_map[x][y][z] == null: if debug_map[x][y][z] == null:
continue continue
@ -195,15 +286,15 @@ func rotate_map_around_z_axis(rotation_steps = 1):
match rotation_steps: match rotation_steps:
1: # 90 degrees 1: # 90 degrees
new_x = y new_x = y
new_y = GRID_SIZE_WIDTH - 1 - x new_y = original_width - 1 - x
2: # 180 degrees 2: # 180 degrees
new_x = GRID_SIZE_WIDTH - 1 - x new_x = original_width - 1 - x
new_y = GRID_SIZE_LENGTH - 1 - y new_y = original_length - 1 - y
3: # 270 degrees 3: # 270 degrees
new_x = GRID_SIZE_LENGTH - 1 - y new_x = original_length - 1 - y
new_y = x new_y = x
if new_x >= 0 and new_x < GRID_SIZE_WIDTH and new_y >= 0 and new_y < GRID_SIZE_LENGTH: if new_x >= 0 and new_x < new_width and new_y >= 0 and new_y < new_length:
temp_map[new_x][new_y][z] = debug_map[x][y][z].duplicate() 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_x = new_x + (-1 * z) + OFFSET
@ -213,8 +304,11 @@ func rotate_map_around_z_axis(rotation_steps = 1):
temp_map[new_x][new_y][z]["y"] = new_coord_y temp_map[new_x][new_y][z]["y"] = new_coord_y
temp_map[new_x][new_y][z]["z"] = z temp_map[new_x][new_y][z]["z"] = z
debug_map = temp_map # Update the grid dimensions
GRID_SIZE_WIDTH = new_width
GRID_SIZE_LENGTH = new_length
debug_map = temp_map
var isometric_map_layers = [] var isometric_map_layers = []
func initialize_map_layers(): func initialize_map_layers():
@ -240,6 +334,10 @@ func initialize_map_layers():
var debug_map = create_debug_map_array() var debug_map = create_debug_map_array()
# Draw the map # Draw the map
func draw_visible_tiles(): func draw_visible_tiles():
# clear all previously drawn tiles on each layer
for layer in isometric_map_layers:
layer.clear()
# draw the map
for z in GRID_SIZE_HEIGHT: for z in GRID_SIZE_HEIGHT:
for y in GRID_SIZE_LENGTH: for y in GRID_SIZE_LENGTH:
for x in GRID_SIZE_WIDTH: for x in GRID_SIZE_WIDTH:
@ -254,9 +352,73 @@ func draw_visible_tiles():
) )
func _ready() -> void: func _ready() -> void:
# Store initial camera position
initial_camera_position = camera.position
initial_camera_zoom = camera.zoom
initialize_map_layers()
draw_visible_tiles()
func _input(event):
# Camera drag (pan) control
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed:
drag_start = event.position
drag_active = true
else:
drag_active = false
# Zoom control with mouse wheel
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
zoom_camera(-zoom_speed)
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
zoom_camera(zoom_speed)
# Handle camera movement while dragging
if event is InputEventMouseMotion and drag_active:
camera.position -= event.relative / camera.zoom
func _on_reset_button_pressed() -> void:
# Reset camera position and zoom
# initialize_map_layers()
# debug_map = create_debug_map_array()
# draw_visible_tiles()
camera.position = initial_camera_position
camera.zoom = initial_camera_zoom
func zoom_camera(zoom_amount):
var new_zoom = camera.zoom.x + zoom_amount
new_zoom = clamp(new_zoom, zoom_min, zoom_max)
camera.zoom = Vector2(new_zoom, new_zoom)
func _on_cw_pressed() -> void:
rotate_map_around_z_axis(3)
initialize_map_layers()
draw_visible_tiles()
func _on_ccw_pressed() -> void:
rotate_map_around_z_axis(1)
initialize_map_layers()
draw_visible_tiles()
func _on_x_cw_pressed() -> void:
rotate_map_around_x_axis(1)
initialize_map_layers()
draw_visible_tiles()
func _on_x_ccw_pressed() -> void:
rotate_map_around_x_axis(3)
initialize_map_layers()
draw_visible_tiles()
func _on_y_cw_pressed() -> void:
rotate_map_around_y_axis(3)
initialize_map_layers()
draw_visible_tiles()
func _on_y_ccw_pressed() -> void:
rotate_map_around_y_axis(1)
initialize_map_layers() initialize_map_layers()
rotate_map_around_z_axis(0)
rotate_map_around_y_axis(0)
rotate_map_around_x_axis(0)
draw_visible_tiles() draw_visible_tiles()

23
scripts/main_menu.gd Normal file
View File

@ -0,0 +1,23 @@
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://scenes/isometric_map_layer_holder.tscn")
func _on_option_button_pressed():
get_tree().quit()
func _on_quit_button_pressed():
get_tree().quit()

1
scripts/main_menu.gd.uid Normal file
View File

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