main game loop fully working except for end state.