SubiDroid

The Invincible Dino

Sep 04, 2020 • 9:26 AM • Subin Gyawali

4 min read


 

It may sound stupid if I ask you 'Have you ever seen this screen?', right?
Yes, as you are reading this article in a website, you must have seen this screen once in your life while browsing the web. This screen appears in some chromium-based browsers such as Chrome, Brave etc. when your internet goes off while browsing. From this screen you can play an exciting dinosaur running game known as 'Chrome Dino Run Game' offline. Today I will be sharing some tweaks to modify our Dino game on desktop browsers for fun. So, let's begin:
 

How to open Dino game manually?
If you do not have an internet connection, you need not do anything special to play this game. But you can open and play this game while you are online too. To do that, you can simply go to address bar of supported chromium browser such as Google Chrome and type in chrome://dino. The same screen will appear and now you can play the game.
 


 

The basic gameplay is like you can start your game by pressing space bar and the dinosaur starts running on your screen. The only thing you need to do is control your Dino to avoid obstacles with up and down arrow keys. If your dinosaur hits any of the obstacles in the path such as cactus or bird, your game will be over. While you go on avoiding obstacles, the speed of your dinosaur gradually increases and if you keep on going like that, your dinosaur will run to infinity. Your high score is recorded on the browser you are playing.
 

Now let's tweak this game to have more fun.
 

Tweak: Indestructible Dino
First, I will be tweaking this game to make our dinosaur indestructible i.e. our dinosaur will not die, even if we hit any obstacles in the path. To do that refresh your Dino game page and right click on anywhere on the screen and select Inspect from the actions available.
 


 

A developer tools window will appear to the right of your screen by default. On that window, find a menu named Console and click on that.



 

Now you need to modify some default code configurations from here to tweak the game. Simply copy and paste the code below on your console window and press enter as shown in the image below:
 

Runner.prototype.gameOver = function(){}



 

Now close your developer tools window using close button on the top right corner of the window. Now press the space bar to see the magic! Your dinosaur will run above the obstacles and you can just sit back and watch your dinosaur running seamlessly.
 

Tweak: Dino with lightning speed
Now let's further modify the game to make it run with your specified speed. Currently the dinosaur is avoiding the obstacles, but its speed value is default. Now let's increase the speed of our Dino. To do that, again right click on the screen and click on inspect. Go to the console menu and copy and paste the code below:
 

Runner.instance_.setSpeed(100);


The number '100' can be replaced with any number you want.



 

If you use both code lines, the Dino will run with your defined speed and will not be affected by obstacles.
 

With this configuration, you can achieve as much score as you want but there is no way to stop it. If you exit the game without properly saving it, your score will not be recorded. So, let's fix that. To save your high score, copy and paste the codes below in your console window:
 

let a = Runner.prototype.gameOver
Runner.prototype.gameOver = function(){}
Runner.instance_.setSpeed(100);



 

This code will not bring any additional changes in your game for now. Now, after some gameplay if you want to stop the game and record your high score, just open the console window again and copy and paste the code below whenever you want to stop the game.
 

Runner.prototype.gameOver = a




Now close the console window and again press the space bar. Your game will now stop when the Dino hits an obstacle, and your score will be recorded.
 

Technicality
If we see these tweaks technically or programmatically, we are just modifying the default code configurations to insert our own JavaScript code. In the first part, we are changing the default value of gameOver function to blank. The gameOver function is called when Dino hits an obstacle. With our code, the gameOver function is called but we've set it to empty, so no action will be performed, and Dino continues moving. In the second tweak, we've used predefined setSpeed function to set our desired speed. Originally, the setSpeed function is called when modifying the speed of the Dino while gradually accelerating. In the third part, we are storing the previous code of gameOver function in a variable so that we can restore it later to end the game properly.

This game is not limited to only these modifications, there are several other things we can modify and make the game more enjoyable, such as modifying Dino character image, modifying obstacles and many more. To perform other modifications, you must have knowledge of JavaScript. You can simply copy and paste the whole code of the game from browser developer tools and paste in your code editor to analyze it. Analyzing the code, you can insert your own code and overwrite several default configurations temporarily.
 

Thank you for reading! Give it a love if you liked it.
Share it with your friends and enjoy the tweaks. 💖

#games  #javascript  #tweaks 

Leave A Comment




Comments

  • AC

    Sep 04, 2020 • 10:00 AM

    I was tired ! But Dino wasn't.
    Nice! Enjoyed implementing it.

  • Rachita

    Sep 05, 2020 • 10:25 AM

    I love this 🥰🥰🥰

  • Bkt

    Sep 08, 2020 • 6:09 PM

    Oh nice ☺️

  • Kushal

    Dec 08, 2020 • 7:41 PM

    It was fun...great work..keep it up

  • Sunny Raj Shrestha

    May 27, 2021 • 12:03 PM

    what a clever trick

Link Copied To Clipboard !