コード例 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            collisionManager = new CollisionManager();
            contentManager   = new GameContentManager(new XnaContentManagerAdapter(Content));
            snake            = new Snake(contentManager, 4, 4, 4, 1, 0, tileSize);
            grid             = new Grid(contentManager, tileSize, GridMap.GetGrid("level1"));
            grid.AddRandomPowerUp(snake.GetPositions());

            base.Initialize();
        }
コード例 #2
0
 public Snake(GameContentManager contentManager, int xStart, int yStart, int initialLenght, int xDirection, int yDirection, Vector2 tileSize)
 {
     this.contentManager = contentManager;
     this.tileSize       = tileSize;
     Head = CreateHead(xStart, yStart);
     ChangeDirection(xDirection, yDirection);
     tail = new SortedList <int, SnakePart>();
     for (int i = 1; i < initialLenght; i++)
     {
         AddTail(Head.X - i, Head.Y);
     }
     newParts = new Queue <int>();
 }
コード例 #3
0
 public void Draw(GameContentManager contentManager, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(contentManager.Get <Texture2D>(Texture), new Vector2(X * (int)TileSize.X, Y * (int)TileSize.Y), Color.White);
 }
コード例 #4
0
ファイル: Grid.cs プロジェクト: Jtavares94/Snake-Game
 public Grid(GameContentManager contentManager, Vector2 tileSize, int[,] grid)
 {
     this.grid           = grid;
     this.tileSize       = tileSize;
     this.contentManager = contentManager;
 }