如何修复进程已完成并退出代码 -805306369 (0xCFFFFFFF)
我遇到了一个奇怪的错误,我的游戏在 PyCharm 中随机崩溃,退出代码为 -805306369 (0xCFFFFFFF)
,我认为错误是在我的 while 循环中的某个地方,但我不知道在哪里
While 循环:
while True:
clock.tick(FPS)
# Start screen
if Starting_screen is True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
screen.fill((101, 67, 33))
screen.blit(Start_game_box, Start_game_box_rect)
screen.blit(Play_game_text, Play_game_text_rect)
screen.blit(Game_name_text, Game_name_text_rect)
screen.blit(Pepsi_credits_text, Pepsi_credits_text_rect)
screen.blit(Brew_credits_text, Brew_credits_text_rect)
screen.blit(Q_credits_text, Q_credits_text_rect)
screen.blit(mouse, mouse_rect)
mouse_pos = pygame.mouse.get_pos()
if pygame.MOUSEMOTION:
mx, my = mouse_pos
mouse_rect.x = mx
mouse_rect.y = my
mouse_pressed = pygame.mouse.get_pressed()
if (mouse_pressed[0]) and mouse_rect.colliderect(Start_game_box_rect):
Main_tycoon_screen = True
Play_game_text_rect.x = 9999
Game_name_text_rect.x = 9999
Start_game_box_rect.x = 9999
print(Main_tycoon_screen)
Starting_screen = False
print(Starting_screen)
pygame.display.update()
if Main_tycoon_screen is True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
screen.fill((101, 67, 33))
screen.blit(dropper1, (100, 400))
screen.blit(conveyor1, (100, 450))
screen.blit(dropper1_block, dropperblock1_rect)
screen.blit(sell_block1, sell_block1_rect)
screen.blit(Buy_block1, Buy_block1_rect)
screen.blit(Buy1_cost_text, Buy1_cost_text_rect)
# functions
spawn_dropper2()
spawn_dropper3()
spawn_dropper4()
spawn_dropper5()
spawn_dropper6()
spawn_dropper7()
spawn_dropper8()
spawn_dropper9()
spawn_dropper10()
spawn_dropper11()
spawn_dropper_rainbow()
spawn_conveyor2()
setting_stuff()
dropperblock1_rect.x += 2
mouse_pos = pygame.mouse.get_pos()
if pygame.MOUSEMOTION:
mx, my = mouse_pos
mouse_rect.x = mx
mouse_rect.y = my
screen.blit(mouse, mouse_rect)
# sell block collisions
if dropperblock12_rect.colliderect(sell_block1_rect):
monet += 500
dropperblock12_rect.x = 70
print(monet)
if dropperblock11_rect.colliderect(sell_block1_rect):
monet += 100
dropperblock11_rect.x = 560
print(monet)
if dropperblock10_rect.colliderect(sell_block1_rect):
monet += 70
dropperblock10_rect.x = 460
print(monet)
if dropperblock9_rect.colliderect(sell_block1_rect):
monet += 50
dropperblock9_rect.x = 360
print(monet)
if dropperblock8_rect.colliderect(sell_block1_rect):
monet += 30
dropperblock8_rect.x = 260
print(monet)
if dropperblock7_rect.colliderect(sell_block1_rect):
monet += 20
dropperblock7_rect.x = 160
print(monet)
if dropperblock6_rect.colliderect(sell_block1_rect):
monet += 15
dropperblock6_rect.x = 600
print(monet)
if dropperblock5_rect.colliderect(sell_block1_rect):
monet += 15
dropperblock5_rect.x = 500
print(monet)
if dropperblock4_rect.colliderect(sell_block1_rect):
monet += 10
dropperblock4_rect.x = 400
print(monet)
if dropperblock3_rect.colliderect(sell_block1_rect):
monet += 8
dropperblock3_rect.x = 300
print(monet)
if dropperblock2_rect.colliderect(sell_block1_rect):
monet += 6
dropperblock2_rect.x = 200
print(monet)
if dropperblock1_rect.colliderect(sell_block1_rect):
monet += 5
dropperblock1_rect.x = 100
print(monet)
# Buy block collisions
mouse_pressed = pygame.mouse.get_pressed()
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block1_rect) and monet >= 10:
monet -= 10
Buy_block1_rect.x = 999
Buy_block1_rect.y = 999
Spawn_dropper2 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block2_rect) and monet >= 30:
monet -= 30
Buy_block2_rect.x = 999
Buy_block2_rect.y = 999
Buy2_cost_text_rect.x = 999
Spawn_dropper3 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block3_rect) and monet >= 100:
monet -= 100
Buy_block3_rect.x = 999
Buy_block3_rect.y = 999
Buy3_cost_text_rect.x = 999
Spawn_dropper4 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block4_rect) and monet >= 200:
monet -= 200
Buy_block4_rect.x = 999
Buy_block4_rect.y = 999
Buy4_cost_text_rect.x = 999
Spawn_dropper5 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block5_rect) and monet >= 500:
monet -= 500
Buy_block5_rect.x = 999
Buy_block5_rect.y = 999
Buy5_cost_text_rect.x = 999
Spawn_dropper6 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block6_rect) and monet >= 1000:
monet -= 1000
Buy_block6_rect.x = 999
Buy_block6_rect.y = 999
Buy6_cost_text_rect.x = 999
Spawn_dropper7 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block7_rect) and monet >= 1500:
monet -= 1500
Buy_block7_rect.x = 999
Buy_block7_rect.y = 999
Buy7_cost_text_rect.x = 999
Spawn_dropper8 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block8_rect) and monet >= 2000:
monet -= 2000
Buy_block8_rect.x = 999
Buy_block8_rect.y = 999
Buy8_cost_text_rect.x = 999
Spawn_dropper9 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block9_rect) and monet >= 3000:
monet -= 3000
Buy_block9_rect.x = 999
Buy_block9_rect.y = 999
Buy9_cost_text_rect.x = 999
Spawn_dropper10 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block10_rect) and monet >= 4000:
monet -= 4000
Buy_block10_rect.x = 999
Buy_block10_rect.y = 999
Buy10_cost_text_rect.x = 999
Spawn_dropper11 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block11_rect) and monet >= 5000:
monet -= 5000
Buy_block11_rect.x = 999
Buy_block11_rect.y = 999
Buy11_cost_text_rect.x = 999
Spawn_dropper12 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_conveyor2_block_rect) and monet >= 10000:
monet -= 10000
Buy_conveyor2_block_rect.x = 999
Buy_conveyor2_text_rect.x = 999
Spawn_conveyor2 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
draw_monet_counter(f"monet: {monet}", "white", 60, 600, 50)
pygame.display.update()
这是
Spawn_conveyor2 = False
Spawn_dropper2 = False
Spawn_dropper3 = False
Spawn_dropper4 = False
Spawn_dropper5 = False
Spawn_dropper6 = False
Spawn_dropper7 = False
Spawn_dropper8 = False
Spawn_dropper9 = False
Spawn_dropper10 = False
Spawn_dropper11 = False
Spawn_dropper12 = False
Spawn_pho_dropper1 = False
def spawn_conveyor2():
if Spawn_conveyor2 is True:
screen.blit(conveyor2, (100, 200))
Buy_conveyor2_block_rect.x = 999
Buy_conveyor2_text_rect.x = 9999
Buy_pho1_rect.x = 110
screen.blit(Buy_pho1, Buy_pho1_rect)
def spawn_dropper2():
if Spawn_dropper2 is True:
Buy_block1_rect.x = 2400
screen.blit(Buy2_cost_text, Buy2_cost_text_rect)
screen.blit(dropper2, (200, 390))
screen.blit(dropper2_block, dropperblock2_rect)
Buy_block2_rect.x = 300
screen.blit(Buy_block2, Buy_block2_rect)
dropperblock2_rect.x += 2
Buy1_cost_text_rect.x = 999
def spawn_dropper3():
if Spawn_dropper3 is True:
screen.blit(dropper3, (300, 390))
screen.blit(dropper3_block, dropperblock3_rect)
dropperblock3_rect.x += 2
Buy_block3_rect.x = 400
screen.blit(Buy_block3, Buy_block3_rect)
screen.blit(Buy3_cost_text, Buy3_cost_text_rect)
def spawn_dropper4():
if Spawn_dropper4 is True:
screen.blit(dropper4, (400, 390))
screen.blit(dropper4_block, dropperblock4_rect)
dropperblock4_rect.x += 2
Buy_block4_rect.x = 500
screen.blit(Buy_block4, Buy_block4_rect)
screen.blit(Buy4_cost_text, Buy4_cost_text_rect)
def spawn_dropper5():
if Spawn_dropper5 is True:
screen.blit(dropper5, (500, 390))
screen.blit(dropper5_block, dropperblock5_rect)
dropperblock5_rect.x += 2
Buy_block5_rect.x = 600
screen.blit(Buy_block5, Buy_block5_rect)
screen.blit(Buy5_cost_text, Buy5_cost_text_rect)
def spawn_dropper6():
if Spawn_dropper6 is True:
screen.blit(dropper6, (600, 390))
screen.blit(dropper6_block, dropperblock6_rect)
dropperblock6_rect.x += 1
Buy_block6_rect.x = 160
screen.blit(Buy_block6, Buy_block6_rect)
screen.blit(Buy6_cost_text, Buy6_cost_text_rect)
def spawn_dropper7():
if Spawn_dropper7 is True:
screen.blit(dropper7, (160, 500))
screen.blit(dropper7_block, dropperblock7_rect)
dropperblock7_rect.x += 2
Buy_block7_rect.x = 260
screen.blit(Buy_block7, Buy_block7_rect)
screen.blit(Buy7_cost_text, Buy7_cost_text_rect)
def spawn_dropper8():
if Spawn_dropper8 is True:
screen.blit(dropper8, (260, 500))
screen.blit(dropper8_block, dropperblock8_rect)
dropperblock8_rect.x += 2
Buy_block8_rect.x = 360
screen.blit(Buy_block8, Buy_block8_rect)
screen.blit(Buy8_cost_text, Buy8_cost_text_rect)
screen.blit(Buy_conveyor2_text, Buy_conveyor2_text_rect)
screen.blit(Buy_conveyor2_block, Buy_conveyor2_block_rect)
def spawn_dropper9():
if Spawn_dropper9 is True:
screen.blit(dropper9, (360, 500))
screen.blit(dropper9_block, dropperblock9_rect)
dropperblock9_rect.x += 2
Buy_block9_rect.x = 460
screen.blit(Buy_block9, Buy_block9_rect)
screen.blit(Buy9_cost_text, Buy9_cost_text_rect)
def spawn_dropper10():
if Spawn_dropper10 is True:
screen.blit(dropper10, (460, 500))
screen.blit(dropper10_block, dropperblock10_rect)
dropperblock10_rect.x += 2
Buy_block10_rect.x = 560
screen.blit(Buy_block10, Buy_block10_rect)
screen.blit(Buy10_cost_text, Buy10_cost_text_rect)
def spawn_dropper11():
if Spawn_dropper11 is True:
screen.blit(dropper11, (560, 500))
screen.blit(dropper11_block, dropperblock11_rect)
dropperblock11_rect.x += 2
Buy_block11_rect.x = 40
screen.blit(Buy_block11, Buy_block11_rect)
screen.blit(Buy11_cost_text, Buy11_cost_text_rect)
def spawn_dropper_rainbow():
if Spawn_dropper12 is True:
screen.blit(dropper12, (40, 450))
screen.blit(Rainbow_block_red, (15, 450))
screen.blit(Rainbow_block_blue, (35, 450))
screen.blit(Rainbow_block_yellow, (50, 450))
screen.blit(Rainbow_block_purple, (65, 450))
screen.blit(Rainbow_block_green, (80, 450))
screen.blit(dropper12_block, dropperblock12_rect)
dropperblock12_rect.x += 2
Starting_screen = True
Main_tycoon_screen = False
Setting_On = False
Setting_Off = True
Music = True
def setting_stuff():
global Setting_On, Setting_Off, Music, Tycoon_music1, Starting_screen_music, mouse_pressed
screen.blit(Setting_button, Setting_button_rect)
screen.blit(setting_button_icon, setting_button_icon_rect)
mouse_pressed = pygame.mouse.get_pressed()
if (mouse_pressed[0]) and mouse_rect.colliderect(Setting_button_rect):
Setting_Off = False
Setting_On = True
if Setting_On is True:
Setting_Background_rect.x = 200
exit_setting_button_rect.x = 470
screen.blit(Setting_Background, Setting_Background_rect)
screen.blit(exit_setting_button, exit_setting_button_rect)
setting_button_icon_rect.x = 999
Setting_button_rect.x = 999
pause_music_block_rect.x = 250
pause_music_text_rect.x = 260
screen.blit(pause_music_block, pause_music_block_rect)
screen.blit(pause_music_text, pause_music_text_rect)
unpause_music_block_rect.x = 250
unpause_music_text_rect.x = 260
screen.blit(unpause_music_block, unpause_music_block_rect)
screen.blit(unpause_music_text, unpause_music_text_rect)
if (mouse_pressed[0]) and mouse_rect.colliderect(exit_setting_button_rect):
Setting_On = False
Setting_Off = True
if (mouse_pressed[0]) and mouse_rect.colliderect(pause_music_block_rect):
Music = False
if (mouse_pressed[0]) and mouse_rect.colliderect(unpause_music_block_rect):
Music = True
if Music is False:
pygame.mixer.music.pause()
if Music is True:
pygame.mixer.music.unpause()
if Setting_Off is True:
pause_music_block_rect. x = 999
pause_music_text_rect.x = 999
unpause_music_block_rect.x = 999
unpause_music_text_rect.x = 999
Setting_Background_rect.x = 999
exit_setting_button_rect.x = 999
setting_button_icon_rect.x = 50
Setting_button_rect.x = 50
当我时发生错误的 函数在游戏中按下按钮有时会发生有时不会,我不知道如何解决它
I've been getting a weird bug were my game crashes randomly with exit code -805306369 (0xCFFFFFFF) in PyCharm
and I think the error is somewhere in my while loop but idk where
While loop:
while True:
clock.tick(FPS)
# Start screen
if Starting_screen is True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
screen.fill((101, 67, 33))
screen.blit(Start_game_box, Start_game_box_rect)
screen.blit(Play_game_text, Play_game_text_rect)
screen.blit(Game_name_text, Game_name_text_rect)
screen.blit(Pepsi_credits_text, Pepsi_credits_text_rect)
screen.blit(Brew_credits_text, Brew_credits_text_rect)
screen.blit(Q_credits_text, Q_credits_text_rect)
screen.blit(mouse, mouse_rect)
mouse_pos = pygame.mouse.get_pos()
if pygame.MOUSEMOTION:
mx, my = mouse_pos
mouse_rect.x = mx
mouse_rect.y = my
mouse_pressed = pygame.mouse.get_pressed()
if (mouse_pressed[0]) and mouse_rect.colliderect(Start_game_box_rect):
Main_tycoon_screen = True
Play_game_text_rect.x = 9999
Game_name_text_rect.x = 9999
Start_game_box_rect.x = 9999
print(Main_tycoon_screen)
Starting_screen = False
print(Starting_screen)
pygame.display.update()
if Main_tycoon_screen is True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
screen.fill((101, 67, 33))
screen.blit(dropper1, (100, 400))
screen.blit(conveyor1, (100, 450))
screen.blit(dropper1_block, dropperblock1_rect)
screen.blit(sell_block1, sell_block1_rect)
screen.blit(Buy_block1, Buy_block1_rect)
screen.blit(Buy1_cost_text, Buy1_cost_text_rect)
# functions
spawn_dropper2()
spawn_dropper3()
spawn_dropper4()
spawn_dropper5()
spawn_dropper6()
spawn_dropper7()
spawn_dropper8()
spawn_dropper9()
spawn_dropper10()
spawn_dropper11()
spawn_dropper_rainbow()
spawn_conveyor2()
setting_stuff()
dropperblock1_rect.x += 2
mouse_pos = pygame.mouse.get_pos()
if pygame.MOUSEMOTION:
mx, my = mouse_pos
mouse_rect.x = mx
mouse_rect.y = my
screen.blit(mouse, mouse_rect)
# sell block collisions
if dropperblock12_rect.colliderect(sell_block1_rect):
monet += 500
dropperblock12_rect.x = 70
print(monet)
if dropperblock11_rect.colliderect(sell_block1_rect):
monet += 100
dropperblock11_rect.x = 560
print(monet)
if dropperblock10_rect.colliderect(sell_block1_rect):
monet += 70
dropperblock10_rect.x = 460
print(monet)
if dropperblock9_rect.colliderect(sell_block1_rect):
monet += 50
dropperblock9_rect.x = 360
print(monet)
if dropperblock8_rect.colliderect(sell_block1_rect):
monet += 30
dropperblock8_rect.x = 260
print(monet)
if dropperblock7_rect.colliderect(sell_block1_rect):
monet += 20
dropperblock7_rect.x = 160
print(monet)
if dropperblock6_rect.colliderect(sell_block1_rect):
monet += 15
dropperblock6_rect.x = 600
print(monet)
if dropperblock5_rect.colliderect(sell_block1_rect):
monet += 15
dropperblock5_rect.x = 500
print(monet)
if dropperblock4_rect.colliderect(sell_block1_rect):
monet += 10
dropperblock4_rect.x = 400
print(monet)
if dropperblock3_rect.colliderect(sell_block1_rect):
monet += 8
dropperblock3_rect.x = 300
print(monet)
if dropperblock2_rect.colliderect(sell_block1_rect):
monet += 6
dropperblock2_rect.x = 200
print(monet)
if dropperblock1_rect.colliderect(sell_block1_rect):
monet += 5
dropperblock1_rect.x = 100
print(monet)
# Buy block collisions
mouse_pressed = pygame.mouse.get_pressed()
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block1_rect) and monet >= 10:
monet -= 10
Buy_block1_rect.x = 999
Buy_block1_rect.y = 999
Spawn_dropper2 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block2_rect) and monet >= 30:
monet -= 30
Buy_block2_rect.x = 999
Buy_block2_rect.y = 999
Buy2_cost_text_rect.x = 999
Spawn_dropper3 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block3_rect) and monet >= 100:
monet -= 100
Buy_block3_rect.x = 999
Buy_block3_rect.y = 999
Buy3_cost_text_rect.x = 999
Spawn_dropper4 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block4_rect) and monet >= 200:
monet -= 200
Buy_block4_rect.x = 999
Buy_block4_rect.y = 999
Buy4_cost_text_rect.x = 999
Spawn_dropper5 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block5_rect) and monet >= 500:
monet -= 500
Buy_block5_rect.x = 999
Buy_block5_rect.y = 999
Buy5_cost_text_rect.x = 999
Spawn_dropper6 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block6_rect) and monet >= 1000:
monet -= 1000
Buy_block6_rect.x = 999
Buy_block6_rect.y = 999
Buy6_cost_text_rect.x = 999
Spawn_dropper7 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block7_rect) and monet >= 1500:
monet -= 1500
Buy_block7_rect.x = 999
Buy_block7_rect.y = 999
Buy7_cost_text_rect.x = 999
Spawn_dropper8 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block8_rect) and monet >= 2000:
monet -= 2000
Buy_block8_rect.x = 999
Buy_block8_rect.y = 999
Buy8_cost_text_rect.x = 999
Spawn_dropper9 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block9_rect) and monet >= 3000:
monet -= 3000
Buy_block9_rect.x = 999
Buy_block9_rect.y = 999
Buy9_cost_text_rect.x = 999
Spawn_dropper10 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block10_rect) and monet >= 4000:
monet -= 4000
Buy_block10_rect.x = 999
Buy_block10_rect.y = 999
Buy10_cost_text_rect.x = 999
Spawn_dropper11 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_block11_rect) and monet >= 5000:
monet -= 5000
Buy_block11_rect.x = 999
Buy_block11_rect.y = 999
Buy11_cost_text_rect.x = 999
Spawn_dropper12 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
if (mouse_pressed[0]) and mouse_rect.colliderect(Buy_conveyor2_block_rect) and monet >= 10000:
monet -= 10000
Buy_conveyor2_block_rect.x = 999
Buy_conveyor2_text_rect.x = 999
Spawn_conveyor2 = True
print(monet)
pygame.mixer.Sound.play(Buying_dropper_sound)
draw_monet_counter(f"monet: {monet}", "white", 60, 600, 50)
pygame.display.update()
and here are the funcitons
Spawn_conveyor2 = False
Spawn_dropper2 = False
Spawn_dropper3 = False
Spawn_dropper4 = False
Spawn_dropper5 = False
Spawn_dropper6 = False
Spawn_dropper7 = False
Spawn_dropper8 = False
Spawn_dropper9 = False
Spawn_dropper10 = False
Spawn_dropper11 = False
Spawn_dropper12 = False
Spawn_pho_dropper1 = False
def spawn_conveyor2():
if Spawn_conveyor2 is True:
screen.blit(conveyor2, (100, 200))
Buy_conveyor2_block_rect.x = 999
Buy_conveyor2_text_rect.x = 9999
Buy_pho1_rect.x = 110
screen.blit(Buy_pho1, Buy_pho1_rect)
def spawn_dropper2():
if Spawn_dropper2 is True:
Buy_block1_rect.x = 2400
screen.blit(Buy2_cost_text, Buy2_cost_text_rect)
screen.blit(dropper2, (200, 390))
screen.blit(dropper2_block, dropperblock2_rect)
Buy_block2_rect.x = 300
screen.blit(Buy_block2, Buy_block2_rect)
dropperblock2_rect.x += 2
Buy1_cost_text_rect.x = 999
def spawn_dropper3():
if Spawn_dropper3 is True:
screen.blit(dropper3, (300, 390))
screen.blit(dropper3_block, dropperblock3_rect)
dropperblock3_rect.x += 2
Buy_block3_rect.x = 400
screen.blit(Buy_block3, Buy_block3_rect)
screen.blit(Buy3_cost_text, Buy3_cost_text_rect)
def spawn_dropper4():
if Spawn_dropper4 is True:
screen.blit(dropper4, (400, 390))
screen.blit(dropper4_block, dropperblock4_rect)
dropperblock4_rect.x += 2
Buy_block4_rect.x = 500
screen.blit(Buy_block4, Buy_block4_rect)
screen.blit(Buy4_cost_text, Buy4_cost_text_rect)
def spawn_dropper5():
if Spawn_dropper5 is True:
screen.blit(dropper5, (500, 390))
screen.blit(dropper5_block, dropperblock5_rect)
dropperblock5_rect.x += 2
Buy_block5_rect.x = 600
screen.blit(Buy_block5, Buy_block5_rect)
screen.blit(Buy5_cost_text, Buy5_cost_text_rect)
def spawn_dropper6():
if Spawn_dropper6 is True:
screen.blit(dropper6, (600, 390))
screen.blit(dropper6_block, dropperblock6_rect)
dropperblock6_rect.x += 1
Buy_block6_rect.x = 160
screen.blit(Buy_block6, Buy_block6_rect)
screen.blit(Buy6_cost_text, Buy6_cost_text_rect)
def spawn_dropper7():
if Spawn_dropper7 is True:
screen.blit(dropper7, (160, 500))
screen.blit(dropper7_block, dropperblock7_rect)
dropperblock7_rect.x += 2
Buy_block7_rect.x = 260
screen.blit(Buy_block7, Buy_block7_rect)
screen.blit(Buy7_cost_text, Buy7_cost_text_rect)
def spawn_dropper8():
if Spawn_dropper8 is True:
screen.blit(dropper8, (260, 500))
screen.blit(dropper8_block, dropperblock8_rect)
dropperblock8_rect.x += 2
Buy_block8_rect.x = 360
screen.blit(Buy_block8, Buy_block8_rect)
screen.blit(Buy8_cost_text, Buy8_cost_text_rect)
screen.blit(Buy_conveyor2_text, Buy_conveyor2_text_rect)
screen.blit(Buy_conveyor2_block, Buy_conveyor2_block_rect)
def spawn_dropper9():
if Spawn_dropper9 is True:
screen.blit(dropper9, (360, 500))
screen.blit(dropper9_block, dropperblock9_rect)
dropperblock9_rect.x += 2
Buy_block9_rect.x = 460
screen.blit(Buy_block9, Buy_block9_rect)
screen.blit(Buy9_cost_text, Buy9_cost_text_rect)
def spawn_dropper10():
if Spawn_dropper10 is True:
screen.blit(dropper10, (460, 500))
screen.blit(dropper10_block, dropperblock10_rect)
dropperblock10_rect.x += 2
Buy_block10_rect.x = 560
screen.blit(Buy_block10, Buy_block10_rect)
screen.blit(Buy10_cost_text, Buy10_cost_text_rect)
def spawn_dropper11():
if Spawn_dropper11 is True:
screen.blit(dropper11, (560, 500))
screen.blit(dropper11_block, dropperblock11_rect)
dropperblock11_rect.x += 2
Buy_block11_rect.x = 40
screen.blit(Buy_block11, Buy_block11_rect)
screen.blit(Buy11_cost_text, Buy11_cost_text_rect)
def spawn_dropper_rainbow():
if Spawn_dropper12 is True:
screen.blit(dropper12, (40, 450))
screen.blit(Rainbow_block_red, (15, 450))
screen.blit(Rainbow_block_blue, (35, 450))
screen.blit(Rainbow_block_yellow, (50, 450))
screen.blit(Rainbow_block_purple, (65, 450))
screen.blit(Rainbow_block_green, (80, 450))
screen.blit(dropper12_block, dropperblock12_rect)
dropperblock12_rect.x += 2
Starting_screen = True
Main_tycoon_screen = False
Setting_On = False
Setting_Off = True
Music = True
def setting_stuff():
global Setting_On, Setting_Off, Music, Tycoon_music1, Starting_screen_music, mouse_pressed
screen.blit(Setting_button, Setting_button_rect)
screen.blit(setting_button_icon, setting_button_icon_rect)
mouse_pressed = pygame.mouse.get_pressed()
if (mouse_pressed[0]) and mouse_rect.colliderect(Setting_button_rect):
Setting_Off = False
Setting_On = True
if Setting_On is True:
Setting_Background_rect.x = 200
exit_setting_button_rect.x = 470
screen.blit(Setting_Background, Setting_Background_rect)
screen.blit(exit_setting_button, exit_setting_button_rect)
setting_button_icon_rect.x = 999
Setting_button_rect.x = 999
pause_music_block_rect.x = 250
pause_music_text_rect.x = 260
screen.blit(pause_music_block, pause_music_block_rect)
screen.blit(pause_music_text, pause_music_text_rect)
unpause_music_block_rect.x = 250
unpause_music_text_rect.x = 260
screen.blit(unpause_music_block, unpause_music_block_rect)
screen.blit(unpause_music_text, unpause_music_text_rect)
if (mouse_pressed[0]) and mouse_rect.colliderect(exit_setting_button_rect):
Setting_On = False
Setting_Off = True
if (mouse_pressed[0]) and mouse_rect.colliderect(pause_music_block_rect):
Music = False
if (mouse_pressed[0]) and mouse_rect.colliderect(unpause_music_block_rect):
Music = True
if Music is False:
pygame.mixer.music.pause()
if Music is True:
pygame.mixer.music.unpause()
if Setting_Off is True:
pause_music_block_rect. x = 999
pause_music_text_rect.x = 999
unpause_music_block_rect.x = 999
unpause_music_text_rect.x = 999
Setting_Background_rect.x = 999
exit_setting_button_rect.x = 999
setting_button_icon_rect.x = 50
Setting_button_rect.x = 50
the error happens when i hit a button in the game sometimes it happens and sometimes not and i dont know how to fix it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很可能您的变量
Starting_screen
和Main_tycoon_screen
都变成了False
。如果这两个条件都为 false,则您将不再处理窗口事件队列。操作系统注意到您的应用程序不再处理事件(即“未响应”),并采取终止它的操作。这会产生 0xCFFFFFFF 代码。我建议您修改程序以在单个位置处理窗口事件,并始终处理事件队列。
该框架允许您通过设置 current_screen 变量在应用程序的“状态”之间切换。但关键是,无论
current_screen
是什么,始终处理事件队列。It's likely that somehow both your variables
Starting_screen
andMain_tycoon_screen
are becomingFalse
. With both of these false, you are no longer handling the window event queue. The operating system notices your application is no longer processing events (i.e. "Not Responding"), and takes the action of terminating it. This results in the 0xCFFFFFFF code.I suggest you modify your program to process the window events in a single place, and always process the event queue.
This framework allows you to switch between the "state" of the application by setting the
current_screen
variable. But the key point is that is always handling the event queue, no matter what thecurrent_screen
.