Beispiel #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Initialise method
        // animation - texture atlas of all the animation frames
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void Initialize(LevelLibrary.SpriteAnimator animation, Vector2 startPosition, int xSize, int ySize)
        {
            PlayerAnimation = animation;

            // Set the starting position of the player around the middle of the screen and to the back
            position = startPosition;
            direction = LevelLibrary.Directions.none;
            currentSpeed = 1f;
            gravity = new LevelLibrary.Gravity();
            gravity.windowHeight = ySize;
            gravity.objectHeight = PlayerAnimation.FrameHeight;

            // Set the player health
            Health = 100;
            Lives = 3;

            // Can I hover
            hoverAbility = false;

            PlayerAnimation.Active = true;
            PlayerAnimation.Position = Position;
        }
Beispiel #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);

            LoadLevel(1);

            // TODO move this into the player
            LevelLibrary.SpriteAnimator playerAnimation = new LevelLibrary.SpriteAnimator();
            Texture2D playerTexture1 = Content.Load<Texture2D>("GenericTextures\\walkingleft");
            Texture2D playerTexture2 = Content.Load<Texture2D>("GenericTextures\\walkingright");

            playerAnimation.Initialize(playerTexture1, playerTexture2, Vector2.Zero, 50, 50, 9, 50, Color.White, 1f, true);

            // TODO set initial position
            Vector2 playerPosition = new Vector2(100,
                                                 350);
            player.Initialize(playerAnimation, playerPosition, GraphicsDevice.Viewport.Width,
                                            GraphicsDevice.Viewport.Height);

            // Load the parallaxing background
            mainbg.Initialize(Content, "GenericTextures\\mainbackground", GraphicsDevice.Viewport.Width, 1);
            bgLayer1.Initialize(Content, "GenericTextures\\bgLayer1", GraphicsDevice.Viewport.Width, 2);
            bgLayer2.Initialize(Content, "GenericTextures\\bgLayer2", GraphicsDevice.Viewport.Width, 3);

            List<Texture2D> textures = new List<Texture2D>();
            textures.Add(Content.Load<Texture2D>("GenericTextures\\circle"));
            textures.Add(Content.Load<Texture2D>("GenericTextures\\star"));
            textures.Add(Content.Load<Texture2D>("GenericTextures\\diamond"));
            particleEngine = new ParticleEngine(textures, new Vector2(400, 240));

            // Heads Up Display
            hudBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("gameFont");
            hud.LoadContent(Content);
            hud.Initialize(font);
        }