【发布时间】:2022-09-23 12:12:56
【问题描述】:
我正在为我的游戏使用 ursina 模块。当我尝试运行我用 auto-py-to-exe 制作的 exe 文件时,它给了我这个错误:
failed to execute script \'main\' due to unhandled
exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda
display library via load-display or aux-diplay.
Traceback (most recent call last):
File \"main.py\", line 5, in <module>
File \"ursina\\main.py\", line 28, in __init__
File \"direct\\showbase\\ShowBase.py\", line 339, in __init__
File \"direct\\showbase\\ShowBase.py\", line 1024, in
openDefaultWindow
File \"direct\\showbase\\ShowBase.py\", line 1059, in
openMainWindow
File \"direct\\showbase\\ShowBase.py\", line 769, in
openWindow
File \"direct\\showbase\\ShowBase.py\", line 749, in <lambda>
File \"direct\\showbase\\ShowBase.py\", line 821, in
_doOpenWindow
File \"direct\\showbase\\ShowBase.py\", line 650, in
makeDefaultPipe
File \"direct\\directnotify\\Notifier.py\", line 130, in
error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda
display
library via load-display or aux-display.
from ursina import *
import random
from playsound import playsound
app = Ursina()
music = Audio(\'audio/Game_music.wav\', loop=True)
quantity = Entity(color=color.clear,position=(0,0,-30))
points=Entity(color=color.clear,position=(0,0,-30))
high= Entity(color=color.clear, position=(0, 0, -30))
score_text = int(points.x)
score_text2 = str(score_text)
score = Text(text=score_text2, scale=5,position=
(-0.6,0.35,-18), color=color.black)
score_top = Text(text=\"score:\", scale=3,position=
(-0.65,0.45,-18), color=color.black); highscore_text =
int(high.x)
highscore_text2 = str(highscore_text)
highscore = Text(text=highscore_text2, scale=5,
position=
(0.6, 0.35, -18), color=color.black)
highscore_top = Text(text=\"high score:\",
scale=3,position=
(0.45,0.45,-18), color=color.black)
respawn_texture = Entity(model=\'quad\',scale=
(0.3,0.1),position=
(0,0,5),texture=load_texture(\'textures/Play_again\'))
#menu_texture = Entity(model=\'quad\',scale=
(0.3,0.1),position=
(0,-0.1,5),texture=load_texture(\'textures/Main_menu\'))
while quantity.x < 0:
quantity.x = 0
class background(Button):
def __init__(self):
super().__init__(
model = \'cube\',
parent=scene,
color=color.white,
position=(0,0,4.5),
scale = (30,30,2))
def input(self, key):
if self.hovered:
if key == \'left mouse down\':
playsound(\"audio/screeching.m4a\", block=False)
camera.z = 4
points.x = 0
class Tile(Button):
def __init__(self):
quantity.x +=1
placement = random.randint(-4, 4)
potential_color_list=(color.red,color.blac)
super().__init__(
model = \'quad\',
parent=scene,
color= random.choice(potential_color_list),
position=(placement,quantity.x * 2 + 3,3),
scale =
(random.uniform(0.1,3),random.uniform(0.5,3))),
def input(self,key):
if self.hovered:
if key == \'left mouse down\':
if self.color == color.black:
playsound(\"audio/scored.m4a\", block=False)
destroy(self)
quantity.x -=1
amount = random.randint(1,3)
multiplier_calculations = points.x / 10 + 1
Multiplier = int(multiplier_calculations)
points.x += Multiplier
score.Text = points.x
score_text = int(points.x)
score_text2 = str(score_text)
score.text = score_text2
if quantity.x <= 0:
if amount == 1:
Tile()
if amount == 2:
Tile()
Tile()
if amount == 3:
Tile()
Tile()
Tile()
if self.color == color.red:
playsound(\"audio/screeching.m4a\",
block=False)
camera.z = 4
if high.x < points.x:
high.x = points.x
highscore_text = int(high.x)
highscore_text2 = str(highscore_text)
highscore.text = highscore_text2
score.Text=points.x
if camera.z == 4:
destroy(self)
def update(self):
speed = points.x / 40 + 3
if camera.z == -20 and points.x != 0:
self.y -= speed * time.dt
else:
self.position=(0,4,3)
self.color = color.black
if self.y <= -6.5:
if self.color == color.black:
playsound(\"audio/screeching.m4a\", block=False)
camera.z = 4
destroy(self)
if self.color == color.red:
destroy(self)
quantity.x -= 1
if quantity <= 0:
amount = random.randint(1,3)
if amount == 1:
Tile()
if amount == 2:
Tile()
Tile()
if amount == 3:
Tile()
Tile()
Tile()
if camera.z == 4:
score.text = \'0\'
destroy(self)
Tile()
quantity.x = 0
#class menu(Button):
# def __init__(self):
# super().__init__(
# model = \'quad\',
# color=color.clear,
# parent=scene,
# position=(0,-0.05,5),
# scale = (0.09,0.03))
# def input(self, key):
# if self.hovered:
# if key == \'left mouse down\':
# playsound(\"audio/bounce.m4a\", block=False)
# points.x = 0
# quantity.x = 0
# camera.z = 8
class play_again(Button):
def __init__(self):
super().__init__(
model = \'quad\',
color=color.clear,
parent=scene,
position=(0,0,4.8),
scale = (0.09,0.03))
def input(self, key):
if self.hovered:
if key == \'left mouse down\':
playsound(\"audio/bounce.m4a\", block=False)
points.x = 0
quantity.x = 0
camera.z = -20
Tile()
play_again()
background()
Tile()
app.run()
标签: python python-3.x ursina auto-py-to-exe