All of us like to have an extra edge while playing games (i mean cheat codes :P ). Most games have such codes that allow you to alter the gaming experience while many other games find it illegal to use such hacks.
But, have you thought about how all this works?
Let us understand it by actually ‘HACKING’ one of the simplest games out there — the T-rex runner.
For those who do not know, it is a side scrolling runner game that appears on the ‘No Internet’ screen of Google Chrome.
This 8-bit-type game features a tiny t-rex which runs through a desert. You have to avoid the t-rex from hitting the obstacles like cacti etc. Believe me, it is simple but addictive.
We will be using simple Javascript commands to tweak the game for fun!
Sounds cool? Let's do it.
1. Getting into the game’s console
First, disconnect your device from the internet and open Google Chrome. Enter any url and you will see the no internet screen with a t-rex dino.
If you want to stay online for some reason, simply enter ‘chrome://dino’ in the address bar.
Now, right click inside the window and click the Inspect option from the menu. Alternatively, you can use the shortcut key combination — Ctrl+Shift+I.
In the side panel which opens, you will be able to see the source code of the game. Next, click the console tab. This is the place where we will run our simple Javascript code to alter the game.