# Bit Invader with iPad tilting controls

Just for a lark, I adapted the Bit Invader code so that it was controlled by tilting the iPad instead of touching the sides. It’s great fun to see these old games like this and Pacman programmed in Codea, but somehow emulating the controls by touching sides of the screen doesn’t smell right. Tilting the iPad does.

There are two modes, controlled by setting `hero.TrueGravity`. If `true` then gravity works like gravity: it controls the acceleration. If `false` then gravity works like a joystick: it controls the velocity. The behaviour when it hits the sides also changes depending on the mode. If `true` then it bounces off the sides (so by rocking the iPad in phase you can get some really fast movement). If `false` then it just stops when it gets to the side.

With just a modicum of encouragement, I could make it so that tilting the iPad up or down slows down or speeds up the vertical flow rate.

(Edit: Forgot the link http://www.math.ntnu.no/~stacey/HowDidIDoThat/iPad/Codea.html)

We know you really want to do it anyway, Andrew!

Nice work, Andrew. I never really liked the original controls I put in for Bit Invader. Yours are better.

Oh alright then, I’ll put in the vertical control.

The latest version (at the above URL) uses the vertical tilt to speed up or slow down the star field and the invaders (so that it looks as though the hero is speeding up or slowing down). With the `TRUEGRAVITY` boolean (now a global boolean) set to `false` then the absolute tilt (measured from the initial tilt) determines the speed factor. If `TRUEGRAVITY` is set to `true` then there is a built-in decay so that the change in speed only has a short-term effect (the idea is that it is as if the pilot is trying to maintain a constant speed, but sometimes encounters some friction (or some is removed) which has to be compensated for, but after a while the original speed is regained).

Going to try your new version.

With 1.2.5, Bit Invader could get a graphical overhaul using the new space shmup sprite pack.

I like it best with TRUEGRAVITY set to false, it feels more like an arcade game. Though i really like the decaying effect when it’s set to true.