예제 #1
0
        private void Form1_ResizeEnd(object sender, EventArgs e)
        {
            Graphics gr = panel1.CreateGraphics();

            gr.FillRectangle(new SolidBrush(Color.Black), new Rectangle(new Point(0, 0), panel1.Size));
            GameRenderer.Render();
        }
예제 #2
0
파일: Game.cs 프로젝트: NorbiPeti/SnakeGame
        public static void Refresh()
        {
            //Decrease any positive Ticks; if next player position is other than zero, game over
            //Otherwise set next player position and set Tick on player position to current Length
            if (!Form1.TimerEnabled)
            {
                return; //Not playing currently
            }
            for (int i = 0; i < GameField.GetLength(0); i++)
            {
                for (int j = 0; j < GameField.GetLength(1); j++)
                {
                    if (GameField[i, j].Tick > 0)
                    {
                        GameField[i, j].Tick--;
                    }
                }
            }
            Point nextcoord = MovePlayerPre(Player, MoveDirection);

            Network.SyncUpdate(NetUpdateType.Move, MoveDirection);
            if (nextcoord.X >= Game.GameSize.X || nextcoord.Y >= Game.GameSize.Y ||
                (Game.GameField[nextcoord.X, nextcoord.Y].Tick != 0 && Game.GameField[nextcoord.X, nextcoord.Y].Type != SquareType.Point))
            {
                Player.Lives--;
                LivesLabel.ForeColor = Color.Red;
                if (Player.Lives <= 0)
                {
                    Stop();
                }
                else
                {
                    Reset(false);
                }
            }
            else
            {
                //LivesLabel.ForeColor = Color.White;
                LivesLabel.ForeColor = Game.Player.Color;
                if (GameField[nextcoord.X, nextcoord.Y].Type == SquareType.Point)
                {
                    Player.Score        += 1000;
                    ScoreLabel.ForeColor = Color.Blue;
                    Game.Length++;
                    Form1.SetTimer(100);
                    Game.AddPoint();
                }
                else
                {
                    //ScoreLabel.ForeColor = Color.White;
                    ScoreLabel.ForeColor = Game.Player.Color;
                }
                if (Player.Score > 0)
                {
                    Player.Score -= new Random().Next(1, 20);
                }
                MovePlayerPost(Player, nextcoord);
            }
            GameRenderer.Render();
        }
예제 #3
0
 private void Form1_Resize(object sender, EventArgs e)
 {
     GameRenderer.Render();
 }
예제 #4
0
 private void panel1_Paint(object sender, PaintEventArgs e)
 {
     GameRenderer.Render();
 }