Ejemplo n.º 1
0
        public Enemy()
        {
            primitivesBuffer = new ConsolePrimitivesBuffer(1);

            primitivesBuffer.GetPrimitive(0).Graphics   = 'X';
            primitivesBuffer.GetPrimitive(0).Foreground = ConsoleColor.Red;
        }
Ejemplo n.º 2
0
        public Bullet()
        {
            primitivesBuffer = new ConsolePrimitivesBuffer(1);

            primitivesBuffer.GetPrimitive(0).Foreground = ConsoleColor.Green;
            primitivesBuffer.GetPrimitive(0).Graphics   = '^';
        }
Ejemplo n.º 3
0
        public Player()
        {
            x = 0;
            primitiveBuffer = new ConsolePrimitivesBuffer(1);

            primitiveBuffer.GetPrimitive(0).Graphics   = 'O';
            primitiveBuffer.GetPrimitive(0).Foreground = ConsoleColor.Cyan;
            primitiveBuffer.GetPrimitive(0).X          = 0;
            primitiveBuffer.GetPrimitive(0).Y          = 0;
        }
Ejemplo n.º 4
0
        public void Clean(ConsolePrimitivesBuffer buffer)
        {
            for (int i = 0; i < buffer.Count; i++)
            {
                var primitive = buffer.GetPrimitive(i);

                Console.SetCursorPosition(primitive.LastX, primitive.LastY);
                Console.Write(" ");
            }
        }
Ejemplo n.º 5
0
        public void Render(int x, int y, ConsolePrimitivesBuffer buffer)
        {
            for (int i = 0; i < buffer.Count; i++)
            {
                var primitive = buffer.GetPrimitive(i);

                if (!primitive.HasChanged)
                {
                    continue;
                }

                if (primitive.LastX != primitive.X + x || primitive.LastY != primitive.Y + y)
                {
                    Console.SetCursorPosition(primitive.LastX, primitive.LastY);
                    Console.Write(" ");
                }

                if (primitive.X + x < 0 ||
                    primitive.X + x >= Viewport.Width ||
                    primitive.Y + y < 0 ||
                    primitive.Y + y >= Viewport.Height)
                {
                    continue;
                }

                primitive.Store(Viewport.Left + primitive.X + x, Viewport.Top + primitive.Y + y);

                Console.SetCursorPosition(Viewport.Left + primitive.X + x, Viewport.Top + primitive.Y + y);
                Console.ForegroundColor = primitive.Foreground;
                Console.BackgroundColor = primitive.Background;

                Console.Write(primitive.Graphics);

                Console.ForegroundColor = ConsoleColor.White;
                Console.BackgroundColor = ConsoleColor.Black;
            }
        }