CheatCodes is a simple plugin that can make cheat codes easily in ImpactJS during the game.
Copy cheat-codes.js to your lib/plugins/ directory.
Edit lib/game/main.js :
ig.module(
'game.main'
)
.requires(
// ... ,
'plugins.cheat-codes',
// ...
)
.defines(function(){
MyGame = ig.Game.extend({
// ...
cheats: new ig.CheatCodes(),
// ...
init: function() {
// All weapons !
this.cheats.addCode('IDKFQ',
[ ig.KEY.I, ig.KEY.D, ig.KEY.K, ig.KEY.F, ig.KEY.Q ],
function() {
ig.game.myEntityPlayer.weaponBullets = 99999;
});
// ...
},
// ...
});
});
this.cheats.addCode('IDDAD',
[ig.KEY.I, ig.KEY.D, ig.KEY.D, ig.KEY.A, ig.KEY.D],
function() {
this.cheats.removeCode( 'IDDAD' );
// Your code for this cheat
});
- addCode: Add a cheat code.
- name:
String
Name of cheat. - keys:
Array
Array of keys. See:ig.KEY.
. - success:
Function
Attach a function when the code is correct. The value ofig.game
provided for the call tosuccess
.
- name:
- removeCode: Remove a cheat code.
- name:
String
Name of cheat.
- name:
- removeAllCodes: Remove all the cheat codes.
Version 1.0.1
- Optimization
Version 1.0
- First commit