Camera in 0.6.0

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
konsumer
Prole
Posts: 7
Joined: Wed Jan 06, 2010 5:16 am

Camera in 0.6.0

Post by konsumer » Wed Jan 06, 2010 5:20 am

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?

osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: Camera in 0.6.0

Post by osuf oboys » Wed Jan 06, 2010 5:35 pm

Sorry, Camera is not compliant with LÖVE 0.6.0. I will update it as soon as possible.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.

User avatar
konsumer
Prole
Posts: 7
Joined: Wed Jan 06, 2010 5:16 am

Re: Camera in 0.6.0

Post by konsumer » Wed Jan 06, 2010 7:30 pm

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.

stampede
Prole
Posts: 21
Joined: Fri Oct 23, 2009 8:22 am
Location: Finland
Contact:

Re: Camera in 0.6.0

Post by stampede » Thu Jan 07, 2010 6:34 am

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

User avatar
rude
Administrator
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Camera in 0.6.0

Post by rude » Thu Jan 07, 2010 2:48 pm

Protip for camera 0.6.0:

Code: Select all

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

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Camera in 0.6.0

Post by bartbes » Thu Jan 07, 2010 2:51 pm

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

User avatar
rude
Administrator
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Camera in 0.6.0

Post by rude » Thu Jan 07, 2010 2:54 pm

Something should add those to the docs.

igor
Prole
Posts: 21
Joined: Fri Nov 20, 2009 12:39 pm
Contact:

Re: Camera in 0.6.0

Post by igor » Thu Jan 07, 2010 7:37 pm

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()

User avatar
konsumer
Prole
Posts: 7
Joined: Wed Jan 06, 2010 5:16 am

Re: Camera in 0.6.0

Post by konsumer » Thu Jan 07, 2010 10:38 pm

Igor: it still doesn't do anything. that is for a mouse-based camera, right? I'm not using that.

User avatar
High Overlord
Prole
Posts: 6
Joined: Sat Dec 12, 2009 1:48 pm
Location: Uzice, Serbia

Re: Camera in 0.6.0

Post by High Overlord » Fri Jan 08, 2010 12:34 pm

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).
My software never has bugs. It just develops random features.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 10 guests