6

I am aware that when playing with a keyboard it is possible to crouch using the DOWN arrow key, however I can't find a way to crouch when playing on mobile/touch device.

Actions I have tried without success:

  • tap with two-fingers
  • tap with three-fingers
  • swiping down
  • press and hold
  • double tap
  • tapping in various positions (ie nearer the bottom of the screen, nearer the right-hand side, etc)

Does anyone know if it's possible?

1

On mobile, it's not possible to "duck" as the source calls it because it fires the event based off of what key code was pressed down. On a mobile keyboard, you don't have the ability to press key code 40, which is the down arrow because most (if not all?) mobile keyboards on devices do not have a down arrow key!

The source for the "Downasaur" can be found in a Javascript file called offline.js. It is publicly available through the Chromium GitHub repository.

If you weren't on mobile, the actual code that makes the dinosaur duck starts on line 712:

.
.
.
else if (this.playing && Runner.keycodes.DUCK[e.keyCode]) {
      e.preventDefault();
      if (this.tRex.jumping) {
        // Speed drop, activated only when jump key is not pressed.
        this.tRex.setSpeedDrop();
      } else if (!this.tRex.jumping && !this.tRex.ducking) {
        // Duck.
        this.tRex.setDuck(true);
      }
    }

Note how it makes use of keyCodes. The down arrow key code is 40 which on a mobile device is not possible to "press" since for one the keyboard isn't available when playing this game on a mobile device and two there is no down arrow on a mobile keyboard - not any that I've seen!

The good news is, the game can tell if you are on a mobile device or not and if you are, it automatically adjusts the Y Coordinates that obstacles are allowed to spawn at. The only obstacle that can even spawn at a height where ducking can be useful when playing the game on a computer is the pterodactyl - see yPosMobile below:

 .
 .
 .
 type: 'PTERODACTYL',
    width: 46,
    height: 40,
    yPos: [ 100, 75, 50 ], // Variable height.
    yPosMobile: [ 100, 50 ], // Variable height mobile.
    multipleSpeed: 999,  

I'm willing to bet (although I haven't tried for myself) that if you connect a keyboard to your device via Bluetooth or some other means, that the mobile game would still let you duck using the connected keyboard. There doesn't seem to be anything in the source that indicates this otherwise, but maybe I missed it. Take a look for yourself!

2
  • 1
    Great research and well explained. I'd played enough to see the pterodactyls do appear but not enough to realise they will never be at a height that can't be jumped over nor ducked under - your second code snippet solves that mystery! – Chris Feb 23 '20 at 22:06
  • @Chris I've become a bit of an expert on this game - this isn't the first time that I've dug into the source code for this game for an answer... My last answer for this game was a much deeper dive :) – Timmy Jim Feb 23 '20 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.