Page 1 of 2

Camera in 0.6.0

Posted: Wed Jan 06, 2010 5:20 am
by konsumer
I can't seem to make it work right...

I am making a tiled map-loader, and I want it to load the entire map into screen mem, then scroll the camera around it, following the player.

Here is how I am using it:

Code: Select all

require("camera.lua")
player_location = {386, 626}
step_size = 10

function love.load()
	setCamera(camera.stretchToResolution(800, 600))
end

function love.update(dt)
	if love.keyboard.isDown( "up" ) then
		player_location[2] = player_location[2] - (step_size * dt)
	end
	if love.keyboard.isDown( "down" ) then
		player_location[2] = player_location[2] + (step_size * dt)
	end
	if love.keyboard.isDown( "left" ) then
		player_location[1] = player_location[1] - (step_size * dt)
	end
	if love.keyboard.isDown( "right" ) then
		player_location[1] = player_location[1] + (step_size * dt)
	end
	getCamera():setOrigin(player_location[1], player_location[2])
end

I have graphics loaded on the screen, starting at (0,0), and pressing keys doesn't do anything. Anybody know what I am doing wrong?

Re: Camera in 0.6.0

Posted: Wed Jan 06, 2010 5:35 pm
by osuf oboys
Sorry, Camera is not compliant with LÖVE 0.6.0. I will update it as soon as possible.

Re: Camera in 0.6.0

Posted: Wed Jan 06, 2010 7:30 pm
by konsumer
No problem. Your post on the other message seems like a better way to do it, actually. I like the idea of just displaying visible tiles of the map. Seems like it could handle much bigger maps pretty efficiently. thanks for your help.

Re: Camera in 0.6.0

Posted: Thu Jan 07, 2010 6:34 am
by stampede
osuf oboys wrote:Sorry, Camera is not compliant with LÖVE 0.6.0. I will update it as soon as possible.
Remember to provide old camera version for 0.5 too, don't delete it <3

Re: Camera in 0.6.0

Posted: Thu Jan 07, 2010 2:48 pm
by rude
Protip for camera 0.6.0:

Code: Select all

love.graphics.translate
love.graphics.scale
etc
Someone should add those to the docs. :megagrin:

Re: Camera in 0.6.0

Posted: Thu Jan 07, 2010 2:51 pm
by bartbes
rude wrote:Someone should add those to the docs. :megagrin:
Last time I checked you were a person and I was a machine, so, you qualify for someone, while I don't... :P

Re: Camera in 0.6.0

Posted: Thu Jan 07, 2010 2:54 pm
by rude
Something should add those to the docs.

Re: Camera in 0.6.0

Posted: Thu Jan 07, 2010 7:37 pm
by igor
konsumer wrote:I can't seem to make it work right...

I am making a tiled map-loader, and I want it to load the entire map into screen mem, then scroll the camera around it, following the player.

Here is how I am using it:

Code: Select all

require("camera.lua")
player_location = {386, 626}
step_size = 10

function love.load()
	setCamera(camera.stretchToResolution(800, 600))
end

function love.update(dt)
	if love.keyboard.isDown( "up" ) then
		player_location[2] = player_location[2] - (step_size * dt)
	end
	if love.keyboard.isDown( "down" ) then
		player_location[2] = player_location[2] + (step_size * dt)
	end
	if love.keyboard.isDown( "left" ) then
		player_location[1] = player_location[1] - (step_size * dt)
	end
	if love.keyboard.isDown( "right" ) then
		player_location[1] = player_location[1] + (step_size * dt)
	end
	getCamera():setOrigin(player_location[1], player_location[2])
end

I have graphics loaded on the screen, starting at (0,0), and pressing keys doesn't do anything. Anybody know what I am doing wrong?
You'v missed camera:lateInit()

Re: Camera in 0.6.0

Posted: Thu Jan 07, 2010 10:38 pm
by konsumer
Igor: it still doesn't do anything. that is for a mouse-based camera, right? I'm not using that.

Re: Camera in 0.6.0

Posted: Fri Jan 08, 2010 12:34 pm
by High Overlord
This is the official camera topic(or so it seems), so i will post this here.

As we all see, Love is "a bit" raster dependant, or it was, before camera came out. Dimensions in camera aren't in pixels, so camera is free from raster chains, but when you zoom the screen, it gets blocky, because it is still using raster images. Is it possible to make Love support vector images(eg. *.svg) via camera? I know it would need a lot of changes(eg. animations, because it is hard to pinpoint the width of a frame on a vector), but it all could be solved with a bit of brainstorming. That way games would work perfectly on all resolutions(if CPU can cope with vectors, which on modern computers shouldn't be a problem).