I am having trouble with a cheat code I am trying to make. I got the part where you type in the cheat just fine, but I have no clue as to how to make the cheat override previous code. Here is the code I am trying to override and the code I want to 'replace it'.
Code to Override:
//If the spacebar is pressed, a laser is fired
if(Greenfoot.isKeyDown("space") && !shooting)
{
//If the rapid fire cheat isn't typed, keep limited firing
getWorld().addObject(new Laser(), getX(), getY());
shooting = true;
}
Cheat Code:
//If rapid is typed into cheat bar (accessed through shift + c), enable rapid fire
if(Greenfoot.isKeyDown("shift") && Greenfoot.isKeyDown("c"))
{
if(Greenfoot.ask("Enter cheat code: ") == code)
{
if(Greenfoot.isKeyDown("space") && !shooting)
{
getWorld().addObject(new Laser(), getX(), getY());
shooting = false;
}
}
}
I don't know where to put the cheat code, nor do I know how to enable it and KEEP it enabled. Any help would be appreciated. Thanks in advance!