[SOLVED] Scaling and camera issues :'D [im probably very stoopid]
Posted: Mon Dec 04, 2023 5:06 pm
Hello hello!
I'm fairly new to this whole Love2D and lua stuff so please explain to me as simply as possible!
So i'm trying "to zoom in" with the camera system i have made for my little game project but i can't figure out how to do it even with some research.
The "y" doesn't do what i want it to do, as it shows in the two screenshots down here.
What did i mess up ? Help pretty please :'D !!!
Here's my very clumsy code:
Note: First image is the normal camera scale and second is the changed one.
For the changed on i thought just changing "scale" would work but no lol
So i tried tinkering around to understand but haven't found anything...
I'm fairly new to this whole Love2D and lua stuff so please explain to me as simply as possible!
So i'm trying "to zoom in" with the camera system i have made for my little game project but i can't figure out how to do it even with some research.
The "y" doesn't do what i want it to do, as it shows in the two screenshots down here.
What did i mess up ? Help pretty please :'D !!!
Here's my very clumsy code:
Code: Select all
local Camera = {
x = 0,
y = 0,
scale = 2,
}
function Camera:apply()
love.graphics.push()
love.graphics.scale(self.scale,self.scale)
love.graphics.translate(-self.x, -self.y)
end
function Camera:clear()
love.graphics.pop()
end
function Camera:setPosition(x, y)
self.x = x - love.graphics.getWidth() / 2 / self.scale
self.y = y - love.graphics.getHeight() / 2 / self.scale
local RX = self.x + love.graphics.getWidth() / 2
local RY = self.y + love.graphics.getHeight() / 2
local MapW, MapH = love.graphics.getDimensions()
if self.x < 0 then
self.x = 0
elseif RX > MapW then
self.x = MapW - love.graphics.getWidth() / 2
end
if self.y > 0 then
self.y = 0
elseif RY > MapH then
self.y = MapH + love.graphics.getHeight() / 2
end
end
return Camera
Note: First image is the normal camera scale and second is the changed one.
For the changed on i thought just changing "scale" would work but no lol
So i tried tinkering around to understand but haven't found anything...