From 4656f8062cd5637b56d028be6f0f6cc423d4ad68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E7=91=97=E6=9D=B0?= <3695888@qq.com> Date: Mon, 25 Jan 2021 12:22:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E7=9D=80=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/client.py | 8 +++- bin/main.py | 21 +++++++--- bin/server.py | 4 +- docs/configes sample/basic_config.json5 | 51 +++++++++++++++-------- docs/configes sample/in_file_config.json5 | 16 +++---- docs/configes sample/key_config.json5 | 8 ++-- docs/configes sample/planet.json5 | 24 ++++++----- docs/configes sample/window.json5 | 14 +++---- sys_value/basic_config.json5 | 38 +++++++++++------ sys_value/planet.json5 | 24 ++++++----- sys_value/window.json5 | 14 +++---- 11 files changed, 140 insertions(+), 82 deletions(-) diff --git a/bin/client.py b/bin/client.py index 3eefa9f..4eb9bc0 100644 --- a/bin/client.py +++ b/bin/client.py @@ -14,10 +14,12 @@ from pyglet.window import Window class RenderThread(mp.Process, pyglet.window.Window): - def __init__(self, dev_list, dev_dic, net_mode='local'): + def __init__(self, dev_list, dev_dic, logger, net_mode='local'): # do father class __init__() Window.__init__(self) mp.Process.__init__(self) + # logging + self.logger = logger # value self.process_id = 'Render' self.process_name = 'render process' @@ -46,6 +48,10 @@ class RenderThread(mp.Process, pyglet.window.Window): caption=str(self.window_c['caption']), visible=bin.tools.mbool(self.window_c['visible'])) + """ + keyboard and mouse input + """ + def on_draw(self): pass diff --git a/bin/main.py b/bin/main.py index 293e739..51eb461 100644 --- a/bin/main.py +++ b/bin/main.py @@ -3,21 +3,32 @@ writen by shenjackyuanjie mail: 3695888@qq.com """ +# share memory from multiprocessing import Manager as share import bin +import time +import logging +# 直接导入 import server import client +# get time when the program to start the logging +start_time = time.time() +start_time_date = time.strftime("%Y-%m-%d %H-%M-%S", time.gmtime(start_time)) + +# ---------- option start ---------- +log_level = logging.DEBUG # log level + class Game(): def __init__(self): + self.start_time = time.strftime("%Y-%m-%d %H-%M-%S", time.gmtime(start_time)) self.dics = share().dict() self.lists = share().list() - self.client = client.RenderThread(self.lists, self.dics, net_mode='local') - self.server = server.server(self.lists, self.dics, net_mode='local') - - def setup(self): - pass + self.server_logger = logging.getLogger('server') + self.client_logger = logging.getLogger('client') + self.client = client.RenderThread(self.lists, self.dics, self.client_logger, net_mode='local') + self.server = server.server(self.lists, self.dics, self.server_logger, net_mode='local') diff --git a/bin/server.py b/bin/server.py index 5b3f483..9bd90e9 100644 --- a/bin/server.py +++ b/bin/server.py @@ -7,9 +7,11 @@ import multiprocessing as mp class server(mp.Process): - def __init__(self, dev_list, dev_dic, net_mode='local'): + def __init__(self, dev_list, dev_dic, logger, net_mode='local'): # father class __init__() mp.Process.__init__(self) + # logging + self.logger = logger # value self.process_id = 'Server' self.process_name = 'server process' diff --git a/docs/configes sample/basic_config.json5 b/docs/configes sample/basic_config.json5 index b26f7da..bd87db6 100644 --- a/docs/configes sample/basic_config.json5 +++ b/docs/configes sample/basic_config.json5 @@ -1,21 +1,38 @@ { - "language": "language", - "textures": { - "back_ground_space": "xxx.png", - "planet": { - "xxx": "xxx.png" - }, - "flame": { - "xxx": "xxx.png" - } + 'language': 'language', + 'textures': { + 'back_ground_space': 'xxx.png', + 'planet': { + 'xxx': 'xxx.png' }, - "basic_number": { - "name": ["float", "int", ["unit"], ["unit"], "name = float × 10^int × unit(s) ÷ unit(s)"] - }, - "basic_force" : { - "name": ["x", "y", "x&y format:basic_number/unit1:[m]/unit2:[]"] - }, - "basic_poi": { - "name": ["x", "y"] + 'flame': { + 'xxx': 'xxx.png' } + }, + 'basic_number': { + 'name': [ + 'float', + 'int', + [ + 'unit' + ], + [ + 'unit' + ], + 'name = float × 10^int × unit(s) ÷ unit(s)' + ] + }, + 'basic_force': { + 'name': [ + 'x', + 'y', + 'x&y format:basic_number/unit1:[m]/unit2:[]' + ] + }, + 'basic_poi': { + 'name': [ + 'x', + 'y' + ] + } } \ No newline at end of file diff --git a/docs/configes sample/in_file_config.json5 b/docs/configes sample/in_file_config.json5 index a28c04d..babfff0 100644 --- a/docs/configes sample/in_file_config.json5 +++ b/docs/configes sample/in_file_config.json5 @@ -1,10 +1,12 @@ { - "Game_threads": { - "orbit_demo": { - "ship_info": { - "mass": "basic_config:basic_number", - "force": "basic_config:basic_force" - } - } + 'Game_threads': { + 'orbit_demo': { + 'ship_info': { + 'mass': 'basic_config:basic_number', + 'force': 'basic_config:basic_force' + } } + }, + 'client': { + } } \ No newline at end of file diff --git a/docs/configes sample/key_config.json5 b/docs/configes sample/key_config.json5 index 38035a7..c3027db 100644 --- a/docs/configes sample/key_config.json5 +++ b/docs/configes sample/key_config.json5 @@ -1,6 +1,6 @@ { - "keys" : { - "function-1" : "keys-1", - "function-2" : "keys-2" - } + 'keys': { + 'function-1': 'keys-1', + 'function-2': 'keys-2' + } } \ No newline at end of file diff --git a/docs/configes sample/planet.json5 b/docs/configes sample/planet.json5 index 2f9ea54..22057cc 100644 --- a/docs/configes sample/planet.json5 +++ b/docs/configes sample/planet.json5 @@ -1,13 +1,17 @@ { - "System name": { - "description": "xxx", - "planets": { - "planets xxx": { - "description": "xxx", - "gravity": "x.xx N/kg", - "radius": "xxx m", - "map_color": ["R", "G", "B"] - } - } + 'System name': { + 'description': 'xxx', + 'planets': { + 'planets xxx': { + 'description': 'xxx', + 'gravity': 'x.xx N/kg', + 'radius': 'xxx m', + 'map_color': [ + 'R', + 'G', + 'B' + ] + } } + } } \ No newline at end of file diff --git a/docs/configes sample/window.json5 b/docs/configes sample/window.json5 index 3992d02..bc12e0b 100644 --- a/docs/configes sample/window.json5 +++ b/docs/configes sample/window.json5 @@ -1,13 +1,13 @@ { - "width": "int", - "height": "int", - "full_screen": "true/false", + 'width': 'int', + 'height': 'int', + 'full_screen': 'true/false', // bool - "caption": "xxx", + 'caption': 'xxx', // {version} -> version of SR - "resizable": "true", + 'resizable': 'true', // bool - "visible": "true", + 'visible': 'true', // bool - "style": "xxx(in list)" + 'style': 'xxx(in list)' } \ No newline at end of file diff --git a/sys_value/basic_config.json5 b/sys_value/basic_config.json5 index 8e07df1..524c5be 100644 --- a/sys_value/basic_config.json5 +++ b/sys_value/basic_config.json5 @@ -1,17 +1,29 @@ { - "language": "zh_cn", - "textures": { - "back_ground_space": "back_ground_space.png", - "planet": { - "earth_ground": "earth_ground.png" - }, - "flame": { - "liquid": "liquid_engine_flame.png", - "soild": "soild_engine_flame.png", - "ion": "ion_engine_flame.png" - } + 'language': 'zh_cn', + 'textures': { + 'back_ground_space': 'back_ground_space.png', + 'planet': { + 'earth_ground': 'earth_ground.png' }, - "basic_number": { - "G" : [6.67, -11, ["N", "m", "m"], ["kg", "kg"]] + 'flame': { + 'liquid': 'liquid_engine_flame.png', + 'solid': 'solid_engine_flame.png', + 'ion': 'ion_engine_flame.png' } + }, + 'basic_number': { + 'G': [ + 6.67, + -11, + [ + 'N', + 'm', + 'm' + ], + [ + 'kg', + 'kg' + ] + ] + } } \ No newline at end of file diff --git a/sys_value/planet.json5 b/sys_value/planet.json5 index f34e878..fc1a7ec 100644 --- a/sys_value/planet.json5 +++ b/sys_value/planet.json5 @@ -1,13 +1,17 @@ { - "Solar System": { - "description": "", - "planets": { - "smearth": { - "description": "", - "gravity": 9.81, - "radius": 63710000, - "map_color": [103, 157, 255] - } - } + 'Solar System': { + 'description': '', + 'planets': { + 'earth': { + 'description': '', + 'gravity': 9.81, + 'radius': 63710000, + 'map_color': [ + 103, + 157, + 255 + ] + } } + } } \ No newline at end of file diff --git a/sys_value/window.json5 b/sys_value/window.json5 index 9b843c8..921d0d6 100644 --- a/sys_value/window.json5 +++ b/sys_value/window.json5 @@ -1,13 +1,13 @@ { - "width": "1024", - "height": "768", - "full_screen": "false", + 'width': '1024', + 'height': '768', + 'full_screen': 'false', // bool - "caption": "Simple Rocket {version}", + 'caption': 'Simple Rocket {version}', // {version} -> version of SR - "resizable": "true", + 'resizable': 'true', // bool - "visible": "true", + 'visible': 'true', // bool - "style": "None" + 'style': 'None' } \ No newline at end of file