Welcome to T-Rex — an exciting spin on the classic Chrome T-Rex runner. Instead of pressing spacebar, you literally jump while holding your phone, and watch T-Rex leap on the big screen!
Try out the game at trex.rohittp.com
Originally inspired by the famous Chrome offline T-Rex game, we’ve given it a modern twist: real-world motion input via your phone.
- No more button mashing.
- No more arrow key spam.
- It’s time to jump and let your phone handle the rest!
- Server: A Node.js/Express app with WebSockets keeps track of multiple game sessions.
- Desktop Browser: Displays the T-Rex game (HTML5 Canvas) and listens for jump signals from the server.
- Phone / Controller: Opens a special controller page, uses device motion APIs to detect your jumps, and sends jump commands via WebSocket to the server.
git clone https://github.com/rohittp0/trex
cd trex
bun install
openssl genpkey -algorithm RSA -out private.key
openssl req -new -key private.key -out certificate.csr
openssl x509 -req -days 365 -in certificate.csr -signkey private.key -out certificate.crt
mkdir certificate
mv private.key certificate.crt certificate/
rm certificate.csr
bun run dev
- Go to https://localhost:3000 on desktop.
- Look for the Game ID displayed.
- On your phone, navigate to https://:3000
- Enter the Game ID.
- Start jumping!
A quick look at the main directories and files:
.
├── public
│ ├── css
│ │ ├── index.css
│ │ ├── controller.css
│ │ └── game.css
│ ├── images
│ │ └── cover.jpg # Our epic cover image
│ ├── js
│ │ ├── index.js
│ │ ├── controller.js
│ │ ├── motion.js
│ │ └── runner
│ │ ├── Runner.js
│ │ ├── Trex.js
│ │ ├── ...
│ │ └── collisionHelpers.js
│ ├── game.html # Game page
│ ├── controller.html # Phone interface
│ └── index.html # Desktop landing page
├── index.ts # The Express/WS server
├── tsconfig.json
└── package.json
public/
: Frontend code, including HTML, CSS, images, and client JS.runner/
: Modular classes for the T-Rex game (Trex, Horizon, Obstacles, etc.).index.ts
: The Node/Express + WebSocket server.
We’d love your help to make the T-Rex game even better! Feel free to:
- Fork the repo
- Create a branch for your feature or fix (
git checkout -b feature/my-awesome-idea
) - Commit your changes (
git commit -m 'Add my awesome idea'
) - Push to your branch (
git push origin feature/my-awesome-idea
) - Open a Pull Request and we’ll review ASAP.
This project is licensed under the MIT License — you’re free to use, modify, and distribute it. See the LICENSE file for details.
Thanks for checking out T-Rex Motion Game. We hope you have a blast jumping around and making the little dino dodge cacti. If you have questions or run into any issues, please open an issue.
Let’s jump to it — literally!