Example #1
0
        public static void update()
        {
            keyPressCooldown--;
            if (keyPressCooldown < 0)
            {
                keyPressCooldown = 0;
            }
            if (currentScreen == 0)
            {
                MainMenu.menu();
            }

            if (currentScreen == 1)
            {
                Gameplay.play();
            }

            if (currentScreen == 2)
            {
                LevelEditor.edit();
            }
        }
Example #2
0
        public static void menu()
        {
            Program.s.render(logo, 250, 20);
            Program.s.render(leftButton, 200, 400);
            Program.s.render(rightButton, 525, 400);
            Program.s.render(levelEditorButton, 10, 650);
            Program.s.render(customLevelButton, 425, 650);
            Program.s.render(Program.keyPressCooldown.ToString(), 0, 0, Brushes.White);

            switch (currentCard)
            {
            case 0:
                Program.s.render(level1Card, 300, 230);
                break;

            case 1:
                Program.s.render(level2Card, 300, 230);
                break;

            case 2:
                Program.s.render(level3Card, 300, 230);
                break;

            case 3:
                Program.s.render(level4Card, 300, 230);
                break;

            case 4:
                Program.s.render(level5Card, 300, 230);
                break;

            default:
                Program.s.render(defaultCard, 300, 230);
                break;
            }

            //check input
            if (Program.s.readKeyDown(Keys.Left) && Program.keyPressCooldown == 0)
            {
                Program.keyPressCooldown = Program.cooldownLength;
                leftDown = true;
            }
            else
            {
                leftDown = false;
            }

            if (Program.s.readKeyDown(Keys.Right) && Program.keyPressCooldown == 0)
            {
                Program.keyPressCooldown = Program.cooldownLength;
                rightDown = true;
            }
            else
            {
                rightDown = false;
            }

            if (Program.s.readKeyDown(Keys.Enter) && Program.keyPressCooldown == 0)
            {
                Program.keyPressCooldown = Program.cooldownLength;
                enterDown = true;
            }
            else
            {
                enterDown = false;
            }

            if (Program.s.readKeyDown(Keys.D1) && Program.keyPressCooldown == 0)
            {
                Program.keyPressCooldown = Program.cooldownLength;
                oneDown = true;
            }
            else
            {
                oneDown = false;
            }

            if (Program.s.readKeyDown(Keys.D2) && Program.keyPressCooldown == 0)
            {
                Program.keyPressCooldown = Program.cooldownLength;
                twoDown = true;
            }
            else
            {
                twoDown = false;
            }

            if (Program.s.keyUp())
            {
                leftDown  = false;
                rightDown = false;
                enterDown = false;
                oneDown   = false;
                twoDown   = false;
                Program.keyPressCooldown = 0;
            }

            if (leftDown)
            {
                currentCard--;
                if (currentCard == -1)
                {
                    currentCard = maxCards - 1;
                }
            }
            if (rightDown)
            {
                currentCard++;
                if (currentCard == maxCards)
                {
                    currentCard = 0;
                }
            }

            if (enterDown)
            {
                Program.currentScreen = 2;
                LevelEditor.initMap("level" + (currentCard + 1).ToString());
            }

            if (oneDown)
            {
                Program.currentScreen = 2;
                LevelEditor.initMap("CUSTOM");
            }

            if (twoDown)
            {
                Program.currentScreen = 2;
                LevelEditor.initWithCustomMap();
            }
        }