beginning of game logic. still very buggy. i wrote the java, tim wrote the javascript.