mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-20 14:02:03 +00:00
Fix issues with pygame event handling (#2684)
* Fix issues with pygame event handling * Fix display initialization and exit for jupyter
This commit is contained in:
committed by
GitHub
parent
29cf1e5393
commit
6f1ec7cc1b
@@ -269,6 +269,7 @@ class AcrobotEnv(core.Env):
|
||||
def render(self, mode="human"):
|
||||
if self.screen is None:
|
||||
pygame.init()
|
||||
pygame.display.init()
|
||||
self.screen = pygame.display.set_mode((self.SCREEN_DIM, self.SCREEN_DIM))
|
||||
if self.clock is None:
|
||||
self.clock = pygame.time.Clock()
|
||||
@@ -326,6 +327,7 @@ class AcrobotEnv(core.Env):
|
||||
self.surf = pygame.transform.flip(self.surf, False, True)
|
||||
self.screen.blit(self.surf, (0, 0))
|
||||
if mode == "human":
|
||||
pygame.event.pump()
|
||||
self.clock.tick(self.metadata["render_fps"])
|
||||
pygame.display.flip()
|
||||
|
||||
@@ -338,6 +340,7 @@ class AcrobotEnv(core.Env):
|
||||
|
||||
def close(self):
|
||||
if self.screen is not None:
|
||||
pygame.display.quit()
|
||||
pygame.quit()
|
||||
self.isopen = False
|
||||
|
||||
|
Reference in New Issue
Block a user