コード例 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            Locator.provide(MessageBoard.init());
            Locator.provide(InputHandler.init());
            Locator.provide(ComponentManager.init());
            Locator.provide(new Random());
            Locator.provide(new ControlManager(screen));
            Locator.getInputHandler().addKeyReleaseObserver(Locator.getControlManager().keyRelease);
            Locator.getInputHandler().addMouseReleaseObserver(Locator.getControlManager().mouseUp);
            Locator.getInputHandler().addMousePressObserver(Locator.getControlManager().mouseDown);
            ControlStates.BaseState.setParent(Locator.getControlManager());


            base.Initialize();
        }
コード例 #2
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)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Locator.getInputHandler().update(elapsed);
            Locator.getControlManager().update(elapsed);
            Locator.getComponentManager().update(elapsed);

            //world.spatial.translation_ = new Vector2((screen.X / 2) - player.spatial.translation_.X, (screen.Y / 2) - player.spatial.translation_.Y);

            /*MouseState ms = Mouse.GetState();
            *  Vector2 mous = new Vector2(ms.X, ms.Y);
            *  Vector2 spot = Locator.getShip().entity_.spatial.worldToLocal(mous);
            *  test.spatial.translation_ = spot;*/

            // TODO: Add your update logic here

            base.Update(gameTime);
        }