this is a simple thing i made in about 10 minutes, and i thought id share it with everyone. to trigger the cheat codes, you press a sequence of directions and then press the pause/play button.
the example has 2 codes, the first one can be triggered by pressing up, down, up, down, play. it will bring up the music guide. the second code is empty.
feel free to edit and use as you desire.
Fields:
Code:
bool leftisdown = false, rightisdown = false, upisdown = false, downisdown = false, bisdown = false;
string cheatinput = "";
//make a new "cheatresult3 = false" for a new cheat result
bool cheatresult1 = false, cheatresult2 = false;
Update:
Code:
if (!leftisdown && GamePad.GetState(PlayerIndex.One).DPad.Left == ButtonState.Pressed)
leftisdown = true;
if (leftisdown && GamePad.GetState(PlayerIndex.One).DPad.Left == ButtonState.Released)
{
leftisdown = false;
cheatinput = cheatinput + "Left,";
}
if (!downisdown && GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Pressed)
downisdown = true;
if (downisdown && GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Released)
{
downisdown = false;
cheatinput = cheatinput + "Down,";
}
if (!rightisdown && GamePad.GetState(PlayerIndex.One).DPad.Right == ButtonState.Pressed)
rightisdown = true;
if (rightisdown && GamePad.GetState(PlayerIndex.One).DPad.Right == ButtonState.Released)
{
rightisdown = false;
cheatinput = cheatinput + "Right,";
}
if (!upisdown && GamePad.GetState(PlayerIndex.One).DPad.Up == ButtonState.Pressed)
upisdown = true;
if (upisdown && GamePad.GetState(PlayerIndex.One).DPad.Up == ButtonState.Released)
{
upisdown = false;
cheatinput = cheatinput + "Up,";
}
if (!bisdown && GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed)
bisdown = true;
DO NOT EDIT THE STUFF ABOVE, IT IS THE CORE BUTTON ENGINE.
the section below is still put within the update section, i cut it off to make it easier to find the parts you would change for the codes and functions.
Code:
if (bisdown && GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Released)
{
bisdown = false;
// CHEAT CODES SEQUENCES, ADD YOUR CHEAT CODE SEQUENCE HERE USING THE FORMAT FROM THE EXAMPLE BELOW
if (cheatinput == "Up,Down,Up,Down,")
cheatresult1 = true;
if (cheatinput == "Up,Down,Down,Up,")
cheatresult2 = true;
cheatinput = "";
}
if (cheatresult1)
{
Guide.show();
cheatresult1 = false;
}
if (cheatresult2)
{
cheatresult1 = false;
}