Cameraman - Stupidly simple Cameras.
Posted: Thu Oct 25, 2012 2:42 am
So this is Cameraman. A stupidly simple camera lib that Ensayia helped me make after a lot of debugging... It's not meant for giant 50k+ sprite games, just simple little things, this is mostly due to the lack of features..
Here it is:
Attached is a demo on how it works (the demo does not use DT)
The main reason for making this is I needed a stupidly simple camera package. This doesn't even support scaling! It's perfect for top down games how ever.
-edit-
Fixed file structure
Here it is:
Code: Select all
-- CameraMan 1.0, the first thing in Love2D with a appropriate name!
-- Credits:
-- iToast - design
-- Ensayia - Usefull example / suggestions
camera = {}
camera.x = 0
camera.y = 0
function updateCamera(ox, oy, wd, wh)
if ox == nil or oy == nil or wd == nil or wh == nil then
ox = 0
oy = 0
wd = 0
wh = 0
end
camera.x = -ox + (wd / 2)
camera.y = -oy + (wh / 2)
end
function pushCamera()
love.graphics.push()
love.graphics.translate(camera.x, camera.y)
end
function popCamera()
love.graphics.pop()
end
-- example by Ensayia
-- pushCamera()
-- love.graphics.draw(image, x + camera.x, y + camera.y)
--and everything else
-- popCamera()
-- Notes by iToast
-- Player doesn't get drawn between pushCamera() and popCamera()
The main reason for making this is I needed a stupidly simple camera package. This doesn't even support scaling! It's perfect for top down games how ever.
-edit-
Fixed file structure