Skip to content

Instantly share code, notes, and snippets.

@BTMPL
Created December 23, 2016 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BTMPL/889ef7feca21b292c1f2c28d934d99ee to your computer and use it in GitHub Desktop.
Save BTMPL/889ef7feca21b292c1f2c28d934d99ee to your computer and use it in GitHub Desktop.
dino cheat ;)
Podium = {};
Podium.keydown = function(k) {
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
return this.keyCodeVal;
}
});
Object.defineProperty(oEvent, 'which', {
get : function() {
return this.keyCodeVal;
}
});
if (oEvent.initKeyboardEvent) {
oEvent.initKeyboardEvent("keydown", true, true, document.defaultView, false, false, false, false, k, k);
} else {
oEvent.initKeyEvent("keydown", true, true, document.defaultView, false, false, false, false, k, 0);
}
oEvent.keyCodeVal = k;
if (oEvent.keyCode !== k) {
alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
}
document.dispatchEvent(oEvent);
}
Podium.keyup = function(k) {
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
return this.keyCodeVal;
}
});
Object.defineProperty(oEvent, 'which', {
get : function() {
return this.keyCodeVal;
}
});
if (oEvent.initKeyboardEvent) {
oEvent.initKeyboardEvent("keyup", true, true, document.defaultView, false, false, false, false, k, k);
} else {
oEvent.initKeyEvent("keyup", true, true, document.defaultView, false, false, false, false, k, 0);
}
oEvent.keyCodeVal = k;
if (oEvent.keyCode !== k) {
alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
}
document.dispatchEvent(oEvent);
}
setInterval(() => {
if(Runner.instance_.horizon.obstacles.length > 0) {
if(!Runner.instance_.horizon.obstacles[0].actedOn && Runner.instance_.horizon.obstacles[0].xPos < 120 && Runner.instance_.horizon.obstacles[0].xPos > 0) {
Runner.instance_.horizon.obstacles[0].actedOn = true;
if(Runner.instance_.horizon.obstacles[0].yPos <= 75) { console.log("duck"); Podium.keydown(40); }
else { console.log("jump"); Podium.keyup(40); Podium.keydown(32); Podium.keyup(32) };
}
}
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment