added click to place tile

added basic window zoom/drag
This commit is contained in:
2024-02-03 16:30:11 -06:00
parent c6d5a8e113
commit 5b546291bf
5 changed files with 38 additions and 4 deletions

View File

@@ -0,0 +1,8 @@
extends Node2D
@onready var world_grid = $"../world_grid"
func _unhandled_input(event):
if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
prints(event.position, get_global_mouse_position(), world_grid.local_to_map(event.position), get_global_mouse_position(), world_grid.local_to_map(get_global_mouse_position()))
world_grid.set_cell(2, world_grid.local_to_map(get_global_mouse_position()), 0, Vector2i(16,2))

13
scripts/Window.gd Normal file
View File

@@ -0,0 +1,13 @@
extends Camera2D
@export var drag_sens: float = 2.0
func _unhandled_input(event):
if event is InputEventMouseButton:
match event.button_index:
MOUSE_BUTTON_WHEEL_DOWN:
zoom -= Vector2(0.01, 0.01)
MOUSE_BUTTON_WHEEL_UP:
zoom += Vector2(0.01, 0.01)
if event is InputEventMouseMotion and Input.is_mouse_button_pressed(MOUSE_BUTTON_MIDDLE):
position -= event.relative * drag_sens / zoom

View File

@@ -31,3 +31,8 @@ func _ready():
for region in noise_regions.size():
prints(region, noise_regions[region], temp_noise_reg.count(region))
#get_tree().quit()
func _process(delta):
var mouse_pos = world_grid.local_to_map(get_local_mouse_position())
world_grid.clear_layer(1)
world_grid.set_cell(1, mouse_pos,0,Vector2i(0,7))