Open
Description
I'm trying to make a monochromatic pixel art styled game with a small resolution, using the pixelperfect mode of this library to scale it up without it becoming a blurry mess. However, when it scales the game up, it's exactly the same as with base love2d, incredibly blurry. My code is below, pls tell me if I'm doing something wrong
local push = require "push"
local gameWidth, gameHeight = 121, 68 --fixed game resolution
local windowWidth, windowHeight = love.window.getDesktopDimensions()
windowWidth, windowHeight = windowWidth*.7, windowHeight*.7 --make the window a bit smaller than the screen itself
push:setupScreen(gameWidth, gameHeight, windowWidth, windowHeight, {pixelperfect = true})
--local baseResolution = {121, 68}
--local scaleResolution = 2
--local windowResloution = {baseResolution[1]*scaleResolution, baseResolution[2]*scaleResolution}
--push:setupScreen(baseResolution[1], baseResolution[2], windowResloution[1], windowResloution[2])
function love.load()
--love.window.setMode(windowResloution[1], windowResloution[2])
playerStartPos = {1,2,2}
playerPos = playerStartPos
overlayImg = love.graphics.newImage("overlay.png")
maxHealth = 23
maxHeat = 23
startingHealth = 23
startingHeat = 0
playerHealth = startingHealth
playerHeat = startingHeat
gamestate = "game" --possible states: menu (in main menu) game (in the game) paused (in the pause menu) painting (in the painting minigame)
heldItem = "none"
lastKeyPressed = "none"
amountOfBoardPainted = {}
for i=1, 48 do
amountOfBoardPainted[i] = false
end
numOfBoards = 0
paintInBucket = 0
maxPaint = 100
end
function love.draw()
--love.graphics.scale(scaleResolution)
push:start()
if gamestate == "game" then
roomImg = love.graphics.newImage("/rooms/"..tostring(playerPos[1]).."/"..tostring(playerPos[2]).."/"..tostring(playerPos[3])..".png")
itemImg = love.graphics.newImage("/items/item_"..heldItem..".png")
love.graphics.draw(roomImg, 0, 0)
love.graphics.draw(overlayImg, 0, 0)
love.graphics.draw(itemImg, 0, 0)
love.graphics.setColor(1,1,1)
love.graphics.rectangle("fill", 6, 29-playerHealth, 1, playerHealth)
love.graphics.rectangle("fill", 6, 62-playerHeat, 1, playerHeat)
elseif gamestate == "painting" then
itemImg = love.graphics.newImage("/items/item_"..heldItem..".png")
love.graphics.draw(love.graphics.newImage("bg_painting.png"),0,0)
love.graphics.draw(itemImg, 0, 0)
if numOfBoards > 0 then
for i=1, table.getn(amountOfBoardPainted) do
local boardSegmentOffsetX = i*5-5
local boardSegmentOffsetY = 0
while boardSegmentOffsetX >= 60 do
boardSegmentOffsetX = boardSegmentOffsetX - 60
boardSegmentOffsetY = boardSegmentOffsetY + 5
end
if amountOfBoardPainted[i] == true then
love.graphics.draw(love.graphics.newImage("/painted_board_tiles/"..i..".png"), 38+boardSegmentOffsetX, 24+boardSegmentOffsetY)
else
love.graphics.draw(love.graphics.newImage("/unpainted_board_tiles/"..i..".png"), 38+boardSegmentOffsetX, 24+boardSegmentOffsetY)
end
end
end
love.graphics.draw(overlayImg,0,0)
love.graphics.rectangle("fill", 6, 29-playerHealth, 1, playerHealth)
love.graphics.rectangle("fill", 6, 62-playerHeat, 1, playerHeat)
end
push:finish()
--v debug stuff v
love.graphics.print(tostring(playerPos[1])..","..tostring(playerPos[2])..", "..tostring(playerPos[3]), 0, 10)
love.graphics.print(tostring(heldItem))
love.graphics.print(lastKeyPressed,0,20)
love.graphics.print(tostring(gameX)..","..tostring(gameY), 0, 30)
end
function love.keypressed(key, scancode, isRepeat)
if gamestate == "game" then
if key == "a" then
if playerPos[3] <= 1 then
playerPos[3] = 4
else
playerPos[3] = playerPos[3] - 1
end
end
if key == "d" then
if playerPos[3] >= 4 then
playerPos[3] = 1
else
playerPos[3] = playerPos[3] + 1
end
end
if key == "w" then
if checkPlayerPos(3,1,3) or checkPlayerPos(2,2,2) or checkPlayerPos(4,2,4) or checkPlayerPos(3,3,1) then
gamestate = "painting"
elseif playerPos[3] == 1 then
if playerPos[2] > 1 and playerPos[1] > 1 then
playerPos[2] = playerPos[2] - 1
end
elseif playerPos[3] == 2 then
if playerPos[1] < 4 then
playerPos[1] = playerPos[1] + 1
end
elseif playerPos[3] == 3 then
if playerPos[2] < 3 and playerPos[1] > 1 then
playerPos[2] = playerPos[2] + 1
end
elseif playerPos[3] == 4 then
if playerPos[1] > 1 then
playerPos[1] = playerPos[1] - 1
end
end
end
if key == "space" then
if checkPlayerPos(1,1,3) or checkPlayerPos(1,1,4) then
if heldItem == "none" then
heldItem = "board"
end
elseif checkPlayerPos(1,2,1) then
if heldItem == "none" then
heldItem = "paint"
end
end--elseif playerPos == {3,1,3} or playerPos == {2,2,2} or playerPos == {4,2,4} or playerPos == {3,3,1} then
end
end
if gamestate == "painting" then
if key == "s" then
gamestate = "game"
end
if key == "space" then
if heldItem == "board" then
numOfBoards = numOfBoards + 1
heldItem = "none"
elseif heldItem == "paint" then
paintInBucket = maxPaint
heldItem = "none"
end
end
end
lastKeyPressed = key
end
function love.update(dt)
if gamestate == "game" or gamestate == "painting" then
if checkPlayerPos(1,2) then
if playerHeat > 0 then
playerHeat = playerHeat - dt
end
elseif checkPlayerPos(4,1) then
if playerHeat > 0 then
playerHeat = playerHeat - dt/2
end
else
if playerHeat < maxHeat then
playerHeat = playerHeat + dt*2
else
playerHealth = playerHealth - dt*2
end
end
end
end
function checkPlayerPos(x, y, r)
local output = true
if x ~= nil then
if x ~= playerPos[1] then
output = false
end
end
if y ~= nil then
if y ~= playerPos[2] then
output = false
end
end
if r ~= nil then
if r ~= playerPos[3] then
output = false
end
end
return output
end
function love.mousemoved(x, y)
gameX, gameY = push:toGame(x, y)
if gamestate == "painting" then
if numOfBoards > 0 then
if gameX ~= nil and gameY ~= nil then
if gameX > 38 and gameX < 98 then
if gameY > 24 and gameY < 44 then
for i=1, table.getn(amountOfBoardPainted) do
local minX = i*5-5
local minY = 0
while minX >= 60 do
minX = minX - 60
minY = minY + 5
end
minX = minX + 38
minY = minY + 24
maxX = minX + 5
maxY = minY + 5
if gameX >= minX and gameX <= maxX and gameY >= minY and gameY <= maxY and paintInBucket > 0 and amountOfBoardPainted[i] == false then
paintInBucket = paintInBucket - 1
amountOfBoardPainted[i] = true
boardFullyPainted = true
for i=1, table.getn(amountOfBoardPainted) do
if amountOfBoardPainted[i] == false then
boardFullyPainted = false
end
end
if boardFullyPainted then
numOfBoards = numOfBoards - 1
for i=1, table.getn(amountOfBoardPainted) do
amountOfBoardPainted[i] = false
end
end
end
end
end
end
end
end
end
end
Metadata
Metadata
Assignees
Labels
No labels