예제 #1
0
 public GameView(int lvl, int speed, bool muzik)
 {
     // wonsz = new Snake(lvl, speed, muzik);
     this.muzik = muzik;
     this.speed = speed;
     this.lvl = lvl;
     InitializeComponent();
     usun_stara_glowe(new Koordynaty(10, 20));
     wonsz = new Snake(lvl, speed, muzik);
     oThread = new Thread(wonsz.snakeLoop);
     oThread.SetApartmentState(ApartmentState.STA);
     oThread.Start();
     while (!oThread.IsAlive) ;
 }
예제 #2
0
        public void menu_LVL()
        {
            Console.BufferHeight = 61;
            Console.BufferWidth = 201;
            Console.SetWindowSize(200, 60);
            int lvl=0;
            int speed=100;
            //sciany(lvl);
            lvl_state = 0;
            restart_LVL(lvl, speed);
            highlight_LVL(0, lvl, speed);
            while (true)
            {
                ConsoleKeyInfo kb;
                kb = Console.ReadKey(false);
                switch (kb.Key)
                { //react to input
                    case ConsoleKey.UpArrow:
                        switch (lvl_state)
                        {
                            case 0:
                                highlight_LVL(2, lvl, speed);
                                lvl_state = ((3 + lvl_state - 1) % 3);
                                break;
                            case 1:
                                highlight_LVL(0, lvl, speed);
                                lvl_state = ((3 + lvl_state - 1) % 3);
                                break;
                            case 2:
                                highlight_LVL(1, lvl, speed);
                                lvl_state = ((3 + lvl_state - 1) % 3);
                                break;
                        }
                        break;

                    case ConsoleKey.DownArrow:

                        switch (lvl_state)
                        {
                            case 0:
                                highlight_LVL(1, lvl, speed);
                                lvl_state = ((lvl_state + 1) % 3);
                                break;
                            case 1:
                                highlight_LVL(2, lvl, speed);
                                lvl_state = ((lvl_state + 1) % 3);
                                break;
                            case 2:
                                highlight_LVL(0, lvl, speed);
                                lvl_state = ((lvl_state + 1) % 3);
                                break;
                        }
                        break;
                    case ConsoleKey.Escape:
                        Console.Clear();
                        reset_menu(muzik);
                        highlight_menu(0, muzik);
                        menu_conroler(false);
                        break;
                }
                if (kb.Key == ConsoleKey.Enter)
                {
                    if (lvl_state == 0)
                    {
                        Snake snake = new Snake(lvl,speed);
                        GameViewer view = new GameViewer();
                        Console.Clear();
                        view.wyswietl_wynik(0);
                        snake.muzik = this.muzik;
                        snake.Snake_Init();
                    }
                    if (lvl_state == 1) // rysowanie scian
                    {

                       // sciany(lvl);
                        if (lvl == 0) { lvl = 1; }//sciany(0); }
                        else if (lvl == 1) { lvl = 2; }//sciany(1); }
                        else if (lvl == 2) { lvl = 0; }//sciany(2); }
                        highlight_LVL(1, lvl, speed);

                    }
                    if (lvl_state == 2)
                    {
                        {
                            if (speed == 100) speed = 80;
                            else if (speed == 80) speed = 60;
                            else if (speed == 60) speed = 100;
                            highlight_LVL(2, lvl, speed);
                        }
                    }
                }
            }
        }