示例#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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            var t = Content.Load <Texture2D>("spritesheet");

            sheet = new SpriteSheet(t, 21, 21, 3, 2);

            // Load the tilemap
            tilemap = Content.Load <Tilemap>("level1");

            // Create the player with the corresponding frames from the spritesheet
            var playerFrames = from index in Enumerable.Range(19, 30) select sheet[index];

            player = new Player(playerFrames);

            // Create the platforms
            platforms.Add(new Platform(new BoundingRectangle(80, 300, 105, 21), sheet[1]));
            platforms.Add(new Platform(new BoundingRectangle(280, 400, 84, 21), sheet[2]));
            platforms.Add(new Platform(new BoundingRectangle(160, 200, 42, 21), sheet[3]));

            // Add the platforms to the axis list
            world = new AxisList();
            foreach (Platform platform in platforms)
            {
                world.AddGameObject(platform);
            }

            tileset = Content.Load <Tileset>("tiledspritesheet");
        }
示例#2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            var t = Content.Load <Texture2D>("Sprite Sheet");

            sheet = new SpriteSheet(t, 31, 35, 3, 2);

            var playerFrames = from index in Enumerable.Range(0, 5) select sheet[index];

            player = new Player(playerFrames, this);
            player.LoadContent(Content, "");


            platforms.Add(new Platform(new BoundaryRectangle(80, 350, 105, 21), sheet[7]));
            platforms.Add(new Platform(new BoundaryRectangle(180, 290, 105, 21), sheet[6]));
            platforms.Add(new Platform(new BoundaryRectangle(230, 220, 105, 21), sheet[7]));
            platforms.Add(new Platform(new BoundaryRectangle(390, 300, 105, 21), sheet[6]));
            platforms.Add(new Platform(new BoundaryRectangle(490, 230, 105, 21), sheet[7]));
            platforms.Add(new Platform(new BoundaryRectangle(600, 160, 105, 21), sheet[6]));

            gameWorld = new AxisList();
            foreach (Platform platform in platforms)
            {
                gameWorld.AddGameObject(platform);
                gameObjects.Add(platform);
            }
            gameObjects.Add(player);
            // TODO: use this.Content to load your game content here
        }
示例#3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

#if VISUAL_DEBUG
            VisualDebugging.LoadContent(Content);
#endif

            // Load and play music
            if (isFirstRun)
            {
                indianaJonesMusic = Content.Load <SoundEffect>("Indiana Jones");
                indianaJonesMusic.Play();
                isFirstRun = false;
            }


            // Load font
            font = Content.Load <SpriteFont>("font");

            // Background
            backgroundTexture = Content.Load <Texture2D>("Background-3584");

            // Player
            Texture2D[] playerTextures = new Texture2D[10];
            for (int i = 0; i < 10; i++)
            {
                playerTextures[i] = Content.Load <Texture2D>("Jump__00" + i);
            }
            player = new Player(playerTextures);

            // Arrow
            arrow = new Arrow(player);
            arrow.LoadContent(Content);

            // Platforms
            Texture2D pixel = Content.Load <Texture2D>("sand");
            pix = new Sprite(new Rectangle(0, 0, 100, 25), pixel);
            platforms.Add(new Platform(new BoundingRectangle(-100, 999, 1000, 25), pix));

            // Add the platforms to the axis list
            world = new AxisList();
            foreach (Platform platform in platforms)
            {
                world.AddGameObject(platform);
            }

            //Spider
            spider.LoadContent(Content);
            //Bat
            bat.LoadContent(Content);

            world.SpawnNewPlatforms(player, random, pix, platforms);
        }
示例#4
0
        private void restartLevel()
        {
            Initialize();

            platforms = new List <Platform>();

            platforms.Add(new Platform(new BoundingRectangle(-100, 999, 1000, 25), pix));

            // Add the platforms to the axis list
            world = new AxisList();
            foreach (Platform platform in platforms)
            {
                world.AddGameObject(platform);
            }
        }
示例#5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            expSFX      = Content.Load <SoundEffect>("explosion");
            scoreFont   = Content.Load <SpriteFont>("score");


            //load player
            var t = Content.Load <Texture2D>("Reimu_1");

            sheet = new SpriteSheet(t, 50, 73, 0, 0, 2);

            //load stone
            var t_s = Content.Load <Texture2D>("stones");

            stone_sheet = new SpriteSheet(t_s, 42, 40, 1, 2, 0);
            for (int i = 0; i < 10; i++)
            {
                stones.Add(new Stone(this, new BoundingRectangle(new Vector2(Random.Next(10) * 100, -Random.Next(100) * 1000), 42, 40), stone_sheet[Random.Next(0, 1)]));
            }

            var playerFrames = from index in Enumerable.Range(0, 23) select sheet[index];

            player = new Player(this, playerFrames);
            player.LoadContent(Content);


            var t_e = Content.Load <Texture2D>("Enemies_1");

            enemies_sheet = new SpriteSheet(t_e, 60, 39, 2, 2, 24);
            for (int i = 0; i < 2; i++)
            {
                enemies.Add(new Enemy(this, new BoundingRectangle(new Vector2(Random.Next(10) * 100, -30), 60, 39), enemies_sheet[Random.Next(0, 15)]));
            }

            env = new AxisList();
            foreach (Enemy e in enemies)
            {
                e.LoadContent(Content);
                env.AddGameObject(e);
            }

            loseRect.LoadContent(Content);

            // TODO: use this.Content to load your game content here
        }
示例#6
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 VISUAL_DEBUG
            VisualDebugging.LoadContent(Content);
#endif
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            background = Content.Load <Texture2D>("background");
            ast        = Content.Load <Texture2D>("asteriodbarrier");
            var gTexture = Content.Load <Texture2D>("gimpMasterSchwag");
            var oTexture = Content.Load <Texture2D>("evilOlive");

            gimp  = new SpriteSheet(gTexture, 87, 87, 8, 17);
            olive = new SpriteSheet(oTexture, 87, 87, 20, 25);

            var gimpFrames  = from index in Enumerable.Range(0, 2) select gimp[index];
            var oliveFrames = from index in Enumerable.Range(0, 2) select olive[index];

            player = new Player(gimpFrames);
            olive1 = new Olive(oliveFrames);
            olive2 = new Olive(oliveFrames);
            olive3 = new Olive(oliveFrames);
            olive4 = new Olive(oliveFrames);
            olive5 = new Olive(oliveFrames);

            //create asteroid barrier here:
            barriers.Add(new Barrier(new BoundingRectangle(200, 75, 400, 125), asteroid));
            barriers.Add(new Barrier(new BoundingRectangle(50, 200, 50, 400), asteroid));
            barriers.Add(new Barrier(new BoundingRectangle(700, 200, 50, 400), asteroid));
            barriers.Add(new Barrier(new BoundingRectangle(350, 300, 100, 200), asteroid));
            barriers.Add(new Barrier(new BoundingRectangle(200, 600, 400, 125), asteroid));

            world = new AxisList();
            foreach (Barrier barrier in barriers)
            {
                world.AddGameObject(barrier);
            }
        }
示例#7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            grass       = Content.Load <Texture2D>("grass");
            font        = Content.Load <SpriteFont>("score");
            button      = Content.Load <Texture2D>("button");
            cloud       = Content.Load <Texture2D>("Cloud");
            wood        = Content.Load <Texture2D>("wood");
            block1.LoadContent(Content);
            block2.LoadContent(Content);
            block3.LoadContent(Content);

            // TODO: use this.Content to load your game content here
            particleTexture = Content.Load <Texture2D>("Particle");
            particleSystem  = new ParticleSystem(this.GraphicsDevice, 2000, particleTexture);
            //particleSystem.Emitter = new Vector2(360, 0);
            particleSystem.SpawnPerFrame = 1;
            // Set the SpawnParticle method
            particleSystem.SpawnParticle = (ref Particle particle) =>
            {
                particle.Position = new Vector2(390, 40);
                particle.Velocity = new Vector2(
                    MathHelper.Lerp(-200, 200, (float)random.NextDouble()),
                    MathHelper.Lerp(0, 415, (float)random.NextDouble())
                    );
                particle.Acceleration = new Vector2(0, 0);
                particle.Color        = Color.Aqua;
                particle.Scale        = 1f;
                particle.Life         = 1.75f;
            };
            particleSystem.UpdateParticle = (float deltaT, ref Particle particle) =>
            {
                particle.Velocity += deltaT * particle.Acceleration;
                particle.Position += deltaT * particle.Velocity;
                particle.Scale    -= deltaT;
                particle.Life     -= deltaT;
            };

            sparkleTexture              = Content.Load <Texture2D>("star");
            sparkleSystem               = new SparkleSystem(this.GraphicsDevice, 300, sparkleTexture); //300
            sparkleSystem.Emitter       = new Vector2(75, 75);
            sparkleSystem.SpawnPerFrame = 2;
            sparkleSystem.SpawnSparkle  = (ref Particle particle) =>
            {
                particle.Position = new Vector2(30, block1.Bounds.Y - sparkleTexture.Height);
                particle.Velocity = new Vector2(
                    MathHelper.Lerp(-30, 30, (float)random.NextDouble()), // X between -30 and 30
                    MathHelper.Lerp(-10, 10, (float)random.NextDouble())  // Y between -10 and 10
                    );
                particle.Acceleration = new Vector2(0, 0);
                particle.Color        = Color.Gold;
                particle.Scale        = 0.5f;
                particle.Life         = 1f;
            };
            // Set the UpdateParticle method
            sparkleSystem.UpdateSparkle = (float deltaT, ref Particle particle) =>
            {
                particle.Velocity += deltaT * particle.Acceleration;
                particle.Position += deltaT * particle.Velocity;
                particle.Scale    -= deltaT;
                particle.Life     -= deltaT;
            };


            //FIRE
            fireTexture              = Content.Load <Texture2D>("particle");
            fireSystem               = new FireSystem(this.GraphicsDevice, 500, fireTexture);
            fireSystem.Emitter       = new Vector2(75, 75);
            fireSystem.SpawnPerFrame = 4;
            fireSystem.SpawnFire     = (ref Particle particle) =>
            {
                particle.Position = new Vector2(690, 400);
                particle.Velocity = new Vector2(
                    MathHelper.Lerp(-25, 25, (float)random.NextDouble()), // X between -50 and 50
                    MathHelper.Lerp(-95, 0, (float)random.NextDouble())   // Y between 0 and 100
                    );
                particle.Acceleration = 0.1f * new Vector2(0, (float)-random.NextDouble());
                particle.Color        = Color.MonoGameOrange;
                particle.Scale        = 1.0f;
                particle.Life         = 0.5f;
            };

            // Set the UpdateParticle method
            fireSystem.UpdateFire = (float deltaT, ref Particle particle) =>
            {
                particle.Velocity += deltaT * particle.Acceleration;
                particle.Position += deltaT * particle.Velocity;
                particle.Scale    -= deltaT;
                particle.Life     -= deltaT;
            };


            player.LoadContent();
            cake.LoadContent(Content);
            cookie.LoadContent(Content);
            donut.LoadContent(Content);
            carrot.LoadContent(Content);
            broccoli.LoadContent(Content);

            message = Content.Load <Message>("message1");

            blocks.Add(block1);
            blocks.Add(block2);
            blocks.Add(block3);


            world = new AxisList();
            foreach (Block block in blocks)
            {
                world.AddGameObject(block);
            }
        }
示例#8
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            offset           = new Vector2(0, 0) + new Vector2(0, (float)gameTime.TotalGameTime.TotalMilliseconds / 50);
            newKeyboardState = Keyboard.GetState();
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (newKeyboardState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            if (!lose)
            {
                //remove collised bullet and enemies
                for (int i = 0; i < bullets.Count; i++)
                {
                    var enemyQuery = env.QueryRange(0, 1042);
                    if (!bullets[i].IsExist(enemyQuery))
                    {
                        score++;
                        bullets.RemoveAt(i);
                        return;
                    }
                }

                //remove the bullet out of bounds
                for (int i = 0; i < bullets.Count; i++)
                {
                    if (!bullets[i].IsVisible(-offset.Y))
                    {
                        bullets.RemoveAt(i);
                        i--;
                    }
                }
                for (int i = 0; i < EBullets.Count; i++)
                {
                    if (!EBullets[i].IsVisible(-offset.Y))
                    {
                        EBullets.RemoveAt(i);
                        i--;
                    }
                }

                //remove stones out of bounds
                for (int i = 0; i < stones.Count; i++)
                {
                    if (!stones[i].IsVisible(-offset.Y))
                    {
                        stones.RemoveAt(i);
                        i--;
                    }
                }

                //add enemies
                float elapsed = (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                timer -= elapsed;

                if (timer < 0 && enemies.Count < 10)
                {
                    Enemy newEnemy = new Enemy(this, new BoundingRectangle(new Vector2(Random.Next(10) * 100, -30 - offset.Y), 60, 39), enemies_sheet[Random.Next(0, 15)]);
                    newEnemy.LoadContent(Content);
                    enemies.Add(newEnemy);
                    env.AddGameObject(newEnemy);
                    timer = TIMER;
                }



                //check for lose
                foreach (Enemy e in enemies)
                {
                    e.Update(gameTime);
                    if (e.IsLose(-offset.Y))
                    {
                        lose = true;
                    }
                    if (player.Bounds.CollidesWith(e.Bounds))
                    {
                        lose = true;
                    }
                }
                foreach (EnemyBullet ebs in EBullets)
                {
                    if (player.Bounds.CollidesWith(ebs.Bounds))
                    {
                        lose = true;
                    }
                }

                foreach (Stone s in stones)
                {
                    s.Update(gameTime);
                    if (s.IsCrash(player.Bounds))
                    {
                        lose = true;
                    }
                }

                //update
                foreach (EnemyBullet ebs in EBullets)
                {
                    ebs.Update(gameTime);
                }
                foreach (Bullet b in bullets)
                {
                    b.Update(gameTime);
                }



                player.Update(gameTime, -offset.Y);
                base.Update(gameTime);

                // Remove killed enemies
                foreach (Enemy enemy in killedEnemies)
                {
                    enemies.Remove(enemy);
                    env.RemoveGameObject(enemy);
                }
            }

            oldKeyboardState = newKeyboardState;
        }
示例#9
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);
        }