Drive a Bus 3 min read
Use your phone as a steering wheel in a free browser bus game
Most ways of using a phone as a steering wheel need an app on the phone, and often a program or a joystick driver on the computer as well. I wanted to skip the installs, so I made Drive a Bus, a 3D bus game that runs in your computer's browser while your phone's browser becomes the wheel. You scan the QR code on the computer's screen, then tilt the phone to steer and press the pedals on it.
How to use your phone as the steering wheel
- Open drive-a-bus.tukka.dev on a computer. It shows a QR code and a 6-digit code.
- Scan the QR code with your phone's camera. If your camera app doesn't open links, open the site on the phone and tap "Scan the QR code", or type the six digits.
- Tap Start on the phone. An iPhone asks once for motion access, which the page needs to read the tilt.
- Choose Upright or Sideways, hold the phone that way, and press Gas.
On the same Wi-Fi, the phone and the computer usually connect directly. Otherwise the inputs travel through the game's server, which adds a little delay. A dot under the code shows which one you got: green for direct, yellow for through the server.
Steering by tilting
The phone page reads gravity from the motion sensor. Wherever the phone points when you tap Start counts as straight ahead, and tilting it 60 degrees either way turns the wheel to full lock. If your arms get tired, Recenter takes the current angle as the new middle. Gas is on the right and the brake on the left, and the middle of the wheel is the horn. The phone's screen stays on while you drive, and an Android phone buzzes when you crash.
What's on the road
The road is an American four-lane street that never ends, with a double yellow line down the middle and houses, shops, trees and street lights along it. A bus stop comes every 400 to 650 meters. The bus tops out at 60 km/h and takes about 10 seconds to reach 50.
Cars and motorbikes drive in all four lanes. Slow cars hold up the curb lane, where the stops are, so you pass them in the inner lane. Quicker cars come up behind you and overtake. Motorbikes ride at 40 to 60 km/h and weave between the lanes. When something blocks your lane, honk, and whatever is just ahead moves over if the other lane has room. A car with no room stays put; a motorbike speeds off instead.
Stops, points and crashes
Stop inside the yellow box in the curb lane, next to the shelter, and the doors open. Riders whose stop it is get off, each worth 10 points, and the people waiting get on and pick a later stop.
Crashing into a car, a house, a tree or a lamp post costs 25 points and one of your three lives, and the third crash ends your shift. If a car runs into the back of the bus or moves over into it, you lose nothing, because the game works out who drove into whom. A motorbike you hit tumbles over, rider and all, which costs 50 points but no life. The computer remembers your best score.
Taking turns
Another phone can join with the same code, shown again in the pause menu, and take over the wheel, so a family or a group of friends can pass the driving around without starting again. If a phone drops out, the game pauses and shows the code until one connects.
What you need
A computer with a browser that can show 3D graphics (WebGL), such as Chrome, Edge, Firefox or Safari, and an iPhone or an Android phone for the wheel. Without a phone, the arrow keys or WASD drive the bus and H honks.
What leaves your phone
The phone sends the computer only its steering amount, the pedals and the horn. The motion readings stay on the phone, and so does the camera picture when you scan; the camera turns off once it has read the code. The game's server pairs the two devices by the code and passes their messages along without storing them. The site has no accounts, and its analytics counts visits with a random ID, keeping those records for 40 days.
Drive a Bus is free. Pick up your phone and start a shift at drive-a-bus.tukka.dev.