JavaScript Code Plays Google Dinosaur/T-Rex Game Automatically
edopedia.com
edopedia.com
setInterval(() => {
const { currentSpeed, horizon: { obstacles: [{ xPos, width, yPos } = {}] } } = Runner?.instance_;
if (xPos < 25 * currentSpeed - width && yPos >= 75)
document.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 32 }));
}, 100);So, I think the code I mentioned in the article is more efficient.
Essentially this is the same solution as in the post, just stripped down to the bare minimum of code, but I haven't tested it enough. There must be some edge case that it fails on
https://gist.github.com/Gaelan/a0c5461055437dca9618a12f68949...
(it does look safe though)
But actually, I minified this code so that people can quickly try it out. I'll try to explain it in some other article.
But, I had to make it as simple as possible for non-programmers.