Esempio n. 1
0
 private void updateBTN_Click(object sender, EventArgs e)
 {
     Settings.player1Name     = player1nameTB.Text;
     Settings.player2Name     = player2nameTB.Text;
     player1highscoreLBL.Text = Highscore.GetHighScore(player1nameTB.Text) + "";
     player2highscoreLBL.Text = Highscore.GetHighScore(player2nameTB.Text) + "";
 }
Esempio n. 2
0
 public ProfileForm()
 {
     InitializeComponent();
     player1nameTB.Text       = Settings.player1Name;
     player2nameTB.Text       = Settings.player2Name;
     player1highscoreLBL.Text = Highscore.GetHighScore(player1nameTB.Text) + "";
     player2highscoreLBL.Text = Highscore.GetHighScore(player2nameTB.Text) + "";
 }
Esempio n. 3
0
        private void UpdateScreen(object sender, EventArgs e)
        {
            highscoreLBL.Text = Highscore.GetHighScore(Settings.player1Name).ToString();

            //Check for Game Over
            if (Settings.IsGameOver)
            {
                //Check if Enter is pressed
                if (GameInput.PressedKey(Keys.Enter))
                {
                    StartGame();
                }
            }
            else
            {
                //(()or())and()
                if (GameInput.PressedKey(Keys.Space))
                {
                    Settings.IsGamePaused = !Settings.IsGamePaused;
                    pausedLBL.Visible     = !pausedLBL.Visible;
                }
                if (GameInput.PressedKey(Keys.K))
                {
                    createPowerup();
                }

                //move when unpaused
                if (!Settings.IsGamePaused)
                {
                    if ((GameInput.PressedKey(Keys.Right) || (GameInput.PressedKey(Keys.D))) && Settings.InGameDirection != Direction.Left)
                    {
                        Settings.InGameDirection = Direction.Right;
                    }
                    else if ((GameInput.PressedKey(Keys.Left) || (GameInput.PressedKey(Keys.A))) && Settings.InGameDirection != Direction.Right)
                    {
                        Settings.InGameDirection = Direction.Left;
                    }
                    else if ((GameInput.PressedKey(Keys.Up) || (GameInput.PressedKey(Keys.W))) && Settings.InGameDirection != Direction.Down)
                    {
                        Settings.InGameDirection = Direction.Up;
                    }
                    else if ((GameInput.PressedKey(Keys.Down) || (GameInput.PressedKey(Keys.S))) && Settings.InGameDirection != Direction.Up)
                    {
                        Settings.InGameDirection = Direction.Down;
                    }
                    MoveSnake(Snake);
                }
            }


            canvas.Invalidate();
        }
Esempio n. 4
0
 private void eatPowerup(string p)
 {
     if (p == "extraPoints")
     {
         extraPoints.Play();
         Settings.Score   += 500;
         score_l.Text      = Settings.Score.ToString();
         highscoreLBL.Text = Highscore.GetHighScore(Settings.player1Name).ToString();
     }
     if (p == "shortenSnake")
     {
         //TODO
     }
     powerup.X = -100;
     powerup.Y = -100;
 }
Esempio n. 5
0
        private void EatFood()
        {
            //For adding circle to snake's body on eating the food
            Shape snake = new Shape
            {
                X = Snake[Snake.Count - 1].X,
                Y = Snake[Snake.Count - 1].Y,
                //testing
            };

            Snake.Add(snake);
            //for updating the score
            Settings.Score   += Settings.Points;
            score_l.Text      = Settings.Score.ToString();
            highscoreLBL.Text = Highscore.GetHighScore(Settings.player1Name).ToString();
            CreateFood();
            createPowerup();
        }