How can I make a game like doodlejump XNA c#

Posted by Ramy on Game Development See other posts from Game Development or by Ramy
Published on 2013-11-10T19:43:19Z Indexed on 2013/11/10 22:25 UTC
Read the original article Hit count: 433

Filed under:
|

I wanted to know how can I make the background scroll down like doodlejump. I have a game made and I have to transform it so it's like doodle jump, but I'm wonder how or where to look so I can make he background keep moving as in progressing through the background till let's say the character dies.

namespace IFM20884
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;


public abstract class BackgroundScroll : Sprite
{

    private float speedOfBackground = 0.2f;       // speed that the background moves


    public BackgroundScroll (GraphicsDeviceManager graphics)
        : base(graphics.GraphicsDevice.Viewport.Width / 2f, graphics.GraphicsDevice.Viewport.Height / 2f) 
    { 
    }

   //Getter
    public float speedOfBackground 
    {
        get { return this.speedOfBackground ; }
        set { this.speedOfBackground = value; }
    }


    public override void Update(GameTime gameTime, GraphicsDeviceManager graphics)
    {
        //Makes background go down.
        ForcePosition(Position.X, Position.Y + (gameTime.ElapsedGameTime.Milliseconds * this.speedOfBackground ));

        if (Position.Y - (Height / 2) > graphics.GraphicsDevice.Viewport.Height)
        {
            ForcePosition(Position.X, Position.Y - this.Height);
        }
    }


    public override void Draw(SpriteBatch spriteBatch)
    {


        ForcePosition(Position.X, Position.Y - this.Height);
        base.Draw(spriteBatch);


        ForcerPosition(Position.X, Position.Y + this.Height);
        base.Draw(spriteBatch);
    }
}

}

© Game Development or respective owner

Related posts about XNA

Related posts about c#