Update main.js

Separate object constructors from regular functions
add function tick
add tileLength