Beispiel #1
0
        static void input()
        {
            if (Console.KeyAvailable)
            {
                var keyInfo = Console.ReadKey();
                switch (keyInfo.KeyChar)
                {
                case 'a':
                    dir = EActiv.LEFT;
                    break;

                case 'd':
                    dir = EActiv.RIGHT;
                    break;

                case 'w':
                    dir = EActiv.UP;
                    break;

                case 's':
                    dir = EActiv.DOWN;
                    break;

                case 'x':
                    gameOver = true;
                    break;
                }
            }
        }
Beispiel #2
0
        static void setup()
        {
            Random rand   = new Random();
            int    marvel = rand.Next();

            gameOver = false;
            dir      = EActiv.STOP;
            x        = width / 2;
            y        = height / 2;
            fruitX   = marvel % (width - 2);
            fruitY   = marvel % (height - 2);
            score    = 0;
        }