Godot Version
godot-4.6.1
Question
I am really really new to coding and Im doing this assignment for a class. I am trying to make a 4x4 tile sliding puzzle game and I’ve been following a bunch of guides to do it.
There is this section where, to check your work, you should be able to click each tile and it will produce the row and column number in the output. In the video I’m watching, it should be from 0-3 in both rows and columns, but my column number is coming out at 2-5 every time. This is causing me issues later in the coding process but I cannot for the life of me figure out what I did wrong!
Apologies for not being able to attach a video of the issue as I am a new user, but here is a chunk of the code!
func _process(delta):
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and mouse:
var mouse_copy = mouse
print(mouse.position)
mouse = false
var rows = int(mouse_copy.position.y / 135)
var cols = int(mouse_copy.position.x / 135)
print(rows, “,”, cols)
func find_empty(position,pos):
var new_rows = int(position.y / 135)
var new_cols = int(position.x / 135)
var new_pos = new_rows * 4 + new_cols
if tiles[new_pos] == $Tile16:swap_tiles(pos, new_pos)
return true
else:
return false