/// <summary> /// Method to detect if pixel from the missile touch an other pixel /// from the current object. If it's true so OnCollision method is called /// </summary> /// <param name="m">The missile with test collision</param> private void PixelByPixel(Missile m) { for (int i = 0; i < m.Image.Height; i++) { for (int j = 0; j < m.Image.Width; j++) { var inter = new Vecteur2d(j - Position.X + m.Position.X, i - Position.Y + m.Position.Y); if (inter.X < Image.Width && inter.Y < Image.Height && inter.X > 0 && inter.Y > 0) { if (Image.GetPixel((int)inter.X, (int)inter.Y) == Color.FromArgb(255, 0, 0, 0)) { OnCollision(m, inter); } } } } }
/// <summary> /// A Lovely abstract constructor to generate a simple object /// </summary> /// <param name="position">The position</param> /// <param name="lives">The number of lives</param> /// <param name="image">The image</param> /// <param name="side">The side</param> protected SimpleObject(Vecteur2d position, int lives, Bitmap image, Side side) : base(position, side) { Lives = lives; Image = new Bitmap(image); }
/// <summary> /// Method to manage the collision if this one appens. /// </summary> /// <param name="m">The missile in collision</param> /// <param name="collisionPoint">A vector with the position of the collision point</param> protected abstract void OnCollision(Missile m, Vecteur2d collisionPoint);