예제 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
#if Debug
            VisualDebugging.LoadContent(Content);
#endif
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //load in spritefont
            spriteFont = Content.Load <SpriteFont>("File");

            // TODO: use this.Content to load your game content here
            var t = Content.Load <Texture2D>("spritesheet");
            sheet = new SpriteSheet(t, 21, 21, 1, 2);

            // Create the player with the corresponding frames from the spritesheet
            var playerFrames = from index in Enumerable.Range(139, 150) select sheet[index]; //19 is the 0 in player currentFrame
            player = new Player(playerFrames);

            // Create the platforms //platforms will randomly not register any collision with player, reasoning is unknown
            platforms.Add(new Platform(new BoundingRectangle(1, 980, 1600, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1, 900, 800, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(920, 860, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1020, 800, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(920, 770, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1050, 700, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1200, 650, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1250, 600, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1300, 550, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1350, 500, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1450, 450, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1500, 400, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1550, 350, 42, 20), sheet[121]));

            Alist = new AxisList();
            foreach (Platform platform in platforms)
            {
                Alist.AddGameObject(platform);
            }

            //ghosts buggy, explained in draw commented out section
            var GhostFrames = from index in Enumerable.Range(445, 449) select sheet[index];
            ghost1 = new GhostEnemy(GhostFrames, player);

            ghost2          = new GhostEnemy(GhostFrames, player);
            ghost2.Position = new Vector2(100, 700);

            ghost3          = new GhostEnemy(GhostFrames, player);
            ghost3.Position = new Vector2(200, 800);

            ghost4          = new GhostEnemy(GhostFrames, player);
            ghost4.Position = new Vector2(1500, 550);

            ghost5          = new GhostEnemy(GhostFrames, player);
            ghost5.Position = new Vector2(550, 900);

            ghost6          = new GhostEnemy(GhostFrames, player);
            ghost6.Position = new Vector2(900, 950);

            ghost7          = new GhostEnemy(GhostFrames, player);
            ghost7.Position = new Vector2(200, 400);

            ghost8          = new GhostEnemy(GhostFrames, player);
            ghost8.Position = new Vector2(1200, 600);

            ghost9          = new GhostEnemy(GhostFrames, player);
            ghost9.Position = new Vector2(800, 400);
        }