Page 1 of 1

I have a HardonCollider problem

Posted: Thu May 03, 2012 5:50 am
by superdajk
Hey there,

I'm having a problem with the HardonCollider collision library. I'm currently working on a Super Crate Box kind of game, but with 2D Zelda gameplay, to practice and improve my still amateur programming. In the game, you pick up crates which give you a new weapon every time (you discard your previous one) but they also increase your score. I've made it so that when you pick up a crate your new weapon is put in a table, together with a few of your previous weapons. This way I can do some fun stuff later with the discarded weapons. I'm using middleclass for OOP.

I can successfully refer to the current equipped weapon with player.weapon.equip[#player.weapon.equip] (such as player.weapon.equip[#player.weapon.equip]:fire(), or something).

As I said, I am working with HardonCollider. I'm doing my collision stuff with the on_collide callback, which worked fine for everything I threw at it. For some reason though, when I try something like:

Code: Select all

if shape_a == player.weapon.equip[#player.weapon.equip].cBox and shape_b == zombie.cBox then
		print("Zombie hit by " .. tostring(player.weapon.equip[#player.weapon.equip]))
	end
Only the first weapon equipped appears to be responding with the zombie object.

I can't figure out what is going wrong. If somebody could help me, I would be very grateful! I've attached the .love file.

Cheers

Re: I have a HardonCollider problem

Posted: Thu May 03, 2012 8:52 pm
by Puzzlem00n
I'm not sure exactly what you mean by this, as I can't tell what's supposed to be happening in your example. What do you mean when you say "responds to the zombie object?" When I play, I can't tell if anything's happening with the first weapon, either.