public void handleInput() { ih.update(Keyboard.GetState()); if (ih.allowSinglePress(Keys.Escape)) { Game.Exit(); } if (ih.allowSinglePress(Keys.Space)) // debug { for (int x = 0; x < 8; x++) { playersReady[x] = true; } } GamePadState gps1 = GamePad.GetState(PlayerIndex.One); GamePadState gps2 = GamePad.GetState(PlayerIndex.Two); GamePadState gps3 = GamePad.GetState(PlayerIndex.Three); GamePadState gps4 = GamePad.GetState(PlayerIndex.Four); ih.updateGamepads(gps1, gps2, gps3, gps4); for (int x = 0; x < 4; x++) { if (ih.allowSingleGPpress(1, 'j')) { playersReady[0] = true; entry.Play(); } if (ih.allowSingleGPpress(1, 'k')) { playersReady[1] = true; entry.Play(); } if (ih.allowSingleGPpress(2, 'j')) { playersReady[2] = true; entry.Play(); } if (ih.allowSingleGPpress(2, 'k')) { playersReady[3] = true; entry.Play(); } if (ih.allowSingleGPpress(3, 'j')) { playersReady[4] = true; entry.Play(); } if (ih.allowSingleGPpress(3, 'k')) { playersReady[5] = true; entry.Play(); } if (ih.allowSingleGPpress(4, 'j')) { playersReady[6] = true; entry.Play(); } if (ih.allowSingleGPpress(4, 'k')) { playersReady[7] = true; entry.Play(); } } }
public void handleInput() { ih.update(Keyboard.GetState()); if (ih.allowSinglePress(Keys.Escape)) { Game.Exit(); } }
public void handleInput() { ih.update(Keyboard.GetState()); if (ih.allowSinglePress(Keys.Escape)) { Game.Exit(); } if (ih.allowSinglePress(Keys.T)) { playerOne.gravityVelocity.X = -99; } if (ih.allowSinglePress(Keys.E)) { createTempExplosion(); } if (goTimer > 0) { return; } GamePadState gp1 = GamePad.GetState(PlayerIndex.One); GamePadState gp2 = GamePad.GetState(PlayerIndex.Two); GamePadState gp3 = GamePad.GetState(PlayerIndex.Three); GamePadState gp4 = GamePad.GetState(PlayerIndex.Four); ih.updateGamepads(gp1, gp2, gp3, gp4); Vector2 p1stick = ih.sticks[playerOneNumber]; Vector2 p2stick = ih.sticks[playerTwoNumber]; if (invertControls) { p1stick *= -1; p2stick *= -1; } if (Math.Abs(playerOne.gravityVelocity.X) > 0) { if (playerOne.gravityVelocity.X > 0) { playerOne.gravityVelocity.X += p1stick.X; if (playerOne.gravityVelocity.X < 0) { playerOne.gravityVelocity.X = 0; } } else { playerOne.gravityVelocity.X += p1stick.X; if (playerOne.gravityVelocity.X > 0) { playerOne.gravityVelocity.X = 0; } } } playerOne.stickVelocity.X += (p1stick.X - playerOne.lastStickPosition.X) * 10; playerOne.lastStickPosition = p1stick; if (Math.Abs(playerTwo.gravityVelocity.X) > 0) { if (playerTwo.gravityVelocity.X > 0) { playerTwo.gravityVelocity.X += p2stick.X; if (playerTwo.gravityVelocity.X < 0) { playerTwo.gravityVelocity.X = 0; } } else { playerTwo.gravityVelocity.X += p2stick.X; if (playerTwo.gravityVelocity.X > 0) { playerTwo.gravityVelocity.X = 0; } } } playerTwo.stickVelocity.X += (p2stick.X - playerTwo.lastStickPosition.X) * 10; playerTwo.lastStickPosition = p2stick; if (playerOne.velocity.X < -0.1) { playerOne.facingLeft = true; } else if (playerOne.velocity.X > 0.1) { playerOne.facingLeft = false; } if (playerTwo.velocity.X < -0.1) { playerTwo.facingLeft = true; } else if (playerTwo.velocity.X > 0.1) { playerTwo.facingLeft = false; } if (playerOneNumber % 2 == 0) // left side of the controller { int p1cn = controllerNumbers[playerOneNumber]; if (ih.allowSingleGPpress(p1cn, 'l') && playerOne.grounded) { playerOne.gravityVelocity.Y = -60; jumpSF.Play(); playerOne.animHandler.setAnimation(1, true); } if (ih.allowSingleGPpress(p1cn, 'j') && playerOne.fireTime <= 0) { fieldSF.Play(); playerOne.fireTime = 2000; p1Field.position = new Vector2(playerOne.boundingRectangle.Center.X - (p1Field.size.X / 2), playerOne.boundingRectangle.Center.Y - (p1Field.size.Y / 2)); } } else { int p1cn = controllerNumbers[playerOneNumber]; if (ih.allowSingleGPpress(p1cn, 'r') && playerOne.grounded) { playerOne.gravityVelocity.Y = -60; jumpSF.Play(); playerOne.animHandler.setAnimation(1, true); } if (ih.allowSingleGPpress(p1cn, 'k') && playerOne.fireTime <= 0) { fieldSF.Play(); playerOne.fireTime = 2000; p1Field.position = new Vector2(playerOne.boundingRectangle.Center.X - (p1Field.size.X / 2), playerOne.boundingRectangle.Center.Y - (p1Field.size.Y / 2)); } } if (playerTwoNumber % 2 == 0) // left side of the controller { int p2cn = controllerNumbers[playerTwoNumber]; if (ih.allowSingleGPpress(p2cn, 'l') && playerTwo.grounded) { playerTwo.gravityVelocity.Y = -60; jumpSF.Play(); playerTwo.animHandler.setAnimation(1, true); } if (ih.allowSingleGPpress(p2cn, 'j') && playerTwo.fireTime <= 0) { fieldSF.Play(); playerTwo.fireTime = 2000; p2Field.position = new Vector2(playerTwo.boundingRectangle.Center.X - (p2Field.size.X / 2), playerTwo.boundingRectangle.Center.Y - (p2Field.size.Y / 2)); } } else { int p2cn = controllerNumbers[playerTwoNumber]; if (ih.allowSingleGPpress(p2cn, 'r') && playerTwo.grounded) { playerTwo.gravityVelocity.Y = -60; jumpSF.Play(); playerTwo.animHandler.setAnimation(1, true); } if (ih.allowSingleGPpress(p2cn, 'k') && playerTwo.fireTime <= 0) { fieldSF.Play(); playerTwo.fireTime = 2000; p2Field.position = new Vector2(playerTwo.boundingRectangle.Center.X - (p2Field.size.X / 2), playerTwo.boundingRectangle.Center.Y - (p2Field.size.Y / 2)); } } }