Stuck on displaying tile info
Posted: Sat Nov 26, 2022 1:14 am
Ive been attempting to create a basic strategy game with generated terrain. Right now, im trying to make a display which shows what type of tile your mouse is over. This code is in love.draw(). The tiles are generated and displayed perfectly fine, so im not sure why this code doesnt display anything. "TileNum" is how many tiles total there are. "XTiles" is the width of the board in Tiles. Each tile is 20X20 pixels.
If anyone has any tips Id greatly appreciate it
Code: Select all
repeat
MouseyX = love.mouse.getX()
MouseyY = love.mouse.getY()
Coord= Coord+1
X1 = X1 + 20 -- Starts as 0 (First tile has X coordinate 20)
X2 = X2 + 20 -- Starts at 20
if MouseyX >= X1 and MouseyX < X2 then -- Checks what column your mouse is in
repeat
Coord = Coord + XTiles -- Checks the tile directly below the last one
Y1 = Y1 +20 -- Starts at 0
Y2 = Y2 +20 -- Starts at 20
if MouseyY >= Y1 and MouseyY < Y2 then -- Checks what row your mouse is in
love.graphics.print("Tile ".."Type"..Tiletype2[Coord], 600,160)
end
until Coord >= TileNum
end
until Coord >= TileNum
X1 = 0
X2 = 20
Y1 = 0
Y2 = 20
Coord = 0