Page 1 of 1

Cheat Code

PostPosted: Sun Mar 07, 2004 10:11 am
by ingsan
i think that putting a cheat code in GE games is actually possible. :? Well i actually don't know how i'm gonna manage that, but it would be interesting if we ponder about it.

To start, maybe we should ask ourself :

Code: Select all
if i press this key, then that one, and then that other one, it makes This
:?

i don't know if someone can help me, but if anyone's got an idea, i will forever be gratful to him, or her... :wink:

PostPosted: Sun Mar 07, 2004 10:05 pm
by jazz_e_bob
Broad Overview? :)

We need to create a keypress string that contains the most recent keys pressed.

When a new key is hit it is added to the end of the string. The first character in the list is deleted.

We then need to scan that list at regular intervals for "cheat" sequences and, if one is found, apply the appropriate cheat.

The scan routine could be a simple strstr.

Does GE support strstr? Maybe not... hmmm

Image

Anyway...

strstr will find a sub-string within a string.

Library: string.h

Prototype: char * strstr(const char *s1, const char *s2);

Syntax: char string1[]="red dwarf";
char string2[]="dwarf";
void *pointer;
pointer = strstr(string1, string2);

strstr returns a pointer to the beginning of the sub-string or NULL if not found.

PostPosted: Mon Mar 08, 2004 11:27 am
by ingsan
:) Great jazz-e-bob. Well i got to say that i quite did not understand most of what u said, but it puts me on the track. 8)

I'm gonna ponder on that and try to make some research to understand more about that C function.

Thank you very very much. :wink: