added --windowed parameter, fixed missing surface assignment

This commit is contained in:
Nicholas Dyer 2023-05-12 23:42:21 -04:00
parent d932538b41
commit e6cb2bd4c8
2 changed files with 17 additions and 9 deletions

View File

@ -9,15 +9,18 @@ import pocket_friends.game_files.game as game
if __name__ == '__main__': if __name__ == '__main__':
enable_dev = False enable_dev = False
windowed = False
# enable dev mode if --dev argument is passed # enable dev mode if --dev argument is passed
if len(sys.argv) > 0: if len(sys.argv) > 0:
for args in sys.argv: for arg in sys.argv:
if args == '--delete-save': if arg == '--delete-save':
save_dir = os.path.join(Path.home(), '.pocket_friends') save_dir = os.path.join(Path.home(), '.pocket_friends')
os.remove(save_dir + '/save.json') os.remove(save_dir + '/save.json')
if arg == '--windowed':
windowed = True
game.main() game.main(windowed)
pygame.quit() pygame.quit()
sys.exit() sys.exit()

View File

@ -32,7 +32,7 @@ starting_surface = 'title'
# Gets the directory of the script for importing and the save directory # Gets the directory of the script for importing and the save directory
def game(): def game(windowed=False):
""" """
Starts the game. Starts the game.
""" """
@ -41,9 +41,14 @@ def game():
# The game is normally rendered at 80 pixels and upscaled from there. If changing displays, change the # The game is normally rendered at 80 pixels and upscaled from there. If changing displays, change the
# screen_size to reflect what the resolution of the new display is. # screen_size to reflect what the resolution of the new display is.
screen_size = 240 if windowed:
pygame.mouse.set_visible(False) screen_size = 480
window = pygame.display.set_mode((screen_size, screen_size), pygame.FULLSCREEN) window = pygame.display.set_mode((screen_size, screen_size))
else:
screen_size = 240
pygame.mouse.set_visible(False)
window = pygame.display.set_mode((screen_size, screen_size), pygame.FULLSCREEN)
surface = surface_modules.get(starting_surface).Surface((game_res, game_res), resources_dir, game_fps)
# Add an icon to the pygame window. # Add an icon to the pygame window.
icon = pygame.image.load(resources_dir + '/icon/icon.png').convert_alpha() icon = pygame.image.load(resources_dir + '/icon/icon.png').convert_alpha()
@ -75,10 +80,10 @@ def game():
pygame.display.flip() pygame.display.flip()
def main(): def main(windowed=False):
""" """
Calls the game() function to start the game. Calls the game() function to start the game.
""" """
game() game(windowed)
pygame.quit() pygame.quit()