Ejemplo n.º 1
0
        public static void RenderHero(Hero hero, string move = "None")
        {
            if (move == "Right")
            {
                ClearHeroSigns(hero, move);
                hero.LocationX++;
                if (hero.LocationX > (windowWidth / 2))
                {
                    Console.SetWindowPosition(windowsX++, windowsY);
                }
            }
            else if (move == "Left")
            {
                ClearHeroSigns(hero, move);
                hero.LocationX--;
                if (hero.LocationX > (windowWidth / 2))
                {
                    Console.SetWindowPosition(windowsX--, windowsY);
                }
            }

            Console.SetCursorPosition(hero.LocationX, hero.LocationY);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write('@');
            Console.SetCursorPosition(hero.LocationX, hero.LocationY+1);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write('@');
        }
Ejemplo n.º 2
0
 /* taka moje da izglejda Moving() za hero, ako oprostim renderEngine-a
 public void Moving()
 {
     ConsoleKeyInfo inputKey = Console.ReadKey();
     if (inputKey.Key == ConsoleKey.RightArrow)
     {
         RenderEngine.RenderHero("Right");
     }
     else if (inputKey.Key == ConsoleKey.LeftArrow)
     {
         RenderEngine.RenderHero("Left");
     }
 }
  */
 public void MovingHero(Hero mario)
 {
     ConsoleKeyInfo inputKey = Console.ReadKey();
     if (inputKey.Key == ConsoleKey.RightArrow)
     {
         RenderEngine.RenderHero(mario,"Right");
     }
     else if (inputKey.Key == ConsoleKey.LeftArrow)
     {
         RenderEngine.RenderHero(mario,"Left");
     }
 }
Ejemplo n.º 3
0
        private static void Main()
        {
            RenderEngine.RenderMap();
            Hero superMario = new Hero();
            //test na rendvaneto na kostenurka
            Turtle turtle = new Turtle(500, 100, 42);

            //RenderEngine.RenderHero(superMario);

            while (true)
            {
                turtle.Moving();
                superMario.MovingHero(superMario);
            }
        }
Ejemplo n.º 4
0
        public static void RenderHero(Hero hero, string move = "None")
        {
            if (move == "Right")
            {
                ClearHeroSigns(hero, move);
                hero.LocationX++;
                if (hero.LocationX > (windowWidth / 2))
                {
                    Console.SetWindowPosition(windowsX++, windowsY);
                }
            }
            else if (move == "Left")
            {
                ClearHeroSigns(hero, move);
                hero.LocationX--;
            }

            Console.SetCursorPosition(hero.LocationX, hero.LocationY);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(new String(Pixel, 5));
            Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 1);
            Console.Write(new String(Pixel, 9));
            Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 2);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 3));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 2));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 1));
            Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 3);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 3));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 4);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 2));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 3));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 5);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 2));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 4));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 4));
            Console.SetCursorPosition(hero.LocationX, hero.LocationY + 6);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 7));
            Console.SetCursorPosition(hero.LocationX - 3, hero.LocationY + 7);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 2));
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(new String(Pixel, 10));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 2));
            Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 8);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX + 4, hero.LocationY + 8);
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 9);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX + 5, hero.LocationY + 9);
            Console.Write(new String(Pixel, 3));
        }
Ejemplo n.º 5
0
 private static void ClearHeroSigns(Hero hero, string direction)
 {
     switch (direction)
     {
         case "Right":
             Console.SetCursorPosition(hero.LocationX, hero.LocationY);
             Console.ForegroundColor = backgroundColors[hero.LocationX, hero.LocationY];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 1);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 1, hero.LocationY + 1];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 2);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 1, hero.LocationY + 2];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 3);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 3];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 4);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 4];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 5);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 5];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX, hero.LocationY + 6);
             Console.ForegroundColor = backgroundColors[hero.LocationX, hero.LocationY + 6];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX - 3, hero.LocationY + 7);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 3, hero.LocationY + 7];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 8);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 1, hero.LocationY + 8];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 4, hero.LocationY + 8);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 4, hero.LocationY + 8];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 9);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 9];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 5, hero.LocationY + 9);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 5, hero.LocationY + 9];
             Console.Write(Pixel);
             break;
         case "Left":
             Console.SetCursorPosition(hero.LocationX + 4, hero.LocationY);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 4, hero.LocationY];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 8, hero.LocationY + 1);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 8, hero.LocationY + 1];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 5, hero.LocationY + 2);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 5, hero.LocationY + 2];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 7, hero.LocationY + 3);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 7, hero.LocationY + 3];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 8, hero.LocationY + 4);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 8, hero.LocationY + 4];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 7, hero.LocationY + 5);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 7, hero.LocationY + 5];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 6, hero.LocationY + 6);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 6, hero.LocationY + 6];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 10, hero.LocationY + 7);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 10, hero.LocationY + 7];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 1, hero.LocationY + 8);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 1, hero.LocationY + 8];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 6, hero.LocationY + 8);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 6, hero.LocationY + 8];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX , hero.LocationY + 9);
             Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 9];
             Console.Write(Pixel);
             Console.SetCursorPosition(hero.LocationX + 7, hero.LocationY + 9);
             Console.ForegroundColor = backgroundColors[hero.LocationX + 7, hero.LocationY + 9];
             Console.Write(Pixel);
             break;
         default:
             break;
     }
 }
Ejemplo n.º 6
0
 private static void ClearHeroSigns(Hero hero, string direction)
 {
     switch (direction)
     {
         case "Right":
             Console.SetCursorPosition(hero.LocationX, hero.LocationY);
             Console.ForegroundColor = ConsoleColor.Black;
             Console.Write(' ');
             Console.SetCursorPosition(hero.LocationX, hero.LocationY+1);
             Console.ForegroundColor = ConsoleColor.White;
             Console.Write(' ');
             break;
         case "Left":
             Console.SetCursorPosition(hero.LocationX, hero.LocationY);
             Console.ForegroundColor = ConsoleColor.Black;
             Console.Write(' ');
             Console.SetCursorPosition(hero.LocationX, hero.LocationY+1);
             Console.ForegroundColor = ConsoleColor.White;
             Console.Write(' ');
             break;
         default:
             break;
     }
 }
Ejemplo n.º 7
0
        public static void RenderHero(Hero hero, string move = "None")
        {
            if (move == "Right")
            {
                ClearHeroSigns(hero, move);
                hero.LocationX++;
                if (hero.LocationX > (windowWidth / 2))
                {
                    Console.SetWindowPosition(windowsX++, windowsY);
                }
            }
            else if (move == "Left")
            {
                ClearHeroSigns(hero, move);
                hero.LocationX--;
            }

            Console.SetCursorPosition(hero.LocationX, hero.LocationY);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(new String(Pixel, 5));
            Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 1);
            Console.Write(new String(Pixel, 9));
            Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 2);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 3));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 2));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 1));
            Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 3);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 3));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 4);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 2));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 3));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 1));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 5);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 2));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 4));
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 4));
            Console.SetCursorPosition(hero.LocationX, hero.LocationY + 6);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 7));
            Console.SetCursorPosition(hero.LocationX - 3, hero.LocationY + 7);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 2));
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(new String(Pixel, 10));
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(new String(Pixel, 2));
            Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 8);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX + 4, hero.LocationY + 8);
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 9);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(new String(Pixel, 3));
            Console.SetCursorPosition(hero.LocationX + 5, hero.LocationY + 9);
            Console.Write(new String(Pixel, 3));
        }
Ejemplo n.º 8
0
        private static void ClearHeroSigns(Hero hero, string direction)
        {
            switch (direction)
            {
            case "Right":
                Console.SetCursorPosition(hero.LocationX, hero.LocationY);
                Console.ForegroundColor = backgroundColors[hero.LocationX, hero.LocationY];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 1);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 1, hero.LocationY + 1];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 2);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 1, hero.LocationY + 2];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 3);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 3];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 4);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 4];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 5);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 5];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX, hero.LocationY + 6);
                Console.ForegroundColor = backgroundColors[hero.LocationX, hero.LocationY + 6];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX - 3, hero.LocationY + 7);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 3, hero.LocationY + 7];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX - 1, hero.LocationY + 8);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 1, hero.LocationY + 8];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 4, hero.LocationY + 8);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 4, hero.LocationY + 8];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX - 2, hero.LocationY + 9);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 9];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 5, hero.LocationY + 9);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 5, hero.LocationY + 9];
                Console.Write(Pixel);
                break;

            case "Left":
                Console.SetCursorPosition(hero.LocationX + 4, hero.LocationY);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 4, hero.LocationY];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 8, hero.LocationY + 1);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 8, hero.LocationY + 1];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 5, hero.LocationY + 2);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 5, hero.LocationY + 2];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 7, hero.LocationY + 3);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 7, hero.LocationY + 3];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 8, hero.LocationY + 4);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 8, hero.LocationY + 4];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 7, hero.LocationY + 5);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 7, hero.LocationY + 5];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 6, hero.LocationY + 6);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 6, hero.LocationY + 6];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 10, hero.LocationY + 7);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 10, hero.LocationY + 7];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 1, hero.LocationY + 8);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 1, hero.LocationY + 8];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 6, hero.LocationY + 8);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 6, hero.LocationY + 8];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX, hero.LocationY + 9);
                Console.ForegroundColor = backgroundColors[hero.LocationX - 2, hero.LocationY + 9];
                Console.Write(Pixel);
                Console.SetCursorPosition(hero.LocationX + 7, hero.LocationY + 9);
                Console.ForegroundColor = backgroundColors[hero.LocationX + 7, hero.LocationY + 9];
                Console.Write(Pixel);
                break;

            default:
                break;
            }
        }