Implement game logic (but it's a little buggy still)