From 042f0290fc5b01d105d3d0155d07a908edfe60e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E7=91=97=E6=9D=B0?= <3695888@qq.com> Date: Wed, 16 Dec 2020 06:33:33 +0800 Subject: [PATCH] THREAD! --- libs/delivery.py | 1 + libs/main.py | 44 ------------------------------------------- libs/render_thread.py | 44 +++++++++++++++++++++++++++++++++++++++++-- libs/tools.py | 13 +++++++++++++ 4 files changed, 56 insertions(+), 46 deletions(-) create mode 100644 libs/tools.py diff --git a/libs/delivery.py b/libs/delivery.py index d3c5dc1..e90bd3d 100644 --- a/libs/delivery.py +++ b/libs/delivery.py @@ -3,6 +3,7 @@ writen by shenjackyuanjie mail: 3695888@qq.com """ + class Delivery: def __init__(self): self.using = False diff --git a/libs/main.py b/libs/main.py index f0d92bf..5631e85 100644 --- a/libs/main.py +++ b/libs/main.py @@ -12,50 +12,6 @@ from pyglet.window import Window from pyglet.resource import image -def mbool(thing): # stand for my bool - if (thing == "True") or (thing == 1) or (thing == "1"): - return True - elif (thing == "False") or (thing == 0) or (thing == "0"): - return False - else: - raise ValueError("Need a 'like bool' not anything else") - - class Game(): def __init__(self): pass - - -class RenderThread(threading.Thread): - def __init__(self,): - # value - # dic - self.parts = {} # this ship parts - self.o_parts = {} # stand for opther parts - self.b_g_e = {} # stand for back ground element - self.planet_system = {} # hole planet system - # list - - def start_game(self): - run() - return - - def setup(self): - # dic - self.window_c = libs.loads.config( - ".\\configs\\window.json") # stand for window config - self.planet_c = libs.loads.config( - ".\\configs\\planet.json") # stand for planet config - self.textures_c = libs.loads.config( - ".\\configs\\basic_config", "textures") # stand for textures config - # image - self.b_g = image("back_ground_space.png") - # window - self.window = Window(width=int(self.window_c['width']), - height=int(self.window_c['height']), - fullscreen=mbool(self.window_c['fullscreen']), - caption=str(self.window_c['caption']), - visible=mbool(self.window_c['visible'])) - - def on_draw(self): - pass diff --git a/libs/render_thread.py b/libs/render_thread.py index 6930a3e..5fba0ab 100644 --- a/libs/render_thread.py +++ b/libs/render_thread.py @@ -11,6 +11,46 @@ from pyglet.app import run from pyglet.window import Window from pyglet.resource import image -class RenderThread(threading.Thread): + +class RenderThread(threading.Thread, pyglet.window.Window): def __init__(self, threadID, delivery_class): - pass \ No newline at end of file + # value + # dic + self.parts = {} # this ship parts + self.o_parts = {} # stand for opther parts + self.b_g_e = {} # stand for back ground element + self.planet_system = {} # hole planet system + # list + + def start_game(self): + run() + return + + def setup(self): + # dic + self.window_c = libs.loads.config( + ".\\configs\\window.json") # stand for window config + self.planet_c = libs.loads.config( + ".\\configs\\planet.json") # stand for planet config + self.textures_c = libs.loads.config( + ".\\configs\\basic_config", "textures") # stand for textures config + # image + self.b_g = image("back_ground_space.png") + # window + self.window = Window(width=int(self.window_c['width']), + height=int(self.window_c['height']), + fullscreen=mbool(self.window_c['fullscreen']), + caption=str(self.window_c['caption']), + visible=mbool(self.window_c['visible'])) + + def on_draw(self): + pass + + def on_mouse_motion(self): + pass + + def on_key_press(self): + pass + + def on_key_release(self): + pass diff --git a/libs/tools.py b/libs/tools.py new file mode 100644 index 0000000..3afaeed --- /dev/null +++ b/libs/tools.py @@ -0,0 +1,13 @@ +""" +writen by shenjackyuanjie +mail: 3695888@qq.com +""" + + +def mbool(thing): # stand for my bool + if (thing == "True") or (thing == 1) or (thing == "1"): + return True + elif (thing == "False") or (thing == 0) or (thing == "0"): + return False + else: + raise ValueError("Need a 'like bool' not anything else")