Stuck on displaying tile info

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
phil1010102
Prole
Posts: 1
Joined: Sat Nov 26, 2022 12:57 am

Stuck on displaying tile info

Post 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
User avatar
pgimeno
Party member
Posts: 3657
Joined: Sun Oct 18, 2015 2:58 pm

Re: Stuck on displaying tile info

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests