made proper game loop with reset function, and fixed some bugs