This is the glitch which appears when i add love.graphics.setDefaultFilter('nearest','nearest'). This is without love.graphics.setDefaultFilter('nearest','nearest'). This is the code:
Code: Select all
push = require 'push'
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
VIRTUAL_WIDTH =512
VIRTUAL_HEIGHT = 288
local background = love.graphics.newImage('background.png')
local backScroll =0
local BACKGROUND_SCROLL_SPEED = 20
local BACKGROUND_LOPPING_POINT = 413
local ground = love.graphics.newImage('ground.png')
local groundScroll = 0
local GROUND_SCROLL_SPEED = 60
function love.load()
--love.graphics.setDefaultFilter('nearest','nearest')
love.window.setTitle('Bad Bird')
push:setupScreen(VIRTUAL_WIDTH,VIRTUAL_HEIGHT,WINDOW_WIDTH,WINDOW_HEIGHT,{
vsync = true,
fullscreen = false,
resizeable = true
})
end
function love.resize(w,h)
push:resize(w,h)
-- body
end
function love.keypressed(key)
if key == 'escape' then
love.event.quit()
end
end
function love.update(dt)
backScroll = (backScroll+ BACKGROUND_SCROLL_SPEED * dt) % BACKGROUND_LOPPING_POINT
--To perform the reset of the pos of the background we use %
groundScroll = (groundScroll + GROUND_SCROLL_SPEED * dt) % VIRTUAL_WIDTH
end
function love.draw()
push:start()
love.graphics.draw(background,-backScroll,0)
love.graphics.draw(ground,-groundScroll,VIRTUAL_HEIGHT-16)
push:finish()
end