I know how to catch two keys in a sequence. But can you catch as many keys in a sequence as you want.If yes, than can you tell me how to.
I'm new to game editor.
storeLastKey(getLastKey());
if(areLastKeys("cheat")) //Catch the cheat word
{
x += 10;
}
#define MAXKEYS 20
int lastKeys[MAXKEYS];
void storeLastKey(int key)
{
int i;
for(i = MAXKEYS-2; i >= 0; i--)
{
lastKeys[i+1] = lastKeys[i];
}
lastKeys[0] = key;
}
int areLastKeys(char *s)
{
int n = strlen(s), i;
if(n >= MAXKEYS) n = MAXKEYS - 1;
n--;
for(i = 0; i <= n; i++)
{
if(s[i] != lastKeys[n - i])
{
return 0;
}
}
return 1;
}
Users browsing this forum: No registered users and 1 guest