PDA

View Full Version : Sword LWeapons



LinktheMaster
10-06-2008, 12:14 AM
Okay, I'm using beta 864, and supposedly swords and hammers are now capable of being used.

However, I tried the following code for collision detection with swords based on a 2x2 FFC:



for(int x = 0; x < Screen->NumLWeapons(); x++)
{
lweapon weapon = Screen->LoadLWeapon(x);

if(weapon->ID == LW_SWORD)
{
if(weapon->X > this->X - 8 && weapon->X < this->X + 24 && weapon->Y > this->Y - 8 && weapon->Y < this->Y + 24)
{
HP--;
hit = true;
hitCounter = 30;
}
}
}


I also tried...



for(int x = 0; x < Screen->NumLWeapons(); x++)
{
lweapon weapon = Screen->LoadLWeapon(x);

int weaponX = weapon->X + 8;
int weaponY = weapon->Y + 8;
int thisX = this->X + 16;
int thisY = this->Y + 16;

if(weapon->ID == LW_SWORD)
{
if(Abs(weaponX - thisX) <= 16 && Abs(weaponY - thisY) <= 16)
{
HP--;
hit = true;
hitCounter = 30;
}
}
}


But neither work. If I remember correctly, that was the code for to check if previous LWeapons are in a box. It should work for everything else, but it's not working for the sword. :-/ Is there anything special that has to be done for this to work?

Thank you for any help.