コード例 #1
0
ファイル: GameStateManager.cs プロジェクト: Avalin/wf_snake
        private void DrawUI(MapManager mm, Graphics gfx)
        {
            Tile center   = mm.GetCenterTile();
            int  tileSize = mm.GetTileSize();

            gfx.DrawString("Food eaten: " + score.ToString(), new Font("Arial", 10), new SolidBrush(Color.Black), center.X * tileSize, 0);
            if (GetGameState() == GameState.Over)
            {
                gfx.DrawString("GAME OVER", new Font("Arial", 20), new SolidBrush(Color.Black), center.X * tileSize, center.Y * tileSize);
            }

            if (GetGameState() == GameState.Pausing)
            {
                gfx.DrawString("PAUSED", new Font("Arial", 20), new SolidBrush(Color.Black), center.X * tileSize, center.Y * tileSize);
            }
        }
コード例 #2
0
ファイル: Snake.cs プロジェクト: Avalin/wf_snake
        public void AddSnakeToMap(MapManager mm)
        {
            SnakePart snakeTail = snakeParts.First();

            mm.PlaceItemOnTile(mm.GetCenterTile(), snakeTail);

            for (LinkedListNode <SnakePart> currentNode = snakeParts.First; currentNode != null;)
            {
                LinkedListNode <SnakePart> nextNode = currentNode.Next;
                if (nextNode != null)
                {
                    Tile tile = mm.GetTileInFrontOfSnakePart(currentNode.Value);
                    mm.PlaceItemOnTile(tile, nextNode.Value);
                }
                currentNode = nextNode;
            }
        }