Пример #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);

#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);
        }
Пример #2
0
        public float CheckForPlatformCollision(IEnumerable <IBoundable> platforms, AxisList world, Random random, Sprite pix, float lastPlatfformY)
        {
            foreach (Platform platform in platforms)
            {
                if (Bounds.CollidesWith(platform.Bounds))
                {
                    Position.Y = platform.Bounds.Y - this.Bounds.Height - 21;
                    Velocity.Y = 0;
                    t          = 0;
                    isJumping  = false;

                    if (!seenPlatforms.ContainsKey(platform.Bounds.X + platform.Bounds.Y))
                    {
                        seenPlatforms.Add(platform.Bounds.X + platform.Bounds.Y, 1);

                        world.SpawnNewPlatforms(this, random, pix, (List <Platform>)platforms);
                        return(platform.Bounds.Y); //
                    }
                }
            }
            return(lastPlatfformY); //
        }