Reputation: 65
Need help, i googled and converted my project file to xbox 360, but i do not know the buttons and stuff.. to make it work on the game pad. here is what i done so far
if (isAI)
{
Ball b = Game1.ball; //this is AI
if (b.Y > padMiddle)
moveDown();
else if ((b.Y + height) < padMiddle)
moveUp();
}
else
{
GamePadState currentState = GamePad.GetState(PlayerIndex.One);
if (mouse.Y < padMiddle) // I need to replace mouse with xbox360 stuff
moveUp();
else if (mouse.Y > padMiddle)
moveDown();
mouse.y was declared as MouseState mouse = MouseState.GetState(); i need to replace that with xbox 360 buttons can someone help?
Upvotes: 2
Views: 275
Reputation: 1395
You were using a click on the paddle's upper region and lower region to determine if it should be moved up and down. That's going to be a fairly difficult thing to translate exactly on the 360.
If you really want to do it the exact same way, please clarify but if you want to translate it into something that makes more sense you're going to want to use the Thumbsticks for determining whether something should move up or down.
if (isAI) {
Ball b = Game1.ball; //this is AI
if (b.Y > padMiddle)
moveDown();
else if ((b.Y + height) < padMiddle)
moveUp();
}
else
{
GamePadState currentState = GamePad.GetState(PlayerIndex.One);
if (currentState.IsButtonDown(Buttons.LeftThumbstickUp)
{
moveUp();
}
else if (currentState.IsButtonDown(Buttons.LeftThumbstickDown)
{
moveDown();
}
}
In the above code, it's detecting if the player is pushing up or pushing down on the left thumbstick of the Xbox360 controller and then moves the paddle up and down appropriately
Upvotes: 1