Exemplo n.º 1
0
            public static void Line(Resource.Position p1, Resource.Position p2)
            {
                if (p1.X == p2.X)
                {
                    return;
                }
                double k = (p2.Y - p1.Y) / (p2.X - p1.X);

                int y(int x) => (int)(k * (x - p1.X) + p1.Y);

                if (p1.X < p2.X)
                {
                    for (int x = p1.X; x < p2.X; x++)
                    {
                        ExtendedConsole.SetChar(x, y(x), '#');
                    }
                }
                else
                {
                    for (int x = p2.X; x < p1.X; x++)
                    {
                        ExtendedConsole.SetChar(x, y(x), '#');
                    }
                }
            }
Exemplo n.º 2
0
 public static Resource.Position PositionOnConsole(Resource.Position position)
 {
     return(new Resource.Position(
                PositionOnConsoleX(position.X),
                PositionOnConsoleY(position.Y)
                ));
 }
Exemplo n.º 3
0
 public static Resource.Position PositionOnScreen(Resource.Position position)
 {
     return(new Resource.Position(
                PositionOnScreenX(position.X),
                PositionOnScreenX(position.Y)
                ));
 }
Exemplo n.º 4
0
 public static void Shoot(System.Windows.Forms.MouseButtons mb, DCG.Resource.Position mp)
 {
     if (mb == System.Windows.Forms.MouseButtons.Left)
     {
         Actions.Draw.Line(new DCG.Resource.Position(ball.X, ball.Y), DCG.Actions.PositionOnConsole(mp));
         int    x     = Actions.PositionOnScreenX(ball.X);
         int    y     = Actions.PositionOnScreenY(ball.Y);
         double dy    = mp.Y - y;
         double dx    = mp.X - x;
         double angle = Math.Atan(dy / dx);
         Console.SetCursorPosition(0, 0);
         Console.WriteLine($"{dy}/{dx}");
         Console.WriteLine((int)(angle * 180 / Math.PI));
         GameEngine.CurrentScene.Objects.Add(
             new Projectile(
                 (2 * ball.X + ball.Sprite.Width) / 2,
                 (2 * ball.Y + ball.Sprite.Height) / 2,
                 angle
                 )
             );
     }
 }