Enabling Cheats

Started by
4 comments, last by grekster 15 years, 9 months ago
How do i write code that enables players to use cheats such as infinite ammo and such?
Advertisement
Moved to For Beginners.
First of all "cheat codes" are not really designed for cheating. So why are they there? For testing. It allows the testers to do things and get through the game easier.

Your question can't really be answered without knowing more about your game, api, platform.

theTroll
Ok, well I am programming this game in XNA... and all i really want to enable through the cheats are extra outfits and more vehicles
Just set a boolean variable to true when a cheat is activated, false when not. Then in the update loop, check the boolean, if true, do code to do the cheat.

example for a one time cheat
if (input == "cheatcode") {  AddSuperDuperWeapon(Player);  input = "";}


example for a cheat that lasts
if (input = "cheatcode2"){  Cheat2 = true;}// And possibly somewhere elseif (Cheat2){  if (Player.Weapons[0].Ammo < Player.Weapons[0].FullAmmo)  {    Player.Weapons[0].Ammo = Player.Weapons[0].FullAmmo;  }}
my blog contains ramblings and what I am up to programming wise.
notice that

if (input = "cheatcode2")

should be

if (input == "cheatcode2")

Just incase you Copy/Paste Imgelling's code
Quote:Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!

This topic is closed to new replies.

Advertisement