some update
This commit is contained in:
parent
f1d71b4861
commit
c882d7901c
@ -15,27 +15,31 @@ hi = """Difficult Rocket is writen by shenjackyuanjie
|
|||||||
mail: 3695888@qq.com or shyj3695888@163.com
|
mail: 3695888@qq.com or shyj3695888@163.com
|
||||||
QQ: 3695888"""
|
QQ: 3695888"""
|
||||||
|
|
||||||
|
error_format = {
|
||||||
|
'TestError': '游戏正在调试中,某处引发了一个 TestError,不是bug造成的原因',
|
||||||
|
'AssertionError': '游戏的某处检查未通过,情报告issue',
|
||||||
|
'error.unknown': '游戏报错了,现在输出报错信息,请报告issue',
|
||||||
|
'error.happen': '游戏出现了一个报错!正在处理'
|
||||||
|
}
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("sys.path[0] = ", sys.path[0])
|
print(f'{__file__=}')
|
||||||
print("sys.argv[0] = ", sys.argv[0])
|
print(f'{sys.path[0]=}')
|
||||||
print("__file__ = ", __file__)
|
print(f'{sys.argv[0]=}')
|
||||||
print("os.path.abspath(__file__) = ", os.path.abspath(__file__))
|
print(f'{os.getcwd()=}')
|
||||||
print("os.path.realpath(__file__) = ", os.path.realpath(__file__))
|
print(f'{os.path.abspath(__file__)=}')
|
||||||
print("os.path.dirname(os.path.realpath(__file__)) = ", os.path.dirname(os.path.realpath(__file__)))
|
print(f'{os.path.realpath(__file__)=}')
|
||||||
print("os.path.split(os.path.realpath(__file__)) = ", os.path.split(os.path.realpath(__file__)))
|
|
||||||
print("os.path.split(os.path.realpath(__file__))[0] = ", os.path.split(os.path.realpath(__file__))[0])
|
|
||||||
print("os.getcwd() = ", os.getcwd())
|
|
||||||
# 输出一遍大部分文件位置相关信息 以后可能会加到logs里
|
# 输出一遍大部分文件位置相关信息 以后可能会加到logs里
|
||||||
file_path = os.path.split(os.path.realpath(__file__))[0]
|
file_path = os.path.split(os.path.realpath(__file__))[0]
|
||||||
os.chdir(file_path)
|
os.chdir(file_path)
|
||||||
sys.path.append(f'{file_path}\\Difficult_Rocket')
|
sys.path.append(f'{file_path}/Difficult_Rocket')
|
||||||
sys.path.append(f'{file_path}\\libs')
|
sys.path.append(f'{file_path}/libs')
|
||||||
print(sys.path)
|
print(sys.path)
|
||||||
print(hi)
|
print(hi)
|
||||||
|
|
||||||
DEBUGGING = False
|
DEBUGGING = False
|
||||||
from Difficult_Rocket.api.Exp import *
|
from Difficult_Rocket.api.Exp import *
|
||||||
print(multiprocessing.get_start_method())
|
|
||||||
try:
|
try:
|
||||||
from Difficult_Rocket import crash
|
from Difficult_Rocket import crash
|
||||||
from Difficult_Rocket import main
|
from Difficult_Rocket import main
|
||||||
@ -45,14 +49,15 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
if DEBUGGING:
|
if DEBUGGING:
|
||||||
raise TestError('debugging')
|
raise TestError('debugging')
|
||||||
except TestError:
|
except Exception as exp:
|
||||||
print('the game is debugging. this crash is raise by TestError')
|
from Difficult_Rocket.api.translate import tr
|
||||||
error = traceback.format_exc()
|
|
||||||
print(error)
|
print(error_format['error.happen'])
|
||||||
crash.create_crash_report(error)
|
|
||||||
except:
|
|
||||||
print('the game has unknown error , now outputting error message')
|
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
|
if (name := type(exp).__name__) in error_format:
|
||||||
|
print(error_format[name])
|
||||||
|
else:
|
||||||
|
print(error_format['error.unknown'])
|
||||||
print(error)
|
print(error)
|
||||||
crash.create_crash_report(error)
|
crash.create_crash_report(error)
|
||||||
else:
|
else:
|
||||||
|
@ -18,7 +18,6 @@ from typing import List, Optional
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# linear_algebra
|
# linear_algebra
|
||||||
|
|
||||||
|
|
||||||
@ -159,7 +158,7 @@ def distance(A, B):
|
|||||||
formats:
|
formats:
|
||||||
A & B format: docs.basic_config:basic_poi
|
A & B format: docs.basic_config:basic_poi
|
||||||
"""
|
"""
|
||||||
poi_dis = configs.basic_poi()
|
poi_dis = basic_poi()
|
||||||
for x in A, B:
|
for x in A, B:
|
||||||
x = decimal.Decimal(str(x))
|
x = decimal.Decimal(str(x))
|
||||||
xd = A[0] - B[0]
|
xd = A[0] - B[0]
|
||||||
@ -179,7 +178,7 @@ def _BasicNumber(int_num=0, float_num=1, unit1=None, unit2=None) -> list:
|
|||||||
unit1 = []
|
unit1 = []
|
||||||
if unit2 is None:
|
if unit2 is None:
|
||||||
unit2 = []
|
unit2 = []
|
||||||
if tools.is_decimal(float_num): # is decimal class?
|
if is_decimal(float_num): # is decimal class?
|
||||||
return [int_num, float_num, unit1, unit2] # is just return
|
return [int_num, float_num, unit1, unit2] # is just return
|
||||||
else:
|
else:
|
||||||
return [int_num, decimal.Decimal(str(float_num)), unit1, unit2] # no create a decimal class
|
return [int_num, decimal.Decimal(str(float_num)), unit1, unit2] # no create a decimal class
|
||||||
@ -296,3 +295,6 @@ class ScientificNumber:
|
|||||||
self.multi_unit = []
|
self.multi_unit = []
|
||||||
else:
|
else:
|
||||||
self.multi_unit = multi_unit
|
self.multi_unit = multi_unit
|
||||||
|
self.floats = floats
|
||||||
|
self.integer = integer
|
||||||
|
|
||||||
|
@ -352,5 +352,3 @@ def distance(A, B):
|
|||||||
poi_dis.append(poi_dis[0] + poi_dis[1])
|
poi_dis.append(poi_dis[0] + poi_dis[1])
|
||||||
poi_dis[2] **= 0.5
|
poi_dis[2] **= 0.5
|
||||||
return poi_dis[2]
|
return poi_dis[2]
|
||||||
|
|
||||||
# def
|
|
||||||
|
@ -83,16 +83,24 @@ class Lang:
|
|||||||
raise LanguageError(f'there\'s no key {args} in both {self.language} and zh-CN')
|
raise LanguageError(f'there\'s no key {args} in both {self.language} and zh-CN')
|
||||||
|
|
||||||
|
|
||||||
try:
|
tr = Lang('zh-CN')
|
||||||
tr = Lang('zh-CN')
|
|
||||||
except FileNotFoundError:
|
|
||||||
import os
|
|
||||||
|
|
||||||
os.chdir('..')
|
# font's value
|
||||||
os.chdir('..')
|
|
||||||
tr = Lang('zh-CN')
|
|
||||||
|
|
||||||
|
HOS = 'HarmonyOS_Sans'
|
||||||
|
HOS_S = 'HarmonyOS_Sans_SC'
|
||||||
|
HOS_T = 'HarmonyOS_Sans_TC'
|
||||||
|
HOS_I = 'HarmonyOS_Sans_Italic'
|
||||||
|
HOS_C = 'HarmonyOS_Sans_Condensed'
|
||||||
|
HOS_CI = 'HarmonyOS_Sans_Condensed_Italic'
|
||||||
|
HOS_NA = 'HarmonyOS_Sans_Naskh_Arabic'
|
||||||
|
HOS_NAU = 'HarmonyOS_Sans_Naskh_Arabic_UI'
|
||||||
|
|
||||||
def test():
|
鸿蒙字体 = HOS
|
||||||
print(tr)
|
鸿蒙简体 = HOS_S
|
||||||
assert tr.language == 'zh-CN'
|
鸿蒙繁体 = HOS_T
|
||||||
|
鸿蒙斜体 = HOS_I
|
||||||
|
鸿蒙窄体 = HOS_C
|
||||||
|
鸿蒙斜窄体 = HOS_CI
|
||||||
|
鸿蒙阿拉伯 = HOS_NA
|
||||||
|
鸿蒙阿拉伯UI = HOS_NAU
|
||||||
|
@ -33,7 +33,7 @@ if __name__ == '__main__': # been start will not run this
|
|||||||
from Difficult_Rocket import crash
|
from Difficult_Rocket import crash
|
||||||
from Difficult_Rocket.api.Exp import *
|
from Difficult_Rocket.api.Exp import *
|
||||||
from Difficult_Rocket.api.translate import tr
|
from Difficult_Rocket.api.translate import tr
|
||||||
from Difficult_Rocket.drag_sprite import DragSprite
|
from Difficult_Rocket.graphics import widgets
|
||||||
from Difficult_Rocket.api import tools, load_file, new_thread, thread
|
from Difficult_Rocket.api import tools, load_file, new_thread, thread
|
||||||
|
|
||||||
# libs function
|
# libs function
|
||||||
@ -48,12 +48,11 @@ else:
|
|||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
def __init__(self, net_mode='local'):
|
def __init__(self, net_mode='local'):
|
||||||
|
start_time = time.time_ns()
|
||||||
# logging
|
# logging
|
||||||
self.logger = logging.getLogger('client')
|
self.logger = logging.getLogger('client')
|
||||||
# config
|
# config
|
||||||
self.config = tools.load_file('configs/main.config')
|
self.config = tools.load_file('configs/main.config')
|
||||||
# lang
|
|
||||||
self.lang = tools.load_file('configs/lang/%s.json5' % self.config['runtime']['language'], 'client')
|
|
||||||
# value
|
# value
|
||||||
self.process_id = 'Client'
|
self.process_id = 'Client'
|
||||||
self.process_name = 'Client process'
|
self.process_name = 'Client process'
|
||||||
@ -67,7 +66,11 @@ class Client:
|
|||||||
caption=self.caption,
|
caption=self.caption,
|
||||||
resizable=tools.format_bool(self.config['window']['resizable']),
|
resizable=tools.format_bool(self.config['window']['resizable']),
|
||||||
visible=tools.format_bool(self.config['window']['visible']))
|
visible=tools.format_bool(self.config['window']['visible']))
|
||||||
self.logger.info(tr['client']['setup.done'])
|
self.logger.info(tr.lang('client', 'setup.done'))
|
||||||
|
end_time = time.time_ns()
|
||||||
|
self.use_time = end_time - start_time
|
||||||
|
self.logger.info(tr.lang('client', 'setup.use_time').format(Decimal(self.use_time) / 1000000000))
|
||||||
|
self.logger.debug(tr.lang('client', 'setup.use_time_ns').format(self.use_time))
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.window.start_game() # 游戏启动
|
self.window.start_game() # 游戏启动
|
||||||
@ -77,7 +80,7 @@ class Client:
|
|||||||
class ClientWindow(pyglet.window.Window):
|
class ClientWindow(pyglet.window.Window):
|
||||||
|
|
||||||
def __init__(self, net_mode='local', *args, **kwargs):
|
def __init__(self, net_mode='local', *args, **kwargs):
|
||||||
self.times = [time.time()]
|
start_time = time.time_ns()
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
"""
|
"""
|
||||||
:param dev_list: 共享内存
|
:param dev_list: 共享内存
|
||||||
@ -96,8 +99,6 @@ class ClientWindow(pyglet.window.Window):
|
|||||||
self.config_file = tools.load_file('configs/main.config')
|
self.config_file = tools.load_file('configs/main.config')
|
||||||
self.FPS = Decimal(int(self.config_file['runtime']['fps']))
|
self.FPS = Decimal(int(self.config_file['runtime']['fps']))
|
||||||
self.SPF = Decimal('1') / self.FPS
|
self.SPF = Decimal('1') / self.FPS
|
||||||
# lang
|
|
||||||
self.lang = tools.load_file('configs/lang/%s.json5' % self.config_file['runtime']['language'], 'client')
|
|
||||||
# dic
|
# dic
|
||||||
self.environment = {}
|
self.environment = {}
|
||||||
self.textures = {} # all textures
|
self.textures = {} # all textures
|
||||||
@ -111,41 +112,40 @@ class ClientWindow(pyglet.window.Window):
|
|||||||
self.label_batch = pyglet.graphics.Batch()
|
self.label_batch = pyglet.graphics.Batch()
|
||||||
# frame
|
# frame
|
||||||
self.frame = pyglet.gui.Frame(self)
|
self.frame = pyglet.gui.Frame(self)
|
||||||
self.M_frame = pyglet.gui.MovableFrame(self)
|
self.M_frame = pyglet.gui.MovableFrame(self, modifier=key.LCTRL)
|
||||||
# setup
|
# setup
|
||||||
self.setup()
|
self.setup()
|
||||||
self.info_label = pyglet.text.Label(x=10, y=self.height - 10,
|
self.info_label = pyglet.text.Label(x=10, y=self.height - 10,
|
||||||
anchor_x='left', anchor_y='top',
|
anchor_x='left', anchor_y='top',
|
||||||
batch=self.label_batch)
|
batch=self.label_batch)
|
||||||
pyglet.clock.schedule_interval(self.update, float(self.SPF))
|
pyglet.clock.schedule_interval(self.update, float(self.SPF))
|
||||||
self.logger.info(self.lang['setup.done'])
|
self.logger.info(tr.lang('window', 'setup.done'))
|
||||||
|
end_time = time.time_ns()
|
||||||
@new_thread('client_load_environment')
|
self.use_time = end_time - start_time
|
||||||
def load_environment(self) -> None:
|
self.logger.info(tr.lang('window', 'setup.use_time').format(Decimal(self.use_time) / 1000000000))
|
||||||
# load parts info
|
self.logger.debug(tr.lang('window', 'setup.use_time_ns').format(self.use_time))
|
||||||
self.environment['parts'] = load_file('configs/sys_value/parts.json5')
|
|
||||||
try:
|
|
||||||
self.load_textures()
|
|
||||||
except TexturesError:
|
|
||||||
raise
|
|
||||||
|
|
||||||
@new_thread('client_load_textures')
|
|
||||||
def load_textures(self) -> None:
|
|
||||||
# load parts
|
|
||||||
self.textures['parts'] = {}
|
|
||||||
for part in self.environment['parts']:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.logger.info(tr.lang('window', 'os.pid_is').format(os.getpid(), os.getppid()))
|
self.logger.info(tr.lang('window', 'os.pid_is').format(os.getpid(), os.getppid()))
|
||||||
image = pyglet.image.load('textures/Editor/PartButton.png')
|
self.load_fonts()
|
||||||
self.textures['test'] = DragSprite(10, 20, image, batch=self.label_batch, drag_by_all=False, drag_out_window=True)
|
|
||||||
self.load_environment()
|
@new_thread('client load_fonts')
|
||||||
|
def load_fonts(self):
|
||||||
|
file_path = './libs/fonts/HarmonyOS Sans/'
|
||||||
|
ttf_files = os.listdir(file_path)
|
||||||
|
self.logger.info(tr.lang('window', 'fonts.found').format(ttf_files))
|
||||||
|
for ttf_file in ttf_files:
|
||||||
|
pyglet.font.add_directory(f'{file_path}{ttf_file}')
|
||||||
|
|
||||||
|
@new_thread('client load_editor')
|
||||||
|
def load_Editor(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def start_game(self) -> None:
|
def start_game(self) -> None:
|
||||||
self.run_input = True
|
self.run_input = True
|
||||||
# self.input_line = threading.Thread(target=self.read_input, name='client_read_line', daemon=True)
|
# self.read_thread = threading.Thread(target=self.read_input, name='client_read_input')
|
||||||
# self.input_line.start()
|
# self.read_thread.start()
|
||||||
|
# crash.all_thread.append(self.read_thread)
|
||||||
pyglet.app.run()
|
pyglet.app.run()
|
||||||
|
|
||||||
def read_input(self):
|
def read_input(self):
|
||||||
@ -162,9 +162,10 @@ class ClientWindow(pyglet.window.Window):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def update(self, tick: float):
|
def update(self, tick: float):
|
||||||
self.FPS_update(tick)
|
decimal_tick = Decimal(tick)
|
||||||
|
self.FPS_update(decimal_tick)
|
||||||
|
|
||||||
def FPS_update(self, tick: float):
|
def FPS_update(self, tick: Decimal):
|
||||||
now_FPS = pyglet.clock.get_fps()
|
now_FPS = pyglet.clock.get_fps()
|
||||||
if now_FPS > self.max_fps[0]:
|
if now_FPS > self.max_fps[0]:
|
||||||
self.max_fps = [now_FPS, time.time()]
|
self.max_fps = [now_FPS, time.time()]
|
||||||
@ -199,20 +200,13 @@ class ClientWindow(pyglet.window.Window):
|
|||||||
|
|
||||||
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers) -> None:
|
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers) -> None:
|
||||||
# self.logger.debug('按键拖拽 %s %s %s %s %s %s' % (x, y, dx, dy, buttons, modifiers))
|
# self.logger.debug('按键拖拽 %s %s %s %s %s %s' % (x, y, dx, dy, buttons, modifiers))
|
||||||
self.textures['test'].on_mouse_drag(x, y, dx, dy, buttons, modifiers)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_mouse_press(self, x, y, button, modifiers) -> None:
|
def on_mouse_press(self, x, y, button, modifiers) -> None:
|
||||||
if button == mouse.LEFT:
|
self.logger.debug(tr.lang('window', 'mouse.press').format([x, y], tr.lang('window', 'mouse.{}'.format(mouse.buttons_string(button)))))
|
||||||
self.logger.debug(self.lang['mouse.press'].format([x, y], self.lang['mouse.left']))
|
|
||||||
elif button == mouse.RIGHT:
|
|
||||||
self.logger.debug(self.lang['mouse.press'].format([x, y], self.lang['mouse.right']))
|
|
||||||
self.textures['test']._sprite.rotation = random.randint(0, 360)
|
|
||||||
self.textures['test'].on_mouse_press(x, y, button, modifiers)
|
|
||||||
|
|
||||||
def on_mouse_release(self, x, y, button, modifiers) -> None:
|
def on_mouse_release(self, x, y, button, modifiers) -> None:
|
||||||
self.logger.debug(tr.lang('window', 'mouse.release').format([x, y], tr.lang('window', 'mouse.right')))
|
self.logger.debug(tr.lang('window', 'mouse.release').format([x, y], tr.lang('window', 'mouse.{}'.format(mouse.buttons_string(button)))))
|
||||||
self.textures['test'].on_mouse_release(x, y, button, modifiers)
|
|
||||||
|
|
||||||
def on_key_press(self, symbol, modifiers) -> None:
|
def on_key_press(self, symbol, modifiers) -> None:
|
||||||
if symbol == key.ESCAPE and not (modifiers & ~(key.MOD_NUMLOCK |
|
if symbol == key.ESCAPE and not (modifiers & ~(key.MOD_NUMLOCK |
|
||||||
|
@ -1,105 +0,0 @@
|
|||||||
"""
|
|
||||||
writen by shenjackyuanjie
|
|
||||||
mail: 3695888@qq.com
|
|
||||||
github: @shenjackyuanjie
|
|
||||||
gitee: @shenjackyuanjie
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
if __name__ == '__main__': # been start will not run this
|
|
||||||
sys.path.append('/bin/libs')
|
|
||||||
sys.path.append('/bin')
|
|
||||||
|
|
||||||
import pyglet
|
|
||||||
from pyglet.window import mouse
|
|
||||||
from pyglet.gui.widgets import WidgetBase
|
|
||||||
|
|
||||||
|
|
||||||
class DragSprite(WidgetBase):
|
|
||||||
"""Instance of a drag button.
|
|
||||||
|
|
||||||
Triggers the event 'on_press' when it is clicked by the mouse.
|
|
||||||
Triggers the event 'on_release' when the mouse is released.
|
|
||||||
Triggers the event 'on_drag' when it is drag by mouse.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# TODO make it More standardized
|
|
||||||
# TODO add group thing again(i don't know how to)
|
|
||||||
# by shenjack
|
|
||||||
|
|
||||||
def __init__(self,
|
|
||||||
x: int,
|
|
||||||
y: int,
|
|
||||||
image: pyglet.image.AbstractImage,
|
|
||||||
drag_by_all: bool = False,
|
|
||||||
drag_out_window: bool = False,
|
|
||||||
batch: pyglet.graphics.Batch = None,
|
|
||||||
group: pyglet.graphics.Group = None):
|
|
||||||
"""Create a draggable sprite.
|
|
||||||
|
|
||||||
:Parameters:
|
|
||||||
`x` : int
|
|
||||||
X coordinate of the push button.
|
|
||||||
`y` : int
|
|
||||||
Y coordinate of the push button.
|
|
||||||
`image` : `~pyglet.image.AbstractImage`
|
|
||||||
Image to display when the sprite is pressed.
|
|
||||||
`drag_by_all` : bool
|
|
||||||
If True then sprite will move whatever witch mouse button drag the sprite,
|
|
||||||
or the sprite will only move when Left mouse button drag.
|
|
||||||
`drag_out_window` : bool
|
|
||||||
If True then sprite will move out of the window with the mouse dragging,
|
|
||||||
or the sprite will only stop on the edge of the window.
|
|
||||||
`batch` : `~pyglet.graphics.Batch`
|
|
||||||
Optional batch to add the sprite to.
|
|
||||||
`group` : `~pyglet.graphics.Group`
|
|
||||||
Optional parent group of the sprite.
|
|
||||||
"""
|
|
||||||
super().__init__(x, y, image.width, image.height)
|
|
||||||
self._image = image
|
|
||||||
self._batch = batch or pyglet.graphics.Batch()
|
|
||||||
self._sprite = pyglet.sprite.Sprite(self._image, x, y, batch=batch, group=group)
|
|
||||||
self.drag_by_all = drag_by_all
|
|
||||||
self.drag_out_window = drag_out_window
|
|
||||||
self.dragging = False
|
|
||||||
|
|
||||||
def _check_hit(self, x, y):
|
|
||||||
return self._x < x < self._x + self._width and self._y < y < self._y + self._height
|
|
||||||
|
|
||||||
def on_mouse_press(self, x, y, buttons, modifiers):
|
|
||||||
if (buttons == mouse.LEFT) or self.drag_by_all:
|
|
||||||
if self._check_hit(x, y):
|
|
||||||
self.dragging = True
|
|
||||||
self.dispatch_event('on_press', buttons, self.dragging)
|
|
||||||
|
|
||||||
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
|
|
||||||
if self.dragging:
|
|
||||||
# TODO find a way to get window height and width
|
|
||||||
if (self._x + dx) < 0 and not self.drag_out_window:
|
|
||||||
self._sprite.x = 0
|
|
||||||
self._x = 0
|
|
||||||
else:
|
|
||||||
self._sprite.x += dx
|
|
||||||
self._x += dx
|
|
||||||
if (self._y + dy) < 0 and not self.drag_out_window:
|
|
||||||
self._sprite.y = 0
|
|
||||||
self._y = 0
|
|
||||||
else:
|
|
||||||
self._sprite.y += dy
|
|
||||||
self._y += dy
|
|
||||||
self.dispatch_event('on_drag', x, y, dx, dy, buttons, modifiers)
|
|
||||||
|
|
||||||
def draw(self):
|
|
||||||
self._sprite.draw()
|
|
||||||
# just use self.draw can draw
|
|
||||||
|
|
||||||
def on_mouse_release(self, x, y, buttons, modifiers):
|
|
||||||
if self.dragging:
|
|
||||||
self.dragging = not self.dragging
|
|
||||||
self.dispatch_event('on_release', x, y, buttons, modifiers)
|
|
||||||
|
|
||||||
|
|
||||||
DragSprite.register_event_type('on_drag')
|
|
||||||
DragSprite.register_event_type('on_press')
|
|
||||||
DragSprite.register_event_type('on_release')
|
|
12
Difficult_Rocket/graphics/__init__.py
Normal file
12
Difficult_Rocket/graphics/__init__.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# -------------------------------
|
||||||
|
# Difficult Rocket
|
||||||
|
# Copyright © 2021 by shenjackyuanjie
|
||||||
|
# All rights reserved
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
"""
|
||||||
|
writen by shenjackyuanjie
|
||||||
|
mail: 3695888@qq.com
|
||||||
|
github: @shenjackyuanjie
|
||||||
|
gitee: @shenjackyuanjie
|
||||||
|
"""
|
35
Difficult_Rocket/graphics/widgets.py
Normal file
35
Difficult_Rocket/graphics/widgets.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# -------------------------------
|
||||||
|
# Difficult Rocket
|
||||||
|
# Copyright © 2021 by shenjackyuanjie
|
||||||
|
# All rights reserved
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
"""
|
||||||
|
writen by shenjackyuanjie
|
||||||
|
mail: 3695888@qq.com
|
||||||
|
github: @shenjackyuanjie
|
||||||
|
gitee: @shenjackyuanjie
|
||||||
|
"""
|
||||||
|
|
||||||
|
from libs import pyglet
|
||||||
|
from libs.pyglet.gui import widgets
|
||||||
|
from libs.pyglet.sprite import Sprite
|
||||||
|
from libs.pyglet.graphics import Batch
|
||||||
|
from libs.pyglet.image import AbstractImage
|
||||||
|
|
||||||
|
|
||||||
|
class Parts(widgets.WidgetBase):
|
||||||
|
"""
|
||||||
|
parts
|
||||||
|
"""
|
||||||
|
def __init__(self,
|
||||||
|
x: int,
|
||||||
|
y: int,
|
||||||
|
width: int,
|
||||||
|
height: int,
|
||||||
|
textures: AbstractImage,
|
||||||
|
batch: Batch,
|
||||||
|
parts_data: dict):
|
||||||
|
super().__init__(x, y, width, height)
|
||||||
|
self.sprite = Sprite(img=textures, x=x, y=y, batch=batch)
|
||||||
|
self._value = 0
|
11
README.md
11
README.md
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
|
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
|
||||||
[![Generic badge](https://img.shields.io/badge/Write_with_Python-3.8.10-blue.svg)](https://Python.org)
|
[![Generic badge](https://img.shields.io/badge/Write_with_Python-3.8.10-blue.svg)](https://Python.org)
|
||||||
[![Generic badge](https://img.shields.io/badge/Python-3.6_|_3.7_|_3.8_|_3.9-blue.svg)](https://Python.org)
|
[![Generic badge](https://img.shields.io/badge/Python-_3.8_|_3.9-blue.svg)](https://Python.org)
|
||||||
|
|
||||||
## Version
|
## Version
|
||||||
|
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<br/>[![Generic badge](https://img.shields.io/badge/Pre_Release-0.4.6-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases/v0.4.6)
|
<br/>[![Generic badge](https://img.shields.io/badge/Pre_Release-0.4.6-blue.svg)](https://github.com/shenjackyuanjie/Difficult-Rocket/releases/v0.4.6)
|
||||||
<br/>![Generic badge](https://img.shields.io/badge/Devloping-0.5.2-blue.svg)
|
<br/>![Generic badge](https://img.shields.io/badge/Devloping-0.5.2-blue.svg)
|
||||||
|
|
||||||
## 中文README请移步 [这里](./docs/README-cn.md)
|
## 中文README请移步 [这里](/docs/README-cn.md)
|
||||||
|
|
||||||
> It's a Simple Rocket liked game build with Python
|
> It's a Simple Rocket liked game build with Python
|
||||||
|
|
||||||
@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
> Lighter than Vanilla SR
|
> Lighter than Vanilla SR
|
||||||
|
|
||||||
## [Plan feature list](./docs/plan_features)
|
## [Plan feature list](/docs/plan_features)
|
||||||
|
|
||||||
## [Update logs](./docs/update_logs.md)
|
## [Update logs](/docs/update_logs.md)
|
||||||
|
|
||||||
## Environment (been tested / develop on)
|
## Environment (been tested / develop on)
|
||||||
|
|
||||||
@ -31,9 +31,10 @@
|
|||||||
- `Python 3.8.10`
|
- `Python 3.8.10`
|
||||||
- `Windows10 x64`
|
- `Windows10 x64`
|
||||||
- `pyglet 2.0.dev9`
|
- `pyglet 2.0.dev9`
|
||||||
- `Json5 0.9.5`
|
- `Json5 0.9.6`
|
||||||
- `pillow 8.1.0`
|
- `pillow 8.1.0`
|
||||||
- `AMD R5 5600X`
|
- `AMD R5 5600X`
|
||||||
|
- `AMD RX 550 4G`
|
||||||
-
|
-
|
||||||
- `Develop platform 2 - macOS Big Sur`
|
- `Develop platform 2 - macOS Big Sur`
|
||||||
- `Python 3.8.7`
|
- `Python 3.8.7`
|
||||||
|
@ -16,19 +16,22 @@
|
|||||||
},
|
},
|
||||||
'client': {
|
'client': {
|
||||||
'setup.done': '客户端载入完成',
|
'setup.done': '客户端载入完成',
|
||||||
'setup.use_time': '客户端载入花费: {} 秒'
|
'setup.use_time': '客户端载入花费: {} 秒',
|
||||||
|
'setup.use_time_ns': '客户端载入花费: {} 纳秒'
|
||||||
},
|
},
|
||||||
'window': {
|
'window': {
|
||||||
'setup.done': '游戏窗口载入完成',
|
'setup.done': '游戏窗口载入完成',
|
||||||
'setup.use_time': '游戏窗口载入消耗时间: {} 秒',
|
'setup.use_time': '游戏窗口载入消耗时间: {} 秒',
|
||||||
|
'setup.use_time_ns': '游戏窗口载入消耗时间: {} 纳秒',
|
||||||
'os.pid_is': '游戏窗口 PID: {} PPID: {}',
|
'os.pid_is': '游戏窗口 PID: {} PPID: {}',
|
||||||
'button.been_press': '按钮被按下,目前状态为:',
|
'button.been_press': '按钮被按下,目前状态为:',
|
||||||
'mouse.press': '鼠标在 {} 被按下,按键为:{}',
|
'mouse.press': '鼠标在 {} 被按下,按键为:{}',
|
||||||
'mouse.release': '鼠标在 {} 释放,按键为:{}',
|
'mouse.release': '鼠标在 {} 释放,按键为:{}',
|
||||||
'mouse.right': '右键',
|
'mouse.RIGHT': '右键',
|
||||||
'mouse.left': '左键',
|
'mouse.LEFT': '左键',
|
||||||
'libs.local': '正在使用本地 pyglet 库 版本为: {}',
|
'libs.local': '正在使用本地 pyglet 库 版本为: {}',
|
||||||
'libs.outer': '正在使用全局 pyglet 库 版本为: {}\n(可能会造成bug,因为本地库版本为2.0dev9)'
|
'libs.outer': '正在使用全局 pyglet 库 版本为: {}\n(可能会造成bug,因为本地库版本为2.0dev9)',
|
||||||
|
'fonts.found': '在字体列表中找到以下字体库: {}'
|
||||||
},
|
},
|
||||||
'server': {
|
'server': {
|
||||||
'setup.done': '服务端载入完成',
|
'setup.done': '服务端载入完成',
|
||||||
|
@ -1,26 +1,31 @@
|
|||||||
{
|
{
|
||||||
'Editor': {
|
'Editor': {
|
||||||
'runtime': {
|
'runtime': {
|
||||||
'toolbar.dark': 'Editor/ToolbarDark.png',
|
'toolbar.dark': 'ToolbarDark.png',
|
||||||
'toolbar.light': 'Editor/ToolbarLight.png',
|
'toolbar.light': 'ToolbarLight.png',
|
||||||
'button_side.dark': 'Editor/ButtonDarkSide.png',
|
'button_side.dark': 'ButtonDarkSide.png',
|
||||||
'button_side.light': 'Editor/ButtonLightSide.png'
|
'button_side.light': 'ButtonLightSide.png'
|
||||||
},
|
},
|
||||||
'toggle_button': {
|
'toggle_button': {
|
||||||
'stage': 'Editor/ToolbarIconStaging.png',
|
'stage': 'ToolbarIconStaging.png',
|
||||||
'add_part': 'Editor/ToolbarIconAddPart.png',
|
'add_part': 'ToolbarIconAddPart.png',
|
||||||
'menu': 'Editor/ToolbarIconMenu.png'
|
'menu': 'ToolbarIconMenu.png'
|
||||||
},
|
},
|
||||||
'push_button': {
|
'push_button': {
|
||||||
'zoom': 'Editor/ToolbarIconZoom.png',
|
'zoom': 'ToolbarIconZoom.png',
|
||||||
'zoom.in': 'Editor/ToolbarIconZoomIn.png',
|
'zoom.in': 'ToolbarIconZoomIn.png',
|
||||||
'zoom.out': 'Editor/ToolbarIconZoomOut.png',
|
'zoom.out': 'ToolbarIconZoomOut.png',
|
||||||
'play': 'Editor/ToolbarIconPlay.png',
|
'play': 'ToolbarIconPlay.png',
|
||||||
'rotate': 'Editor/RotateButton.png',
|
'rotate': 'RotateButton.png',
|
||||||
'trash_can': 'Editor/TrashCan.png'
|
'trash_can': 'TrashCan.png'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'Runtime': {
|
'Runtime': {
|
||||||
|
},
|
||||||
|
'Parts': {
|
||||||
|
'battery': 'Battery.png',
|
||||||
|
'beam': 'Beam.png',
|
||||||
|
'cover_bottom': 'CoverBottom.png',
|
||||||
|
'nose_cone': 'NoseCone.png'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
|
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
|
||||||
[![Generic badge](https://img.shields.io/badge/编写_Python_版本-3.8.10-blue.svg)](https://Python.org)
|
[![Generic badge](https://img.shields.io/badge/编写_Python_版本-3.8.10-blue.svg)](https://Python.org)
|
||||||
[![Generic badge](https://img.shields.io/badge/Python-3.6_|_3.7_|_3.8_|_3.9-blue.svg)](https://Python.org)
|
[![Generic badge](https://img.shields.io/badge/Python-_3.8_|_3.9-blue.svg)](https://Python.org)
|
||||||
|
|
||||||
## 版本
|
## 版本
|
||||||
|
|
||||||
@ -32,9 +32,10 @@
|
|||||||
- `Python 3.8.10`
|
- `Python 3.8.10`
|
||||||
- `Windows10 x64`
|
- `Windows10 x64`
|
||||||
- `pyglet 2.0.dev9`
|
- `pyglet 2.0.dev9`
|
||||||
- `Json5 0.9.5`
|
- `Json5 0.9.6`
|
||||||
- `pillow 8.1.0`
|
- `pillow 8.1.0`
|
||||||
- `AMD R5 5600X(AMD YES!)`
|
- `AMD R5 5600X(AMD YES!)`
|
||||||
|
- `AMD RX 550 4G`
|
||||||
-
|
-
|
||||||
- `开发平台2 macOS Big Sur`
|
- `开发平台2 macOS Big Sur`
|
||||||
- `Python 3.8.7`
|
- `Python 3.8.7`
|
||||||
|
@ -3,13 +3,27 @@
|
|||||||
## Readme
|
## Readme
|
||||||
##### most badge can be clicked and jump
|
##### most badge can be clicked and jump
|
||||||
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
|
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
|
||||||
![Generic badge](https://img.shields.io/badge/Version-0.5.1-yellow.svg)
|
![Generic badge](https://img.shields.io/badge/Version-0.5.3-yellow.svg)
|
||||||
|
|
||||||
- [![Readme-github](https://img.shields.io/badge/Readme-Github-blue.svg?style=flat-square&logo=Github)](https://github.com/shenjackyuanjie/Difficult-Rocket)
|
- [![Readme-github](https://img.shields.io/badge/Readme-Github-blue.svg?style=flat-square&logo=Github)](https://github.com/shenjackyuanjie/Difficult-Rocket)
|
||||||
- [![Readme-gitee](https://img.shields.io/badge/Readme-Gitee-blue.svg?style=flat-square&logo=Gitee)](https://gitee.com/shenjackyuanjie/Difficult-Rocket)
|
- [![Readme-gitee](https://img.shields.io/badge/Readme-Gitee-blue.svg?style=flat-square&logo=Gitee)](https://gitee.com/shenjackyuanjie/Difficult-Rocket)
|
||||||
- [![Readme-gitee](https://img.shields.io/badge/Readme-中文(点我!)-blue.svg?style=flat-square)](README-cn.md)
|
- [![Readme-gitee](https://img.shields.io/badge/Readme-中文(点我!)-blue.svg?style=flat-square)](README-cn.md)
|
||||||
- Using [SemVer 2.0.0](https://semver.org/) to manage version
|
- Using [SemVer 2.0.0](https://semver.org/) to manage version
|
||||||
|
|
||||||
|
## 202110 V 0.5.3
|
||||||
|
|
||||||
|
### Change
|
||||||
|
|
||||||
|
- now `Difficult Rocket` will only fit python3.8+
|
||||||
|
- because `:=`
|
||||||
|
- now main crash report handler have new way to handler crash
|
||||||
|
|
||||||
|
### Add
|
||||||
|
|
||||||
|
- `Difficult_Rocket.graphics.widgets.Parts`
|
||||||
|
- have many costume value
|
||||||
|
- `libs/fonts` now have `HarmonyOS_Sans`
|
||||||
|
|
||||||
## 20210928 V 0.5.2
|
## 20210928 V 0.5.2
|
||||||
|
|
||||||
### Change
|
### Change
|
||||||
|
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans/.DS_Store
vendored
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans/HarmonyOS_Sans_Bold.ttf
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans/HarmonyOS_Sans_Bold.ttf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans/HarmonyOS_Sans_Thin.ttf
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans/HarmonyOS_Sans_Thin.ttf
Normal file
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans/LICENSE.txt
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans/LICENSE.txt
Normal file
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Condensed/.DS_Store
vendored
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Condensed/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Condensed/LICENSE.txt
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Condensed/LICENSE.txt
Normal file
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Condensed_Italic/.DS_Store
vendored
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Condensed_Italic/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Italic/.DS_Store
vendored
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Italic/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Italic/LICENSE.txt
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Italic/LICENSE.txt
Normal file
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Naskh_Arabic/.DS_Store
vendored
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Naskh_Arabic/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Naskh_Arabic_UI/.DS_Store
vendored
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_Naskh_Arabic_UI/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_SC/.DS_Store
vendored
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_SC/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_SC/LICENSE.txt
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_SC/LICENSE.txt
Normal file
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_TC/.DS_Store
vendored
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_TC/.DS_Store
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_TC/LICENSE.txt
Normal file
BIN
libs/fonts/HarmonyOS Sans/HarmonyOS_Sans_TC/LICENSE.txt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user