//------------------------------------------------------------------------------
        // Constructor: GameObject2D
        // Author: Neil Holmes & Andrew Green
        // Summary: default constructor - initialises a 2D game object ready for use
        //------------------------------------------------------------------------------
        public GameObject2D(Game game, GameObject2DManager gameObjectManager, DisplayManager displayManager, Vector2 position, GameObject2DProperties properties)
        {
            // Store reference to parent game system object
            this.game = game;

            // Store reference to owning gameObjectManager
            this.gameObjectManager = gameObjectManager;

            // store reference to the display manager
            this.displayManager = displayManager;

            // get the game input manager service
            inputManager = (InputManager)game.Services.GetService(typeof(InputManager));

            // get the game input manager service
            timerSystem = (TimerSystem)game.Services.GetService(typeof(TimerSystem));

            // set the type of this game object
            type = properties.type;

            // store whether the object should always be updated
            alwaysUpdate = properties.alwaysUpdate;

            // store the update range for this object
            updateRange = properties.updateRange;

            // store the position
            this.position = position;

            // set initial velocity to zero
            velocity = new Vector2(0, 0);

            // create the master list for the animation frames
            animationFrames = new List<List<Texture2D>>();

            // set some default values for current animation frame and animation speed
            defaultAnimationSpeed = 10;
            animationSpeed = 0;

            // default to showing no animation at all
            currentAnimation = -1;

            // set the current animation frame index to zero
            currentAnimFrame = 0;

            // set the texture frame flip X and & to false by default
            textureFrameFlipX = false;
            textureFrameFlipY = false;

            // set the texture frame rotation to zero by defaul
            textureFrameRotation = 0;

            // store the display offset and size
            displayOffset = properties.displayOffset;
            displaySize = properties.displaySize;

            // set the rotation offset based on the display size
            rotationOffset = displaySize * 0.5f;

            // store the collision offset and size
            collisionOffset = properties.collisionOffset;
            collisionSize = properties.collisionSize;
        }
        //------------------------------------------------------------------------------
        // Function: GameState
        // Author: Neil Holmes & Andrew Green
        // Summary: main constructor
        //------------------------------------------------------------------------------
        public GameState(Game game, PlayerIndex? controllingPlayer)
        {
            // store a reference to the game that owns this game state
            this.game = game;

            // get the display manager service
            displayManager = (DisplayManager)game.Services.GetService(typeof(DisplayManager));

            // get the game state manager service
            gameStateManager = (GameStateManager)game.Services.GetService(typeof(GameStateManager));

            // get the game timer system service
            timerSystem = (TimerSystem)game.Services.GetService(typeof(TimerSystem));

            // get the game input manager service
            inputManager = (InputManager)game.Services.GetService(typeof(InputManager));

            // store the player that has control of this game state
            this.controllingPlayer = controllingPlayer;

            // set the default sub-state of the state to be transitioning on
            subState = SubState.TransitionOn;

            // by default, transition has not finished
            transitionAmount = 1.0f;

            // by default, we are not exiting ;)
            isExiting = false;
        }
        //------------------------------------------------------------------------------
        // Method: Initialize
        // Author: Neil Holmes & Andrew Green
        // Summary: overrides base initialize so we can perform our own class
        //          initialisations called after the XNA devices have been initialised
        //------------------------------------------------------------------------------
        protected override void Initialize()
        {
            // *** IndieCity Setup ***

            // initialise the message pop up display class and register it as a service
            messagePopUp = new ICMessagePopUp(this, graphicsDeviceManager, ICMessagePosition.bottomRight, ICMessageScale.normal);
            base.Services.AddService(typeof(ICMessagePopUp), messagePopUp);

            // create bridge
            ICEBridgeLib.CoBridge bridge = new ICEBridgeLib.CoBridge();
            if (bridge != null)
            {
                // setup the game id and game secret
                ICECoreLib.GameId myGameId = StringToGameId("540a5e40-669c-4782-8424-fd688e720573");
                string mySecret = "248f9aa3-624b-4e2d-b286-8d6de3781896";

                // initialise the bridge
                bridge.Initialise(myGameId, mySecret);

                //get some user info
                int userId = bridge.DefaultUserId;
                ICECoreLib.CoUserStore storeClass = bridge.UserStore;
                ICECoreLib.CoUserInfo userClass = storeClass.GetUserFromId(userId);
                string name = userClass.Name;

                //Create a game session
                try
                {
                    indieCitySession = bridge.CreateDefaultGameSession();
                }
                catch (System.Runtime.InteropServices.COMException ex)
                {
                    // session creation failed - report the error and tell the game to bail out
                    messagePopUp.AddMessage("Session Creation Error", "Valid tokens for " + name +" could not be found.\nThis means a IndieCity session could not be created.", ICMessagePriority.urgent);
                    gameStatus = GameStatus.exiting;
                }

                // only do the following if the session was succesfully created
                if (indieCitySession != null)
                {
                    indieCitySession.RequestStartSession();

                    // create the achievement manager and initialise it
                    indieCityAchievementManager = new ICELandaLib.CoAchievementManager();
                    indieCityAchievementManager.SetGameSession(indieCitySession);
                    indieCityAchievementManager.InitialiseAchievements(null);

                    // retrieve the achievement group from the achievement manager
                    indieCityAchievementGroup = indieCityAchievementManager.AchievementGroup;

                    // initialise the achievement list and pop up display classes and register them as services
                    achievementPopUp = new ICAchievementPopUp(this, graphicsDeviceManager, ICAchievementPosition.topRight, ICAchievementScale.normal);
                    achievementList = new ICAchievementList(this, graphicsDeviceManager, indieCityAchievementGroup, ICAchievementScale.normal);
                    base.Services.AddService(typeof(ICAchievementPopUp), achievementPopUp);
                    base.Services.AddService(typeof(ICAchievementList), achievementList);

                    // get the current user's list of unlocked achievements
                    indieCityUserList = indieCityAchievementManager.GetUserAchievementList(indieCitySession.UserId);

                    // register the pop up achievement class with the achievement manager to handle events
                    ICELandaLib.IAchievementService iService = (ICELandaLib.IAchievementService)indieCityAchievementManager;
                    m_cookie = iService.RegisterAchievementEventHandler(achievementPopUp);

                    // create the leaderboard manager
                    indieCityLeaderboardManager = new ICELandaLib.CoLeaderboardManager();
                    indieCityLeaderboardManager.SetGameSession(indieCitySession);
                    indieCityLeaderboardManager.InitialiseLeaderboards(null);

                    // we need to create a list of the leaderboard UIDs so that the game knows the order in which to display the leaderboards
                    // this list will be custom for your game and will depend on the IDs that exist for your games leaderboards and the order
                    // in which you wish to display them!
                    int[] leaderboardUIDlist = {54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,120,74,75,76};

                    // for sanity, check that the number of IDs we have specified is the same as the number of leaderboards before proceeding ;)
                    if (leaderboardUIDlist.Length == indieCityLeaderboardManager.GetNumberLeaderboards())
                    {
                        // initlaise the leaderboard browser class and register it as a service
                        leaderboardBrowser = new ICLeaderboardsBrowser(this, graphicsDeviceManager, indieCityLeaderboardManager, ICLeaderboardScale.normal, leaderboardUIDlist);
                        base.Services.AddService(typeof(ICLeaderboardsBrowser), leaderboardBrowser);
                    }
                }
            }

            // *** optional initialisations ***

            // create the display manager and register it as a service
            displayManager = new DisplayManager(this, Window, graphicsDeviceManager, 1280, 720, ScreenMode.Windowed, 1);
            base.Services.AddService(typeof(DisplayManager), displayManager);

            // create the timer system and add it as a service
            timerSystem = new TimerSystem(this);
            base.Services.AddService(typeof(TimerSystem), timerSystem);

            // create the input manager for a single player game and add it as a service
            inputManager = new InputManager(NumPlayers.one);
            base.Services.AddService(typeof(InputManager), inputManager);

            // create the save game manager and add it as a service
            saveGameManager = new SaveGameManager(this);
            base.Services.AddService(typeof(SaveGameManager), saveGameManager);

            // initialise the mouse pointer system and add it as a service
            mousePointer = new Pointer(this, PointerType.mouse, true);
            base.Services.AddService(typeof(Pointer), mousePointer);

            // create the game state manager and register it as a service
            gameStateManager = new GameStateManager(this);
            base.Services.AddService(typeof(GameStateManager), gameStateManager);

            // activate the initial example game states - in this example we are adding two :)
            gameStateManager.AddGameState(new Background(this, null));
            gameStateManager.AddGameState(new TitleScreen(this, null));

            // propogate initialise call to base class
            base.Initialize();
        }