Page 1 of 1

HardonCollider and hump.camera?

Posted: Fri Mar 30, 2012 3:32 pm
by MiniDemonic
Is there a simple way to use HardonCollider+hump.camera to effectively pan the view on a top down shooter?
I've been trying for ages to get it to work, but I can't get the HardonCollider objects to stay at the place where they belong.
Also, is there anything like shape:moveTo() for the hump.camera class? Moving the cam using moveTo would be easier than move in some cases.

Re: HardonCollider and hump.camera?

Posted: Fri Mar 30, 2012 3:42 pm
by vrld
MiniDemonic wrote:I've been trying for ages to get it to work, but I can't get the HardonCollider objects to stay at the place where they belong.
I don't quite understand what you mean. The camera does not affect the position of anything in the game world, just where it is drawn. Are you sure you draw the objects between a cam:attach()/cam:detach() pair? Could you provide some example code (or even better a .love)?
MiniDemonic wrote:Also, is there anything like shape:moveTo() for the hump.camera class? Moving the cam using moveTo would be easier than move in some cases.
Yes:
hump.camera documentation wrote:To set the position, use camera.pos = some_vector or camera.pos.x, camera.pos.y = new_x, new_y.

Re: HardonCollider and hump.camera?

Posted: Fri Mar 30, 2012 4:55 pm
by MiniDemonic
The camera is working fine for all the drawn objects, but I want the hardoncollider objects to keep their position relative to where the camera is moving, I know that the camera doesn't affect the objects which is why I need help with a function to move the objects to their correct positions.

Re: HardonCollider and hump.camera?

Posted: Fri Mar 30, 2012 6:40 pm
by Refpeuk
I'm not sure why you'd want to move the collision shapes without their sprites (unless I've misunderstood what you want)

I've attached a really basic .love of 3rd person top down game I just started working on. I've reverted back to 0.7.2 since the 0.8.0 version wasn't working. I use hardoncollider and hump.camera for my collision and viewport, you can read the code to see how. (you can also delete the black blocks after pressing 0 or replace them after pressing 1)

Hope it helps.

Re: HardonCollider and hump.camera?

Posted: Fri Mar 30, 2012 8:31 pm
by MiniDemonic
Well I am using AdvTiledLoader to draw the tilemaps, the sprites and the collision objects are separated, which means that I need to move the collision objects with the tilemap, unless there is a way to draw the tiles on the collision objects using AdvTileLoader.

Re: HardonCollider and hump.camera?

Posted: Sun Apr 01, 2012 1:06 pm
by vrld
MiniDemonic wrote:I want the hardoncollider objects to keep their position relative to where the camera is moving,
You can get the camera position using cam.pos (as already mentioned). I've never done anything with the advanced tiled loader, but from the example it should work about like this:

Code: Select all

global.tx = cam.pos.x
global.ty = cam.pos.y
global.scale = cam.zoom
Edit: Having a more detailed look at the example code, it seems as though you are doing it wrong. This is probably how you should do it:

Code: Select all

local x,y = cam:worldCoords(0,0):unpack()
local w,h = love.graphics.getWidth()/cam.zoom, love.graphics.getHeight()/cam.zoom
map:setDrawRange(x,y,w,h)

cam:attach()
map:draw() 
cam:detach()

Re: HardonCollider and hump.camera?

Posted: Mon Apr 02, 2012 10:29 pm
by MiniDemonic
Sorry for late response, I've been busy and haven't been able to check the forum.

I appreciate your efforts vrld, but that didn't achieve what I was looking for, I abandoned the scrolling map idea and is going to stick with a normal "switch map at screen edge" kind of deal. (will probably use entities in the game instead of checking for the screen edge)

If someone does however know how to do it then I appreciate the help.
Although I'm starting to think that it is impossible to do scrolling maps with AdvTiledLoader+HardonCollider.

Re: HardonCollider and hump.camera?

Posted: Tue Apr 03, 2012 9:11 am
by vrld
MiniDemonic wrote:Although I'm starting to think that it is impossible to do scrolling maps with AdvTiledLoader+HardonCollider.
It's possible. More or less using the way I showed you.

Re: HardonCollider and hump.camera?

Posted: Tue Apr 03, 2012 2:03 pm
by MiniDemonic
Thanks once again, I checked out the link you gave me and I found out how to accomplish what I was looking for.
It is now working as I expected :D You will see my game soon enough, just need to remove a few bugs and add a couple of stuff.

The game is going to be a singleplayer zombie shooter rpg, might try to make it online in the future but need to get better at love2d first.

The game will cycle between night and day every 10 minutes, and on the day you are supposed to go around and search for food/ammo, on the night you need to survive the zombie horde.

Upon gaining enough exp you will level up and be able to choose from a set of stats, i.e Ammo Capacity, Health, Speed, Reload Speed, Stamina etc etc.