Sorry, here is a portion of the script which loads a saved state when game 
over is triggered. The code in the first post is for when the exe saves but 
that portion works fine as intended. This part is where the trouble starts. 

# Check whether the game is over or not.
if lives_count <= 0:
lives_count = 0
enemy_count = 0
game_over = True
level = 66
if time_count != str("OUT"):
gameMusic()
bg_img = black_bg
draw_text('GAME OVER', font_s_game_over, white, (screen_width // 2) - 200, 
(screen_height // 2) -100)
player.rect.x = (screen_width // 2) - 25
player.rect.y = (screen_height // 2) + 125
player.image = dead_ball_img
exit_level_group.empty()
bricks_group.empty()
brickschange_group.empty()
breakbricks_group.empty()
barbwire_group.empty()
cash_group.empty()
info_ball_group.empty()
spike_goon_group.empty()
spike_boss_group.empty()
soccer_goon_group.empty()
soccer_boss_group.empty()
tnt_group.empty()
boobytrap_group.empty()
hooks_goon_group.empty()
hooks_boss_group.empty()
shadow_goon_group.empty()
shadow_boss_group.empty()
foot_goon_group.empty()
foot_boss_group.empty()
if rock_inuse:
level = 64
time_count = int(555)
if card_inuse:
level = 65
time_count = int(777)
if cigs_inuse:
level = 67
time_count = int(666)
draw_text('Need a clue? Click the pack...', font_s, blue, 360, 670)
if gear_inuse:
level = 68
time_count = int(888)
if continue_button.draw():
game_over = False
if check_point == -1:
level = 0
lives_count = 2
cash_count = 0
score_count = 0
elif not check_point == -1:
importlib.reload(savestate)
level = savestate.check_point + 1
score_count = savestate.score_count
gameMusic()

It seems to import the save state (savestate) from the frozen exe instead 
of the update as I have stated previously.

On Friday, November 21, 2025 at 9:26:05 AM UTC-8 David Chavez wrote:

> Hello,
>
> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/pyinstaller/c304f068-6dec-4b35-8830-bc887cd059bfn%40googlegroups.com.

Reply via email to