You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
push = require 'push'
-- close resolution to NES but 16:9
virtualWidth = 33 * 16
virtualHeight = 28 * 16
-- actual window resolution
windowWidth = 33 * 16
windowHeight = 28 * 16
mode = 0
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.window.setTitle("Without push")
love.graphics.setDefaultFilter('nearest', 'nearest')
-- 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
You can use mode variable 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.
Hello,
I created a program:
You can use mode variable 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.
I also create thread in love2d forum about that: https://www.love2d.org/forums/viewtopic.php?t=95753
The text was updated successfully, but these errors were encountered: