コード例 #1
0
ファイル: Form1.cs プロジェクト: Ni1k001/TiPPGK4
        public void DrawPoints(PolygonSprite p1, PolygonSprite p2)
        {
            p1.CheckCollision(p2);

            for (int i = 0; i < p1.vertices; i++)
            {
                if (i == 0)
                {
                    for (int j = 0; j < p1.vertices; j++)
                    {
                        _graphics.DrawRectangle(Pens.Red, p1.shadows[j + (i * p1.vertices) + (i * p2.vertices)].X, p1.shadows[j + (i * p1.vertices) + (i * p2.vertices)].Y, 1, 1);
                    }
                    for (int j = 0; j < p2.vertices; j++)
                    {
                        _graphics.DrawRectangle(Pens.Aqua, p1.shadows[p1.vertices + j + (i * p2.vertices) + (i * p1.vertices)].X, p1.shadows[p1.vertices + j + (i * p2.vertices) + (i * p1.vertices)].Y, 1, 1);
                    }
                }
                else if (i == 1)
                {
                    for (int j = 0; j < p1.vertices; j++)
                    {
                        _graphics.DrawRectangle(Pens.Green, p1.shadows[j + (i * p1.vertices) + (i * p2.vertices)].X, p1.shadows[j + (i * p1.vertices) + (i * p2.vertices)].Y, 1, 1);
                    }
                    for (int j = 0; j < p2.vertices; j++)
                    {
                        _graphics.DrawRectangle(Pens.Orange, p1.shadows[p1.vertices + j + (i * p2.vertices) + (i * p1.vertices)].X, p1.shadows[p1.vertices + j + (i * p2.vertices) + (i * p1.vertices)].Y, 1, 1);
                    }
                }
                else if (i == 2)
                {
                    for (int j = 0; j < p1.vertices; j++)
                    {
                        _graphics.DrawRectangle(Pens.Brown, p1.shadows[j + (i * p1.vertices) + (i * p2.vertices)].X, p1.shadows[j + (i * p1.vertices) + (i * p2.vertices)].Y, 1, 1);
                    }
                    for (int j = 0; j < p2.vertices; j++)
                    {
                        _graphics.DrawRectangle(Pens.Violet, p1.shadows[p1.vertices + j + (i * p2.vertices) + (i * p1.vertices)].X, p1.shadows[p1.vertices + j + (i * p2.vertices) + (i * p1.vertices)].Y, 1, 1);
                    }
                }
                else if (i == 3)
                {
                    for (int j = 0; j < p1.vertices; j++)
                    {
                        _graphics.DrawRectangle(Pens.Blue, p1.shadows[j + (i * p1.vertices) + (i * p2.vertices)].X, p1.shadows[j + (i * p1.vertices) + (i * p2.vertices)].Y, 1, 1);
                    }
                    for (int j = 0; j < p2.vertices; j++)
                    {
                        _graphics.DrawRectangle(Pens.DarkSeaGreen, p1.shadows[p1.vertices + j + (i * p2.vertices) + (i * p1.vertices)].X, p1.shadows[p1.vertices + j + (i * p2.vertices) + (i * p1.vertices)].Y, 1, 1);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Ni1k001/TiPPGK4
 public void GetCollision(PolygonSprite other)
 {
     if (CheckCollision(other))
     {
         //Debug.WriteLine("1. TRUE");
         if (other.CheckCollision(this))
         {
             //Debug.WriteLine("2. TRUE");
             isColliding = true;
         }
         else
         {
             //Debug.WriteLine("2. FALSE");
             isColliding = false;
         }
     }
     else
     {
         //Debug.WriteLine("1. FALSE");
         isColliding = false;
     }
 }