some little change
This commit is contained in:
parent
eaf968fc70
commit
c942132df5
@ -1,23 +1,11 @@
|
|||||||
'''
|
"""
|
||||||
writen by shenjackyuanjie
|
writen by shenjackyuanjie
|
||||||
mail: 3695888@qq.com
|
mail: 3695888@qq.com
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
import sys
|
|
||||||
from bin import main
|
from bin import main
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
def game():
|
|
||||||
# Python vision check
|
|
||||||
py_v_info = sys.version_info
|
|
||||||
py_v = str('%d.%d.%d' % (py_v_info[0], py_v_info[1], py_v_info[2]))
|
|
||||||
if py_v_info[0] == 2:
|
|
||||||
raise Exception('Difficult Rocket need python vision 3+')
|
|
||||||
# start games
|
|
||||||
game = main.Game()
|
game = main.Game()
|
||||||
game.start()
|
game.start()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
game()
|
|
||||||
|
@ -5,7 +5,6 @@ mail: 3695888@qq.com
|
|||||||
|
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
|
|
||||||
import re
|
|
||||||
import pyglet
|
import pyglet
|
||||||
import pyglet.app
|
import pyglet.app
|
||||||
from pyglet import image
|
from pyglet import image
|
||||||
@ -21,7 +20,7 @@ except (ModuleNotFoundError, ImportError, ImportWarning):
|
|||||||
import tools
|
import tools
|
||||||
|
|
||||||
|
|
||||||
class RenderThread(mp.Process, pyglet.window.Window):
|
class client(mp.Process, pyglet.window.Window):
|
||||||
|
|
||||||
def __init__(self, logger, dev_dic=None, dev_list=None, path=None, net_mode='local'):
|
def __init__(self, logger, dev_dic=None, dev_list=None, path=None, net_mode='local'):
|
||||||
'''
|
'''
|
||||||
@ -64,7 +63,7 @@ class RenderThread(mp.Process, pyglet.window.Window):
|
|||||||
# setup
|
# setup
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
def startGame(self):
|
def start_game(self):
|
||||||
pyglet.app.run()
|
pyglet.app.run()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
34
bin/main.py
34
bin/main.py
@ -26,10 +26,16 @@ class Game:
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# basic config
|
# basic config
|
||||||
|
self.on_python_v_info = sys.version_info
|
||||||
|
self.on_python_v = str('%d.%d.%d' % (self.on_python_v_info[0],
|
||||||
|
self.on_python_v_info[1],
|
||||||
|
self.on_python_v_info[2]))
|
||||||
self.start_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time()))
|
self.start_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time()))
|
||||||
|
|
||||||
# share memory
|
# share memory
|
||||||
self.dicts = share().dict()
|
self.dicts = share().dict()
|
||||||
self.lists = share().list()
|
self.lists = share().list()
|
||||||
|
|
||||||
# logger
|
# logger
|
||||||
self.log_config = tools.config('configs/logging.json5', 'file')
|
self.log_config = tools.config('configs/logging.json5', 'file')
|
||||||
self.log_filename = configs.name_handler(self.log_config['filename']['main'],
|
self.log_filename = configs.name_handler(self.log_config['filename']['main'],
|
||||||
@ -39,7 +45,7 @@ class Game:
|
|||||||
self.root_logger_stream_handler.setLevel(self.log_config['level'])
|
self.root_logger_stream_handler.setLevel(self.log_config['level'])
|
||||||
self.root_logger_stream_handler.setFormatter(self.root_logger_fmt)
|
self.root_logger_stream_handler.setFormatter(self.root_logger_fmt)
|
||||||
self.root_logger_stream_handler.setLevel(tools.log_level(self.log_config['level']))
|
self.root_logger_stream_handler.setLevel(tools.log_level(self.log_config['level']))
|
||||||
self.root_logger_file_handler = logging.FileHandler(self.log_filename)
|
self.root_logger_file_handler = logging.FileHandler('logs/' + self.log_filename)
|
||||||
self.root_logger_file_handler.setFormatter(self.root_logger_fmt)
|
self.root_logger_file_handler.setFormatter(self.root_logger_fmt)
|
||||||
self.root_logger_file_handler.setLevel(tools.log_level(self.log_config['level']))
|
self.root_logger_file_handler.setLevel(tools.log_level(self.log_config['level']))
|
||||||
# root logger setup
|
# root logger setup
|
||||||
@ -51,25 +57,23 @@ class Game:
|
|||||||
self.server_logger = logging.getLogger().getChild('server')
|
self.server_logger = logging.getLogger().getChild('server')
|
||||||
self.client_logger = logging.getLogger().getChild('client')
|
self.client_logger = logging.getLogger().getChild('client')
|
||||||
self.main_logger.info('client logger and server logger done')
|
self.main_logger.info('client logger and server logger done')
|
||||||
|
|
||||||
|
# version check
|
||||||
self.python_version_check()
|
self.python_version_check()
|
||||||
# client and server
|
# client and server
|
||||||
self.client = client.RenderThread(
|
self.client = client.client(self.client_logger, self.dicts, self.lists, net_mode='local')
|
||||||
self.client_logger, self.dicts, self.lists, net_mode='local')
|
self.server = server.server(self.lists, self.dicts, self.server_logger, net_mode='local')
|
||||||
self.server = server.server(
|
|
||||||
self.lists, self.dicts, self.server_logger, net_mode='local')
|
|
||||||
# //todo log configs
|
# //todo log configs
|
||||||
|
|
||||||
def python_version_check(self) -> None:
|
def python_version_check(self) -> None:
|
||||||
py_v_info = sys.version_info
|
self.main_logger.info('Difficult Rocket is running on Python Vision %s' % self.on_python_v)
|
||||||
py_v = str('%d.%d.%d' % (py_v_info[0], py_v_info[1], py_v_info[2]))
|
if self.on_python_v_info[0] == 2:
|
||||||
self.main_logger.info('Difficult Rocket is running on Python Vision %s' % py_v)
|
self.main_logger.critical('Difficult Rocket need Python vision 3+ but not %s ' % self.on_python_v)
|
||||||
if py_v_info[0] == 2:
|
raise Exception('Difficult Rocket need python vision 3+ but not %s ' % self.on_python_v)
|
||||||
self.main_logger.critical('Difficult Rocket need Python vision 3+ but not %s ' % py_v)
|
elif self.on_python_v_info[1] <= 7:
|
||||||
raise Exception('Difficult Rocket need python vision 3+ but not %s ' % py_v)
|
self.main_logger.warning('Difficult is develop in Python version 3.8 \n\
|
||||||
elif py_v_info[1] <= 7:
|
and you are running on %s may cause error' % self.on_python_v)
|
||||||
self.main_logger.warning('Difficult is develop in Python version 3.8 \n and you are running on %s may \
|
|
||||||
cause error' % py_v)
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
# start
|
# start
|
||||||
self.client.startGame()
|
self.client.start_game()
|
||||||
|
Loading…
Reference in New Issue
Block a user