I've been working on a really simple game as a base for a project in my CS course, but while mapping the movement commands, I keep having trouble making the character sprite move upwards as well as swap textures. Whenever I try moving upwards, the character moves up one space and swaps textures, then resets to the previous position when I release the button. I've tried a few different methods and I end up with pretty much the same result. Any suggestions would be greatly appreciated.
public static void Update ()
{
// Query gamepad for current state
var gamePadData = GamePad.GetData (0);
pnut = pnutDefault;
pnutDown.Position = pnut.Position;
if ((gamePadData.Buttons & GamePadButtons.Left) != 0)
{
pnut.Position.X--;
}
if ((gamePadData.Buttons & GamePadButtons.Right) != 0)
{
pnut.Position.X++;
}
if ((gamePadData.Buttons & GamePadButtons.Down) != 0)
{
pnut.Position.Y++;
}
if ((gamePadData.Buttons & GamePadButtons.Up) != 0)
{
//pnutDown.Position = pnut.Position;
pnutDown.Position.Y--;
pnut.Position.Y--;
}
}