Cameraman - Stupidly simple Cameras.

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
iToast
Prole
Posts: 1
Joined: Thu Oct 25, 2012 2:38 am

Cameraman - Stupidly simple Cameras.

Post by iToast »

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:

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()
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
Attachments
Cameraman.love
(926 Bytes) Downloaded 186 times
Cameraman.love
(1.07 KiB) Downloaded 168 times
Post Reply

Who is online

Users browsing this forum: No registered users and 200 guests