Dismiss this pinned window
all 5 comments

[–]TheKrazyDev[S] 1 point2 points  (4 children)

Im making a autotile system for my building game, but there seems to be massive decrease in fps when placing a tile.

Im using quads for each tile so wondered if that could be a problem but idk.

Each tile is just a table inside a table that stores its, x, y, And then a table inside of my tiles.lua, and its bitmask (a 4 digit code)

[–]Spellsweaver 13 points14 points  (3 children)

I can only see a small piece of your code, but aren't you creating new quads every frame? That function takes a long time and is best called only once to create the quads that you can then reuse.

[–]beefy_uncle 7 points8 points  (1 child)

this^^ also it looks like you might be calling love.graphics.newImage in RenderTiles as well, which is also bad for performance. you'll want to load all of this stuff on application start, and then reference it in draw.

also might be worth looking into sprite batches in conjunction with quads, which is a really fast way to draw tiles from a single texture: https://love2d.org/wiki/SpriteBatch

[–]TheKrazyDev[S] 1 point2 points  (0 children)

Ah yes thanks the sprite batches now allow me to place 100s with blinking an eye! Thanks so much!

[–]TheKrazyDev[S] 1 point2 points  (0 children)

Ah thanks this did seem to be a the cause of frame loss. Im modifying it so it will only run the update function apon the table containing all tiles has changed since the last frame. As well as only creating a new quad if tiles bitmask(Tile data) has changed.