Beispiel #1
0
        private void GenerateFood()
        {
            //Creem menjar a una posició random
            int maxXPos = pbCanvas.Size.Width / Settings.Width;
            int maxYPos = pbCanvas.Size.Height / Settings.Height;

            Random r = new Random();

            food   = new Cercle();
            food.X = r.Next(0, maxXPos);
            food.Y = r.Next(0, maxYPos);
        }
Beispiel #2
0
        private void SumarPunts()
        {
            Settings.Score   += 100;
            lblPuntuacio.Text = Settings.Score.ToString();

            GenerateFood();
            Cercle tail = new Cercle();

            tail.X = Snake[Snake.Count - 1].X;
            tail.Y = Snake[Snake.Count - 1].Y;

            Snake.Add(tail);
            Settings.Speed    += 1;
            gameTimer.Interval = 1000 / Settings.Speed;
            lbl_velocitat.Text = Settings.Speed.ToString();
        }
Beispiel #3
0
        private void StartGame()
        {
            //Settings a Default
            new Settings();

            //Creem un nou objecte jugador
            Snake.Clear();
            Cercle head = new Cercle();

            head.X = 10;
            head.Y = 5;
            Snake.Add(head);

            lblPuntuacio.Text  = Settings.Score.ToString();
            lbl_velocitat.Text = Settings.Speed.ToString();
            GenerateFood();
        }