protected override void UpdateWorld() { if (GamePad.ButtonBackClicked()) { Exit(); } #region Elasticity and Friction by Left ThumbStick mElasticiy += 0.02f * GamePad.ThumbSticks.Left.X; mFriction += 0.02f * GamePad.ThumbSticks.Left.Y; #endregion if (GamePad.ButtonXClicked()) { World.Paused = !World.Paused; } if (!World.Paused) { #region shoot the ball if (GamePad.ButtonAClicked()) { Vector2 velocity = mVBlock.VelocityDirection * mVBlock.Speed; mBall.ShootSoccer(kInitPosition, velocity); } #endregion #region Update Velocity Dir and size by Right thumbStick mVBlock.UpdateVelocityBlock(GamePad.ThumbSticks.Right); #endregion #region tell the Ball to update itself mBall.Update(mElasticiy, mFriction); #endregion #region Rotate the Block mBlock.UpdateBlock(Vector2.Zero, GamePad.Triggers.Right); #endregion } EchoToTopStatus("Elasticity[LeftThumb.X]=" + mElasticiy + " Friction[LeftThumb.Y]=" + mFriction); EchoToBottomStatus("Vector Direction" + mVBlock.VelocityDirection + " Size: " + mVBlock.Speed); }
protected override void UpdateWorld() { if (GamePad.ButtonBackClicked()) { Exit(); } #region Pause everything if (GamePad.ButtonXClicked()) { World.Paused = !World.Paused; } if (World.Paused) { return; } #endregion #region shoot the ball if (GamePad.ButtonAClicked()) { Vector2 velocity = mVBlock.VelocityDirection * mVBlock.Speed; mBall.ShootSoccer(kInitPosition, velocity); } #endregion #region Update Velocity Dir and size by thumbSticks mVBlock.UpdateVelocityBlock(GamePad.ThumbSticks.Right, GamePad.ThumbSticks.Left.Y); #endregion #region tell the Ball to update itself mBall.Update(); #endregion #region Rotate the Block mBlock.UpdateBlock(Vector2.Zero, GamePad.Triggers.Right); #endregion EchoToTopStatus("Block rotated angle=" + mBlock.RotateAngle); EchoToBottomStatus("Vector Direction" + mVBlock.VelocityDirection + " Size: " + mVBlock.Speed); }
protected override void UpdateWorld() { if (GamePad.ButtonBackClicked()) { Exit(); } // Update all of them!! for (int i = 0; i < kTotalPlots; i++) { if (i != mCurrentPlot) { mPlotPath[i].Update(Vector2.Zero, 0f, 0f, 0f, Vector2.Zero); } } if (GamePad.ButtonXClicked()) { mCurrentPlot++; if (mCurrentPlot >= kTotalPlots) { mCurrentPlot = 0; } } if (GamePad.ButtonBClicked()) { mPlotPath[mCurrentPlot].ShowPlots = !mPlotPath[mCurrentPlot].ShowPlots; } if (GamePad.ButtonAClicked()) { mPlotPath[mCurrentPlot].ConstantSpeed = !mPlotPath[mCurrentPlot].ConstantSpeed; } float deltaW = GamePad.Triggers.Left; if (GamePad.Buttons.LeftShoulder == ButtonState.Pressed) { deltaW -= 0.2f; } float deltaH = GamePad.Triggers.Right; if (GamePad.Buttons.RightShoulder == ButtonState.Pressed) { deltaH -= 0.2f; } float deltaR = 0f; if (GamePad.Dpad.Up == ButtonState.Pressed) { deltaR += 2f; } else if (GamePad.Dpad.Down == ButtonState.Pressed) { deltaR -= 2f; } mPlotPath[mCurrentPlot].Update(GamePad.ThumbSticks.Right, deltaW, deltaH, deltaR, GamePad.ThumbSticks.Left); EchoToTopStatus("LeftThumb.X/Y adjust Amplitude/Period; Box: Pos-RightStick Size:Left/Right Trigger/Button; Rotate-Dpad Up/Down"); EchoToBottomStatus("XButton=NextPlot BButton=PlotAreaVisibility ... XCovearge=" + mPlotPath[mCurrentPlot].XCoverage + " YCoverage=" + mPlotPath[mCurrentPlot].YCoverage + " ConstantSpeed=" + mPlotPath[mCurrentPlot].ConstantSpeed); }
protected override void UpdateWorld() { if (GamePad.Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (GamePad.ButtonAClicked() && mMyBall == null) { PlayACue("powerup"); mMyBall = new Ball((World.WorldMax + World.WorldMin) / 2f, RandomFloat(0.5f, 2f)); } if (mMyPaddle != null) { mMyPaddle.updatePaddle( GamePad.ButtonXClicked(), GamePad.ButtonBClicked(), GamePad.ThumbSticks.Right); World.ClampAtWorldBound(mMyPaddle.mPaddle); } if (mMyBall != null) { mMyBall.updateBall( GamePad.Buttons.LeftShoulder, GamePad.Buttons.RightShoulder); bool collided = mMyBall.mBall.Collided(mMyPaddle.mPaddle); if (collided) { Score++; mMyBall.PaddleCollide(mMyPaddle); } BoundCollideStatus collideStatus = World.CollideWorldBound(mMyBall.mBall); switch (collideStatus) { case BoundCollideStatus.CollideBottom: Score = 0; mMyBall.DestroyBall(); mMyBall = null; break; case BoundCollideStatus.CollideTop: World.ClampAtWorldBound(mMyBall.mBall); mMyBall.WallCollide(true); EchoToTopStatus(collideStatus.ToString()); break; case BoundCollideStatus.CollideLeft: case BoundCollideStatus.CollideRight: World.ClampAtWorldBound(mMyBall.mBall); mMyBall.WallCollide(false); EchoToTopStatus(collideStatus.ToString()); break; } } EchoToBottomStatus("Score: " + Score.ToString()); }
protected override void UpdateWorld() { if (gameStarted && !gameOver) { int roomX = (int)theLevel.currentRoom.X; int roomY = (int)theLevel.currentRoom.Y; if (pauseScreen == null) { float x = theLevel.rooms[roomX, roomY].roomOrigin.X + 50f; float y = theLevel.rooms[roomX, roomY].roomOrigin.Y + 27f; pauseScreen = new XNACS1Rectangle(new Vector2(x, y), 100f, 54f); pauseScreen.Color = Color.Black; } if (GamePad.ButtonStartClicked()) { paused = paused ? false : true; } if (!paused) { if (GamePad.ButtonBackClicked()) { Exit(); } bool newLevel = false; newLevel = theLevel.updateLevel(GamePad.Buttons, GamePad.ThumbSticks); if (newLevel) { if (currentLevel < totalLevels) { currentLevel++; theLevel.unloadLevel(); switch (currentLevel) { case 1: path = @"level1.txt"; break; case 2: path = @"level2.txt"; break; case 3: path = @"level3.txt"; break; case 4: path = @"level4.txt"; break; default: break; } s = new StreamReader(path); theLevel = new Level(ref s); theLevel.loadInitialRoom(difficulty); } else { gameOver = true; } } if (pauseScreen.IsInAutoDrawSet()) { pauseScreen.RemoveFromAutoDrawSet(); pauseScreen = null; } } else { pauseScreen.AddToAutoDrawSet(); pauseScreen.Label = "PAUSED"; pauseScreen.LabelColor = Color.White; } gameOver = theLevel.hero.lives < 0; String message = "Number of Lives: " + theLevel.hero.lives + " Level Number: " + currentLevel; SetTopEchoColor(Color.White); EchoToTopStatus(message); } else if (gameOver) { World.SetWorldCoordinate(new Vector2(0, 0), 100f); cover = new XNACS1Rectangle(new Vector2(0, 0), 200, 200); cover.Color = Color.Black; gameOverText = new XNACS1Rectangle(new Vector2(50, 40), 40, 10); gameOverText.Label = "GAME OVER \n X TO RESTART"; gameOverText.Color = Color.Black; gameOverText.LabelColor = Color.White; if (GamePad.ButtonXClicked()) { gameOverText.RemoveFromAutoDrawSet(); gameOverText = null; cover.RemoveFromAutoDrawSet(); cover = null; this.InitializeWorld(); } } else if (!gameStarted) { if (GamePad.ButtonXClicked()) { if (selected.Center == easy.Center) { difficulty = 1; } else if (selected.Center == medium.Center) { difficulty = 2; } else { difficulty = 3; } theLevel.loadInitialRoom(difficulty); EchoToTopStatus(difficulty.ToString()); gameStarted = true; } if (ticks > 0) { ticks--; } else { if (GamePad.ThumbSticks.Right.Y > 0) { if (selected.Center != easy.Center) { if (selected.Center != medium.Center) { selected.Center = medium.Center; } else { selected.Center = easy.Center; } } ticks = 8; } else if (GamePad.ThumbSticks.Right.Y < 0) { if (selected.Center != hard.Center) { if (selected.Center != medium.Center) { selected.Center = medium.Center; } else { selected.Center = hard.Center; } } ticks = 8; } } } }