Page 1 of 1

Stuck on displaying tile info

Posted: Sat Nov 26, 2022 1:14 am
by phil1010102
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.

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
    
If anyone has any tips Id greatly appreciate it

Re: Stuck on displaying tile info

Posted: Sat Nov 26, 2022 8:45 am
by pgimeno
Where's your drawing code? Is it possible that you're overwriting the texts with the tiles? Without a runnable example there's little we can do to help.