def main():
#figure out our directories
global DATADIR, CODEDIR
# first try to get the path from the solarwolf package.
try:
import solarwolf
if type(solarwolf.__path__) == list:
localpath = os.path.abspath(solarwolf.__path__[0])
else:
localpath = os.path.abspath(solarwolf.__path__._path[0])
except ImportError:
localpath = os.path.split(os.path.abspath(sys.argv[0]))[0]
testdata = localpath
testcode = os.path.join(localpath, '.')
if os.path.isdir(os.path.join(testdata, 'data')):
DATADIR = testdata
if os.path.isdir(testcode):
CODEDIR = testcode
#apply our directories and test environment
os.chdir(DATADIR)
sys.path.insert(0, CODEDIR)
checkdependencies()
#install pychecker if debugging
try:
import game
if game.DEBUG >= 2:
import pychecker.checker
print('Pychecker Enabled')
except ImportError:
pass
#run game and protect from exceptions
try:
import main, pygame
main.main(sys.argv)
except KeyboardInterrupt:
print('Keyboard Interrupt (Control-C)...')
except:
#must wait on any threading
if game.thread:
game.threadstop = 1
while game.thread:
pygame.time.wait(10)
print('waiting on thread...')
exception_handler()
if game.DEBUG:
raise
评论列表
文章目录