The worst javascript I've ever written in my life. But the game loop works.