[SOLVED] push.lua and love.graphics.newQuad problem
Posted: Thu May 16, 2024 4:56 pm
Hello everyone!
I write this post because I have a problem with push.lua and love.graphics.newQuad. I know that here are many love2d experts and maybe someone can help me. Ok so I've done a app:
Where you can use mode to control app. With mode equals 1 app runs with push otherwise without it. Result
As you can see, there is a 1-pixel border at the edge of the tile and I don't know how to get rid of it. This is actually the most important part of this thread. You know how to get rid of this border. You can see it better when you scale it up, but to compare it with the version without push, I used such a low resolution.
Addons:
push.lua : https://github.com/Ulydev/push/blob/master/push.lua
tiles.png:
I write this post because I have a problem with push.lua and love.graphics.newQuad. I know that here are many love2d experts and maybe someone can help me. Ok so I've done a app:
Code: Select all
push = require 'push'
virtualWidth = 33 * 16
virtualHeight = 28 * 16
windowWidth = 33 * 16
windowHeight = 28 * 16
mode = 1
function generateQuads(atlas, tilewidth, tileheight)
local sheetWidth = atlas:getWidth() / tilewidth
local sheetHeight = atlas:getHeight() / tileheight
local sheetCounter = 1
local quads = {}
for y = 0, sheetHeight - 1 do
for x = 0, sheetWidth - 1 do
-- this quad represents a square cutout of our atlas that we can
-- individually draw instead of the whole atlas
quads[sheetCounter] =
love.graphics.newQuad(x * tilewidth, y * tileheight, tilewidth,
tileheight, atlas:getDimensions())
sheetCounter = sheetCounter + 1
end
end
return quads
end
function love.load()
spriteSheets = love.graphics.newImage("tiles.png")
tilesSprite = generateQuads(spriteSheets, 16, 16)
love.window.setMode(33*16, 28*16)
love.graphics.setDefaultFilter('nearest', 'nearest')
love.window.setTitle("With push")
-- sets up virtual screen resolution for an authentic retro feel
if mode == 1 then
push:setupScreen(virtualWidth, virtualHeight, windowWidth, windowHeight, {
fullscreen = false,
resizable = false
})
end
end
-- called whenever window is resized
function love.resize(w, h)
if mode == 1 then
push:resize(w, h)
end
end
function love.update(dt)
end
function love.draw()
if mode == 0 then
love.graphics.clear(255, 255, 255)
local index = 1
for x = 1, 33 do
for y = 1, 28 do
love.graphics.draw(spriteSheets, tilesSprite[index], (y - 1) * 16, (x - 1) * 16)
index = index + 1
end
end
end
if mode == 1 then
-- begin virtual resolution drawing
push:apply('start')
-- clear screen using Mario background blue
love.graphics.clear(108, 140, 255, 255)
local index = 1
for x = 1, 33 do
for y = 1, 28 do
love.graphics.draw(spriteSheets, tilesSprite[index], (y - 1) * 16, (x - 1) * 16)
index = index + 1
end
end
push:apply('end')
end
end
As you can see, there is a 1-pixel border at the edge of the tile and I don't know how to get rid of it. This is actually the most important part of this thread. You know how to get rid of this border. You can see it better when you scale it up, but to compare it with the version without push, I used such a low resolution.
Addons:
push.lua : https://github.com/Ulydev/push/blob/master/push.lua
tiles.png: