/// <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) { // Allows the game to exit if (InputWrapper.Buttons.Back == ButtonState.Pressed) { this.Exit(); } mUWBLogo.Update(InputWrapper.ThumbSticks.Left, Vector2.Zero); mBall.Update(); mBall.Update(Vector2.Zero, InputWrapper.ThumbSticks.Right); // "A" to toggle to full-screen mode if (InputWrapper.Buttons.A == ButtonState.Pressed) { mBall = new SoccerBall(mSoccerPosition, mSoccerBallRadius * 2f); if (!Game1.sGraphics.IsFullScreen) { Game1.sGraphics.IsFullScreen = true; Game1.sGraphics.ApplyChanges(); } } // "B" toggles back to windowed mode if (InputWrapper.Buttons.B == ButtonState.Pressed) { if (Game1.sGraphics.IsFullScreen) { Game1.sGraphics.IsFullScreen = false; Game1.sGraphics.ApplyChanges(); } } // Button X to select the next object to work with if (InputWrapper.Buttons.X == ButtonState.Pressed) { mCurrentIndex = (mCurrentIndex + 1) % kNumObjects; } // Update currently working object with thumb sticks. mGraphicsObjects[mCurrentIndex].Update( InputWrapper.ThumbSticks.Left, InputWrapper.ThumbSticks.Right); base.Update(gameTime); base.Update(gameTime); mTheGame.UpdateGame(gameTime); if (InputWrapper.Buttons.A == ButtonState.Pressed) { mTheGame = new MyGame(); } }
/// <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. Game1.sSpriteBatch = new SpriteBatch(GraphicsDevice); // Define camera window bounds Camera.SetCameraWindow(new Vector2(10f, 20f), 100f); // Create the primitives. mGraphicsObjects = new TexturedPrimitive[kNumObjects]; mGraphicsObjects[0] = new TexturedPrimitive( "Soccer", // Image file name new Vector2(15f, 25f), // Position to draw new Vector2(10f, 10f)); // Size to draw mGraphicsObjects[1] = new TexturedPrimitive( "UWB-JPG", new Vector2(35f, 60f), new Vector2(50f, 50f)); mGraphicsObjects[2] = new TexturedPrimitive( "UWB-PNG", new Vector2(105f, 25f), new Vector2(10f, 10f)); mGraphicsObjects[3] = new TexturedPrimitive( "UWB-PNG", new Vector2(90f, 60f), new Vector2(35f, 35f)); // NOTE: Since the creation of TexturedPrimitive involves loading of textures, // the creation should occur in or after LoadContent() mUWBLogo = new TexturedPrimitive("UWB-PNG", new Vector2(30, 30), new Vector2(20, 20)); mBall = new SoccerBall(mSoccerPosition, mSoccerBallRadius * 2f); mTheGame = new MyGame(); // TODO: use this.Content to load your game content here }