I'm trying to make a space invaders clone, and I want to check to see if a bullet has hit the triangular ship. I can't really figure how to do this, so I've put in this makeshift solution:
but this is letting bullets hit the empty space around the skinny end of the ship. Does anyone have a better way to run this test?Code:for (i = 1; i <= numbullets; ++i) if (bullet[i].x >= ship.x - 10 && bullet[i].x <= ship.x + 10 && bullet[i].y >= ship.y - 15 && bullet[i].y <= ship.y && bullet[i].dy > 0) { ship.life -= 10; killbullet(bullet,i,numbullets); }
complete source/game