--**Cheat Codes**--
Blitz3D Forums/Blitz3D Beginners Area/--**Cheat Codes**--
| ||
How do you add cheat codes to your game? Like type "extrapoints" while playing the game to gain extra points. Can it be done??? |
| ||
You could use an input command to create a console. Display it if a certain key is pressed, check the value and apply the appropriate cheat. ie. If the input is 'extralives' numlives = numlives +10 |
| ||
Thanks! |
| ||
i have never tried this, but i think you will have to keep checking for input. Once you get some input youll have to check to see if the key pressed is right, if it is you should up a variable to say that the user is one step closer to entering the full cheat, if a wrong key is pressed, reset the string and clear keys. Hope that makes sense. |
| ||
Ack - cant find it now, I think it's been archived, but a while back somone asked for how to do the code for repetitive button presses like in a beat 'em up game such as Tekken. The problem with just checking for key inputs is that the gameloops will happen so quickly that typing "HELLO" will appear to the computer as [code] H H H H E E E E L L L L L L L L L L O O O [/CODE] where it continuously records the keypresses and nul values between the keypresses. The use of GetKey$ and FlushKey is going to be very helpful, probably adding the output from GetKey$ to a string so you will end up with MyString$="CHEATCODE" HOpe this makes sense and helps. Any probs and I should be able to post an example a bit later :) |
| ||
I don't see the repeating keypresses as being a problem - just use KeyHit in your cheat code checking function, instead of KeyDown. I believe KeyHit (for code checking) and KeyDown (for game input) will work together fine, even if checking the same key. e.g. if you press 'A' in your game to move left, and you also need to check to see if 'A' has been pressed as part of a cheat code sequence, it should work OK. Also, when checking a sequence and an incorrect key is pressed, remember to check to see if that key is the first character of a cheat code sequence. |
| ||
using cheats is lame ;) |
| ||
using cheats is lame ;) |
| ||
@ malice- uh, use keyhit i think, wont that stop repeats? [edit]sorry didn't see ya there 10 |
| ||
keyhit is probably not the best choice since it will give you a number and you still don't know what key was hit. Even with a scancode table it may still confuse eg. Y and Z on a german keybord layout. Using GetKey() is better sample somewhere in mainloop: ;... g=getkey() if g<>0 cheat$=cheat$+chr$(g) if len(cheat$)>0 if upper$(right$(cheat$,3))="GOD" godmode=godmode xor 1 cheat$="" goto nocheat endif if upper$(right$(cheat$,4))="CURE" health=100 cheat$="" goto nocheat endif ; etc... .nocheat endif endif ;... |
| ||
ah, i thought something wasnt quite right with keyhit(), forgot about good old getkey() |