## HardonCollider and hump.camera?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
MiniDemonic
Prole
Posts: 28
Joined: Tue Mar 20, 2012 10:39 am

### HardonCollider and hump.camera?

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.

vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

### Re: HardonCollider and hump.camera?

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.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine

MiniDemonic
Prole
Posts: 28
Joined: Tue Mar 20, 2012 10:39 am

### Re: HardonCollider and hump.camera?

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.

Refpeuk
Citizen
Posts: 91
Joined: Wed Dec 14, 2011 6:16 pm

### Re: HardonCollider and hump.camera?

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.
Attachments
3rdperson.love
It was the best of times, it was the worst of times . . .

MiniDemonic
Prole
Posts: 28
Joined: Tue Mar 20, 2012 10:39 am

### Re: HardonCollider and hump.camera?

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.

vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

### Re: HardonCollider and hump.camera?

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()
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine

MiniDemonic
Prole
Posts: 28
Joined: Tue Mar 20, 2012 10:39 am

### Re: HardonCollider and hump.camera?

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.

vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

### Re: HardonCollider and hump.camera?

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.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine

MiniDemonic
Prole
Posts: 28
Joined: Tue Mar 20, 2012 10:39 am

### Re: HardonCollider and hump.camera?

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 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.

### Who is online

Users browsing this forum: Bing [Bot] and 19 guests