Skip to content

Commit

Permalink
Generic game wrapper enables start_game and reset_game
Browse files Browse the repository at this point in the history
  • Loading branch information
Baekalfen committed Feb 11, 2024
1 parent 8a4e9a4 commit 2acfb7e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
3 changes: 3 additions & 0 deletions pyboy/plugins/base_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ def start_game(self, timer_div=None):

if not self.pyboy.frame_count == 0:
logger.warning("Calling start_game from an already running game. This might not work.")
self.game_has_started = True
self.saved_state.seek(0)
self.pyboy.save_state(self.saved_state)

def reset_game(self, timer_div=None):
"""
Expand Down
2 changes: 0 additions & 2 deletions pyboy/plugins/game_wrapper_kirby_dream_land.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def start_game(self, timer_div=None):
# Wait for transition to finish (exit level intro screen, enter game)
self.pyboy.tick(60, False)

self.game_has_started = True

self.saved_state.seek(0)
self.pyboy.save_state(self.saved_state)

Expand Down
2 changes: 1 addition & 1 deletion pyboy/plugins/game_wrapper_super_mario_land.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def start_game(self, timer_div=None, world_level=None, unlock_level_select=False
# "MARIO" in the title bar and 0 is placed at score
if self.tilemap_background[0:5, 0] == [278, 266, 283, 274, 280] and \
self.tilemap_background[5, 1] == 256:
self.game_has_started = True
# Game has started
break

self.saved_state.seek(0)
Expand Down
2 changes: 0 additions & 2 deletions pyboy/plugins/game_wrapper_tetris.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ def start_game(self, timer_div=None):
self.saved_state.seek(0)
self.pyboy.save_state(self.saved_state)

self.game_has_started = True

self.reset_game(timer_div=timer_div)

def reset_game(self, timer_div=None):
Expand Down

0 comments on commit 2acfb7e

Please sign in to comment.