I am having an issue with pyinstaller where it would create the executable file just fine, however it would not load saved states. For example, after a checkpoint is made, it saves to a file which file is then used to load variables if/when the player gets game over or closes the game. Normally, when testing in development mode opening the program via terminal, this functionality works fine. However, when creating the executable file, since it keeps things in a frozen state, it does not reach the updated save file(s).
Here's a piece of my code which is used to load saved states which works fine when open via command line/terminal:
if pygame.sprite.spritecollide(player, exit_level_group, False):
if not level == 99:
score_count += 100
if level == 99:
with open('savestate.py', 'w') as file:
file.write('check_point = ' + str(check_point) + '\
\nlives_count = ' + str(lives_count) + '\
\ncash_count = ' + str(cash_count) + '\
\nscore_count = ' + str(score_count) + '\
\nrock_sold = ' + str(rock_sold) + '\
\ncard_sold = ' + str(card_sold) + '\
\ncigs_sold = ' + str(cigs_sold) + '\
\ngear_sold = ' + str(gear_sold) + '\
\ngame1_won = ' + str(game1_won) + '\
\ngame2_won = ' + str(game2_won) + '\
\ngame3_won = ' + str(game3_won) + '\
\ngame4_won = ' + str(game4_won) + '\
\ndoorlevel_46 = ' + str(doorlevel_46) + '\
\ndoorlevel_47 = ' + str(doorlevel_47) + '\
\ndoorlevel_48 = ' + str(doorlevel_48) + '\
\ndoorlevel_49 = ' + str(doorlevel_49) + '\
\ndoorlevel_52 = ' + str(doorlevel_52) + '\
\ndoorlevel_53 = ' + str(doorlevel_53) + '\
\ndoorlevel_54 = ' + str(doorlevel_54) + '\
\ndoorlevel_55 = ' + str(doorlevel_55))
Please let me know how I may resolve this issue. I couldn't find anything in documentation which would have addressed my issue and worked.
Best regards,
David Chavez.