コード例 #1
0
ファイル: Form1.cs プロジェクト: NorbiPeti/SnakeGame
        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
ファイル: Form1.cs プロジェクト: NorbiPeti/SnakeGame
 private void Form1_Resize(object sender, EventArgs e)
 {
     GameRenderer.Render();
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: NorbiPeti/SnakeGame
 private void panel1_Paint(object sender, PaintEventArgs e)
 {
     GameRenderer.Render();
 }