Не открывается exe файл, сконвертированный Cx_freeze
22.07.2019, 12:24. Показов 2122. Ответов 3
Написал игру используя pygame и переконвертировал в exe. При открытии exe выдаёт ошибку:
Прекращена работа программы
Сигнатура проблемы:
Имя события проблемы: APPCRASH
Имя приложения: GAME.exe
Версия приложения: 0.0.0.0
Отметка времени приложения: 549dea3c
Имя модуля с ошибкой: MSVCR100.dll
Версия модуля с ошибкой: 10.0.40219.325
Отметка времени модуля с ошибкой: 4df2be1e
Код исключения: 40000015
Смещение исключения: 0008d6fd
Версия ОС: 6.1.7601.2.1.0.768.3
Код языка: 1049
Дополнительные сведения 1: 03f9
Дополнительные сведения 2: 03f97f0a6bd2408168aa06a668613242
Дополнительные сведения 3: d9f3
Дополнительные сведения 4: d9f33fd3d887f44dc967cf625d8697fe
Код GAME.py: | Python | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
| from random import randrange
from random import choice
import os, pygame, sys
from pygame.locals import *
# Initialize screen
pygame.init()
def game():
win = pygame.display.set_mode((500, 500))
global fruitX, fruitY, fruit,fruits
walkRight = pygame.image.load("data/Chuck_right.png")
walkLeft = pygame.image.load("data/Chuck_left.png")
bg = pygame.image.load("data/background.jpg")
banana = pygame.image.load("data/banan.png")
apple = pygame.image.load("data/apple.png")
orange = pygame.image.load("data/orange.png")
cherry = pygame.image.load("data/cherry.png")
fruitSound = pygame.mixer.Sound(file='data/Fruit.wav')
loseSound = pygame.mixer.Sound(file='data/Lose.wav')
beginSound = pygame.mixer.Sound(file='data/begin.wav')
newRecordSound = pygame.mixer.Sound(file='data/new-record.wav')
fruits = [banana, apple, orange, cherry]
aqua = ( 0, 255, 255) # морская волна
black = ( 0, 0, 0) # черный
blue = ( 0, 0, 255) # синий
fuchsia = (255, 0, 255) # фуксия
gray = (128, 128, 128) # серый
green = ( 0, 128, 0) # зеленый
lime = ( 0, 255, 0) # цвет лайма
maroon = (128, 0, 0) # темно-бордовый
navy_blue = ( 0, 0, 128) # темно-синий
olive = (128, 128, 0) # оливковый
purple = (128, 0, 128) # фиолетовый
red = (255, 0, 0) # красный
silver = (192, 192, 192) # серебряный
teal = ( 0, 128, 128) # зелено-голубой
white = (255, 255, 255) # белый
yellow = (255, 255, 0) # желтый
font = pygame.font.Font(None, 25)
gameOverFont = pygame.font.Font(None, 65)
x = 60
y = 425
width = 60
height = 60
speed = 4
fruitX = 0
fruitY = 0
fruitWidth = 60
fruitHeight = 60
fruitCount = 0
fileRecord = open('data/record.dat', 'r')
record = int(fileRecord.read())
fileRecord.close()
def moveFruit():
global fruitX, fruitY, fruit,fruits
fruit = choice(fruits)
pastFruitX = fruitX
pastFruitY = fruitY
fruitX = randrange(5,500 - fruitWidth - 5)
fruitY = randrange(500 - fruitHeight - 120, 333)
if pastFruitX > fruitX:
if pastFruitX - fruitX < 100:
moveFruit()
else:
if fruitX - pastFruitX < 100:
moveFruit()
isJump = False
jumpCount = 10
newRecordplay = False
newRecord = False
left = False
right = False
showFruit = True
run = True
time = 12
win.blit(bg, (0,0))
pygame.display.update()
pygame.time.delay(1500)
beginSound.play()
gameOverText = gameOverFont.render("На старт!", True, red)
win.blit(gameOverText, (140,180))
pygame.display.update()
pygame.time.delay(1500)
gameOverText = gameOverFont.render("Внимание!", True, red)
win.blit(gameOverText, (120,230))
pygame.display.update()
pygame.time.delay(1500)
gameOverText = gameOverFont.render("Марш!", True, red)
win.blit(gameOverText, (165,280))
pygame.display.update()
pygame.time.delay(1500)
moveFruit()
while run:
pygame.time.delay(20)
time-=0.05
recordText = font.render("Рекорд: {0}".format(record), True, black)
text = font.render("Счет: {0}".format(fruitCount), True, black)
timetext = font.render("Время: {0}".format(int(time)), True, black)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and x > 5:
x-= speed
left = True
right = False
if keys[pygame.K_RIGHT] and x < 500 - width - 5:
x+= speed
left = False
right = True
if not(isJump):
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
if jumpCount < 0:
y += (jumpCount ** 2) / 2
else:
y -= (jumpCount ** 2) / 2
jumpCount -= 1
else:
isJump = False
jumpCount = 10
win.blit(bg, (0,0))
win.blit(text, (0,0))
win.blit(timetext, (0,30))
win.blit(recordText, (0,60))
if showFruit:
win.blit(fruit, (fruitX, fruitY))
if ((x - fruitX)<= 60 and (fruitX - x) <= 60) and ((y - fruitY)<= 60 and (fruitY - y) <= 60):
fruitSound.play()
fruitCount += 1
time += 2
moveFruit()
if left:
win.blit(walkLeft, (x,y))
elif right:
win.blit(walkRight, (x,y))
else:
win.blit(walkRight, (x,y))
if time <= 0:
break
if fruitCount > record:
newRecord = True
if newRecord == True and newRecordplay == False:
newRecordSound.play()
newRecordplay = True
pygame.display.update()
loseSound.play()
if newRecord:
fileRecord = open('data/record.dat','w')
fileRecord.write(str(fruitCount))
fileRecord.close()
gameOverFont = pygame.font.Font(None, 42)
gameOverText = gameOverFont.render("Вы проиграли. Новый рекорд - {}".format(fruitCount), True, red)
win.blit(gameOverText, (5, 200))
pygame.display.update()
else:
gameOverText = gameOverFont.render("Вы проиграли", True, red)
win.blit(gameOverText, (95, 200))
pygame.display.update()
pygame.time.delay(4000)
menu()
def menu():
banana = pygame.image.load("data/banan.png")
apple = pygame.image.load("data/apple.png")
orange = pygame.image.load("data/orange.png")
cherry = pygame.image.load("data/cherry.png")
DISPLAYSURF = pygame.display.set_mode((800, 600))
pygame.display.set_caption('Angry Birds Fruits 1.0')
size = DISPLAYSURF.get_size()
width = size[0]
height = size[1]
title = pygame.Rect(((width/16)+1, (height/8)+1, 7*width/8, height/4))
menu1 = pygame.Rect(((width/4)+1, (height/2)+1, 2*width/4, height/10))
menu2 = pygame.Rect(((width/4)+1, (height/2)+1+(3*height/20), 2*width/4, height/10))
menu3 = pygame.Rect(((width/4)+1, (height/2)+1+(6*height/20), 2*width/4, height/10))
#Draws dark blue rectangles.
pygame.draw.rect(DISPLAYSURF, (0,0,150), menu1)
pygame.draw.rect(DISPLAYSURF, (0,0,150), menu2)
pygame.draw.rect(DISPLAYSURF, (0,0,150), menu3)
#Draws blue ovals on top of the rectangles.
pygame.draw.ellipse(DISPLAYSURF, (0,0,150), title)
pygame.draw.ellipse(DISPLAYSURF, (0,0,255), menu1)
pygame.draw.ellipse(DISPLAYSURF, (0,0,255), menu2)
pygame.draw.ellipse(DISPLAYSURF, (0,0,255), menu3)
#pygame.font.Font takes in a font name and an integer for its size.
#Free Sans Bold comes with Pygame (Sweigart 2012 p. 30).
font_title = pygame.font.Font(None, 64)
font_menu = pygame.font.Font(None, 32)
font_mini = pygame.font.Font(None, 25)
#Creates and draws the text.
surface_title = font_title.render('Angry Birds Fruits', True, (0,255,0))
rect_title = surface_title.get_rect() #get_rect() is my favorite Pygame function.
rect_title.center = (width/2,(height/4)+3)
surface_new_game = font_menu.render('ИГРАТЬ', True, (255,0,0))
rect_new_game = surface_new_game.get_rect()
rect_new_game.center = (width/2,(height/2)+(height/20)+3)
surface_load_game = font_menu.render('СКОРО', True, (0,0,0))
rect_load_game = surface_load_game.get_rect()
rect_load_game.center = (width/2,(height/2)+(4*height/20)+3)
surface_exit = font_menu.render('ВЫХОД', True, (0,0,0))
rect_exit = surface_exit.get_rect()
rect_exit.center = (width/2,(height/2)+(7*height/20)+3)
bottom_text = font_mini.render('© АНАНЬЕВ НЕСТОРИАН. ANGRY BIRDS FRUITS 1.0', True, (255,255,255))
Menu = True
while Menu: #main game loop
DISPLAYSURF.blit(surface_title, rect_title)
DISPLAYSURF.blit(surface_new_game, rect_new_game)
DISPLAYSURF.blit(surface_load_game, rect_load_game)
DISPLAYSURF.blit(surface_exit, rect_exit)
DISPLAYSURF.blit(apple, (15,250))
DISPLAYSURF.blit(orange, (750,250))
DISPLAYSURF.blit(cherry, (380,15))
DISPLAYSURF.blit(banana, (380,250))
DISPLAYSURF.blit(bottom_text, (190,570))
for event in pygame.event.get():
if event.type == MOUSEBUTTONUP:
if event.button == 1:
if (menu1.left < event.pos[0] < menu1.right) and (menu1.top < event.pos[1] < menu1.bottom):
Menu = False
game()
if (menu2.left < event.pos[0] < menu2.right) and (menu2.top < event.pos[1] < menu2.bottom):
pass
if (menu3.left < event.pos[0] < menu3.right) and (menu3.top < event.pos[1] < menu3.bottom):
pygame.event.post(pygame.event.Event(QUIT)) #Exits the game
#When you mouse-over a button, the text turns green.
if event.type == MOUSEMOTION:
if (menu1.left < event.pos[0] < menu1.right) and (menu1.top < event.pos[1] < menu1.bottom):
surface_new_game = font_menu.render('ИГРАТЬ', True, (0,255,0))
else:
surface_new_game = font_menu.render('ИГРАТЬ', True, (0,0,0))
if (menu2.left < event.pos[0] < menu2.right) and (menu2.top < event.pos[1] < menu2.bottom):
surface_load_game = font_menu.render('СКОРО', True, (255,255,0))
else:
surface_load_game = font_menu.render('СКОРО', True, (0,0,0))
if (menu3.left < event.pos[0] < menu3.right) and (menu3.top < event.pos[1] < menu3.bottom):
surface_exit = font_menu.render('ВЫХОД', True, (255,0,0))
else:
surface_exit = font_menu.render('ВЫХОД', True, (0,0,0))
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
menu() |
|
Код setup.py:
| Python | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
| from random import randrange
from random import choice
import os, pygame, sys
from pygame.locals import *
# Initialize screen
pygame.init()
def game():
win = pygame.display.set_mode((500, 500))
global fruitX, fruitY, fruit,fruits
walkRight = pygame.image.load("data/Chuck_right.png")
walkLeft = pygame.image.load("data/Chuck_left.png")
bg = pygame.image.load("data/background.jpg")
banana = pygame.image.load("data/banan.png")
apple = pygame.image.load("data/apple.png")
orange = pygame.image.load("data/orange.png")
cherry = pygame.image.load("data/cherry.png")
fruitSound = pygame.mixer.Sound(file='data/Fruit.wav')
loseSound = pygame.mixer.Sound(file='data/Lose.wav')
beginSound = pygame.mixer.Sound(file='data/begin.wav')
newRecordSound = pygame.mixer.Sound(file='data/new-record.wav')
fruits = [banana, apple, orange, cherry]
aqua = ( 0, 255, 255) # морская волна
black = ( 0, 0, 0) # черный
blue = ( 0, 0, 255) # синий
fuchsia = (255, 0, 255) # фуксия
gray = (128, 128, 128) # серый
green = ( 0, 128, 0) # зеленый
lime = ( 0, 255, 0) # цвет лайма
maroon = (128, 0, 0) # темно-бордовый
navy_blue = ( 0, 0, 128) # темно-синий
olive = (128, 128, 0) # оливковый
purple = (128, 0, 128) # фиолетовый
red = (255, 0, 0) # красный
silver = (192, 192, 192) # серебряный
teal = ( 0, 128, 128) # зелено-голубой
white = (255, 255, 255) # белый
yellow = (255, 255, 0) # желтый
font = pygame.font.Font(None, 25)
gameOverFont = pygame.font.Font(None, 65)
x = 60
y = 425
width = 60
height = 60
speed = 4
fruitX = 0
fruitY = 0
fruitWidth = 60
fruitHeight = 60
fruitCount = 0
fileRecord = open('data/record.dat', 'r')
record = int(fileRecord.read())
fileRecord.close()
def moveFruit():
global fruitX, fruitY, fruit,fruits
fruit = choice(fruits)
pastFruitX = fruitX
pastFruitY = fruitY
fruitX = randrange(5,500 - fruitWidth - 5)
fruitY = randrange(500 - fruitHeight - 120, 333)
if pastFruitX > fruitX:
if pastFruitX - fruitX < 100:
moveFruit()
else:
if fruitX - pastFruitX < 100:
moveFruit()
isJump = False
jumpCount = 10
newRecordplay = False
newRecord = False
left = False
right = False
showFruit = True
run = True
time = 12
win.blit(bg, (0,0))
pygame.display.update()
pygame.time.delay(1500)
beginSound.play()
gameOverText = gameOverFont.render("На старт!", True, red)
win.blit(gameOverText, (140,180))
pygame.display.update()
pygame.time.delay(1500)
gameOverText = gameOverFont.render("Внимание!", True, red)
win.blit(gameOverText, (120,230))
pygame.display.update()
pygame.time.delay(1500)
gameOverText = gameOverFont.render("Марш!", True, red)
win.blit(gameOverText, (165,280))
pygame.display.update()
pygame.time.delay(1500)
moveFruit()
while run:
pygame.time.delay(20)
time-=0.05
recordText = font.render("Рекорд: {0}".format(record), True, black)
text = font.render("Счет: {0}".format(fruitCount), True, black)
timetext = font.render("Время: {0}".format(int(time)), True, black)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and x > 5:
x-= speed
left = True
right = False
if keys[pygame.K_RIGHT] and x < 500 - width - 5:
x+= speed
left = False
right = True
if not(isJump):
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
if jumpCount < 0:
y += (jumpCount ** 2) / 2
else:
y -= (jumpCount ** 2) / 2
jumpCount -= 1
else:
isJump = False
jumpCount = 10
win.blit(bg, (0,0))
win.blit(text, (0,0))
win.blit(timetext, (0,30))
win.blit(recordText, (0,60))
if showFruit:
win.blit(fruit, (fruitX, fruitY))
if ((x - fruitX)<= 60 and (fruitX - x) <= 60) and ((y - fruitY)<= 60 and (fruitY - y) <= 60):
fruitSound.play()
fruitCount += 1
time += 2
moveFruit()
if left:
win.blit(walkLeft, (x,y))
elif right:
win.blit(walkRight, (x,y))
else:
win.blit(walkRight, (x,y))
if time <= 0:
break
if fruitCount > record:
newRecord = True
if newRecord == True and newRecordplay == False:
newRecordSound.play()
newRecordplay = True
pygame.display.update()
loseSound.play()
if newRecord:
fileRecord = open('data/record.dat','w')
fileRecord.write(str(fruitCount))
fileRecord.close()
gameOverFont = pygame.font.Font(None, 42)
gameOverText = gameOverFont.render("Вы проиграли. Новый рекорд - {}".format(fruitCount), True, red)
win.blit(gameOverText, (5, 200))
pygame.display.update()
else:
gameOverText = gameOverFont.render("Вы проиграли", True, red)
win.blit(gameOverText, (95, 200))
pygame.display.update()
pygame.time.delay(4000)
menu()
def menu():
banana = pygame.image.load("data/banan.png")
apple = pygame.image.load("data/apple.png")
orange = pygame.image.load("data/orange.png")
cherry = pygame.image.load("data/cherry.png")
DISPLAYSURF = pygame.display.set_mode((800, 600))
pygame.display.set_caption('Angry Birds Fruits 1.0')
size = DISPLAYSURF.get_size()
width = size[0]
height = size[1]
title = pygame.Rect(((width/16)+1, (height/8)+1, 7*width/8, height/4))
menu1 = pygame.Rect(((width/4)+1, (height/2)+1, 2*width/4, height/10))
menu2 = pygame.Rect(((width/4)+1, (height/2)+1+(3*height/20), 2*width/4, height/10))
menu3 = pygame.Rect(((width/4)+1, (height/2)+1+(6*height/20), 2*width/4, height/10))
#Draws dark blue rectangles.
pygame.draw.rect(DISPLAYSURF, (0,0,150), menu1)
pygame.draw.rect(DISPLAYSURF, (0,0,150), menu2)
pygame.draw.rect(DISPLAYSURF, (0,0,150), menu3)
#Draws blue ovals on top of the rectangles.
pygame.draw.ellipse(DISPLAYSURF, (0,0,150), title)
pygame.draw.ellipse(DISPLAYSURF, (0,0,255), menu1)
pygame.draw.ellipse(DISPLAYSURF, (0,0,255), menu2)
pygame.draw.ellipse(DISPLAYSURF, (0,0,255), menu3)
#pygame.font.Font takes in a font name and an integer for its size.
#Free Sans Bold comes with Pygame (Sweigart 2012 p. 30).
font_title = pygame.font.Font(None, 64)
font_menu = pygame.font.Font(None, 32)
font_mini = pygame.font.Font(None, 25)
#Creates and draws the text.
surface_title = font_title.render('Angry Birds Fruits', True, (0,255,0))
rect_title = surface_title.get_rect() #get_rect() is my favorite Pygame function.
rect_title.center = (width/2,(height/4)+3)
surface_new_game = font_menu.render('ИГРАТЬ', True, (255,0,0))
rect_new_game = surface_new_game.get_rect()
rect_new_game.center = (width/2,(height/2)+(height/20)+3)
surface_load_game = font_menu.render('СКОРО', True, (0,0,0))
rect_load_game = surface_load_game.get_rect()
rect_load_game.center = (width/2,(height/2)+(4*height/20)+3)
surface_exit = font_menu.render('ВЫХОД', True, (0,0,0))
rect_exit = surface_exit.get_rect()
rect_exit.center = (width/2,(height/2)+(7*height/20)+3)
bottom_text = font_mini.render('© АНАНЬЕВ НЕСТОРИАН. ANGRY BIRDS FRUITS 1.0', True, (255,255,255))
Menu = True
while Menu: #main game loop
DISPLAYSURF.blit(surface_title, rect_title)
DISPLAYSURF.blit(surface_new_game, rect_new_game)
DISPLAYSURF.blit(surface_load_game, rect_load_game)
DISPLAYSURF.blit(surface_exit, rect_exit)
DISPLAYSURF.blit(apple, (15,250))
DISPLAYSURF.blit(orange, (750,250))
DISPLAYSURF.blit(cherry, (380,15))
DISPLAYSURF.blit(banana, (380,250))
DISPLAYSURF.blit(bottom_text, (190,570))
for event in pygame.event.get():
if event.type == MOUSEBUTTONUP:
if event.button == 1:
if (menu1.left < event.pos[0] < menu1.right) and (menu1.top < event.pos[1] < menu1.bottom):
Menu = False
game()
if (menu2.left < event.pos[0] < menu2.right) and (menu2.top < event.pos[1] < menu2.bottom):
pass
if (menu3.left < event.pos[0] < menu3.right) and (menu3.top < event.pos[1] < menu3.bottom):
pygame.event.post(pygame.event.Event(QUIT)) #Exits the game
#When you mouse-over a button, the text turns green.
if event.type == MOUSEMOTION:
if (menu1.left < event.pos[0] < menu1.right) and (menu1.top < event.pos[1] < menu1.bottom):
surface_new_game = font_menu.render('ИГРАТЬ', True, (0,255,0))
else:
surface_new_game = font_menu.render('ИГРАТЬ', True, (0,0,0))
if (menu2.left < event.pos[0] < menu2.right) and (menu2.top < event.pos[1] < menu2.bottom):
surface_load_game = font_menu.render('СКОРО', True, (255,255,0))
else:
surface_load_game = font_menu.render('СКОРО', True, (0,0,0))
if (menu3.left < event.pos[0] < menu3.right) and (menu3.top < event.pos[1] < menu3.bottom):
surface_exit = font_menu.render('ВЫХОД', True, (255,0,0))
else:
surface_exit = font_menu.render('ВЫХОД', True, (0,0,0))
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
menu() |
|
0
|