if (not pygame.K_SPACE in keystates_old or not keystates_old[pygame.K_SPACE]) and (pygame.K_SPACE in keystates and keystates[pygame.K_SPACE]): if simulationRunning: manualControl = not manualControl else: rocket = RocketPhysics() controller = RocketControllerClass(rocket) s_count += 1 rocket.resetScenario(s_count) simulationRunning = True fillColor = WHITE if simulationRunning: landingStatus = rocket.landingStatus() if landingStatus != None: simulationRunning = False fillColor = GREEN if landingStatus else RED if manualControl: rocket.throttle = 1 if pygame.K_UP in keystates and keystates[pygame.K_UP] else 0 rocket.gimbal = 0 if pygame.K_LEFT in keystates and keystates[pygame.K_LEFT]: rocket.gimbal = -1 if pygame.K_RIGHT in keystates and keystates[pygame.K_RIGHT]: rocket.gimbal = 1 else: controller.setControls() rocket.timestep(1.0/60)