V 0.4.3
This commit is contained in:
parent
263a2d12b2
commit
73273fde7c
@ -27,6 +27,7 @@ if __name__ == '__main__':
|
|||||||
os.path.split(os.path.realpath(__file__))[0])
|
os.path.split(os.path.realpath(__file__))[0])
|
||||||
print("os.getcwd() = ", os.getcwd())
|
print("os.getcwd() = ", os.getcwd())
|
||||||
from bin import main
|
from bin import main
|
||||||
|
|
||||||
os.chdir(sys.path[0]) # TODO 没做完.ing
|
os.chdir(sys.path[0]) # TODO 没做完.ing
|
||||||
print(hi)
|
print(hi)
|
||||||
game = main.Game()
|
game = main.Game()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
### Version
|
### Version
|
||||||
|
|
||||||
0.4.2 (developing DEMO)
|
0.4.3 (developing DEMO)
|
||||||
|
|
||||||
[Update logs](https://github.com/shenjackyuanjie/Difficult-Rocket/blob/main/docs/update_logs.md)
|
[Update logs](https://github.com/shenjackyuanjie/Difficult-Rocket/blob/main/docs/update_logs.md)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class client(mp.Process):
|
|||||||
self.net_mode = net_mode
|
self.net_mode = net_mode
|
||||||
self.window_config = tools.config('configs/sys_value/window.json5')
|
self.window_config = tools.config('configs/sys_value/window.json5')
|
||||||
self.caption = self.window_config['caption']
|
self.caption = self.window_config['caption']
|
||||||
self.caption = configs.name_handler(self.caption, {'version': self.window_config['caption_option']['version']})
|
self.caption = tools.name_handler(self.caption, {'version': self.window_config['caption_option']['version']})
|
||||||
self.window = window(logger=logger,
|
self.window = window(logger=logger,
|
||||||
dev_dic=dev_dic,
|
dev_dic=dev_dic,
|
||||||
dev_list=dev_list,
|
dev_list=dev_list,
|
||||||
|
@ -3,12 +3,12 @@ writen by shenjackyuanjie
|
|||||||
mail: 3695888@qq.com
|
mail: 3695888@qq.com
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import decimal
|
|
||||||
import logging
|
|
||||||
# import re
|
# import re
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import decimal
|
||||||
|
import logging
|
||||||
|
|
||||||
sys.path.append('./bin/libs/')
|
sys.path.append('./bin/libs/')
|
||||||
sys.path.append('./')
|
sys.path.append('./')
|
||||||
@ -127,18 +127,6 @@ def basic_force() -> list:
|
|||||||
return BasicNumber(unit1='N', num=2)
|
return BasicNumber(unit1='N', num=2)
|
||||||
|
|
||||||
|
|
||||||
def configs(name, option=None) -> dict:
|
|
||||||
with open(name, 'r') as file:
|
|
||||||
data = json5.load(file)
|
|
||||||
if option:
|
|
||||||
try:
|
|
||||||
data = data[option]
|
|
||||||
except IndexError as exp:
|
|
||||||
log = 'can\'t find stack named %s in file %s' % (option, name)
|
|
||||||
configs_logger.exception(log)
|
|
||||||
raise IndexError(log)
|
|
||||||
return data
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
name_handlers = {'time.time': str(time.time()),
|
name_handlers = {'time.time': str(time.time()),
|
||||||
'dir': str(os.getcwd()),
|
'dir': str(os.getcwd()),
|
||||||
@ -159,31 +147,3 @@ def name_handler(name: str, configs=dict) -> str:
|
|||||||
handler_name = name.format(**names)
|
handler_name = name.format(**names)
|
||||||
return handler_name
|
return handler_name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
names = {'{time.time}': str(time.time()),
|
|
||||||
'{dir}': str(os.getcwd()),
|
|
||||||
'{py_v}': str(sys.version.split(' ')[0])}
|
|
||||||
|
|
||||||
|
|
||||||
def default_name_handler(name: str) -> str:
|
|
||||||
"""
|
|
||||||
won't change the string
|
|
||||||
just return one
|
|
||||||
"""
|
|
||||||
name = name
|
|
||||||
name = name.replace('{time.time}', str(time.time()))
|
|
||||||
name = name.replace('{dir}', str(os.getcwd()))
|
|
||||||
name = name.replace('{py_v}', str(sys.version.split(' ')[0]))
|
|
||||||
return name
|
|
||||||
|
|
||||||
|
|
||||||
def name_handler(name: str, formats=None) -> str:
|
|
||||||
if formats is None:
|
|
||||||
return default_name_handler(name)
|
|
||||||
name = default_name_handler(name)
|
|
||||||
for need_replace in formats:
|
|
||||||
replace = formats[need_replace]
|
|
||||||
if need_replace == '{date}':
|
|
||||||
replace = time.strftime(formats['{date}'], time.gmtime(time.time()))
|
|
||||||
name = name.replace(need_replace, replace)
|
|
||||||
return name
|
|
||||||
|
@ -41,7 +41,7 @@ class Game:
|
|||||||
self.lang = tools.config('configs/sys_value/lang/%s.json5' % self.language, 'main')
|
self.lang = tools.config('configs/sys_value/lang/%s.json5' % self.language, 'main')
|
||||||
# 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 = tools.name_handler(self.log_config['filename']['main'],
|
||||||
{'date': self.log_config['date_fmt']})
|
{'date': self.log_config['date_fmt']})
|
||||||
self.root_logger_fmt = logging.Formatter(self.log_config['fmt'], self.log_config['date_fmt'])
|
self.root_logger_fmt = logging.Formatter(self.log_config['fmt'], self.log_config['date_fmt'])
|
||||||
self.root_logger_stream_handler = logging.StreamHandler()
|
self.root_logger_stream_handler = logging.StreamHandler()
|
||||||
@ -88,7 +88,7 @@ class Game:
|
|||||||
self.main_logger.critical('%s' % self.lang['version.need3+'])
|
self.main_logger.critical('%s' % self.lang['version.need3+'])
|
||||||
raise SystemError('%s' % self.lang['version.need3+'])
|
raise SystemError('%s' % self.lang['version.need3+'])
|
||||||
elif self.on_python_v_info[1] < 9:
|
elif self.on_python_v_info[1] < 9:
|
||||||
warning = configs.name_handler(self.lang['version.best3.8+'])
|
warning = tools.name_handler(self.lang['version.best3.8+'])
|
||||||
self.main_logger.warning(warning)
|
self.main_logger.warning(warning)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
42
bin/tools.py
42
bin/tools.py
@ -3,16 +3,18 @@ writen by shenjackyuanjie
|
|||||||
mail: 3695888@qq.com
|
mail: 3695888@qq.com
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import configparser
|
|
||||||
import decimal
|
|
||||||
import logging
|
|
||||||
import math
|
|
||||||
import sys
|
import sys
|
||||||
from xml.dom.minidom import parse
|
|
||||||
|
|
||||||
sys.path.append('./bin/libs/')
|
sys.path.append('./bin/libs/')
|
||||||
sys.path.append('./')
|
sys.path.append('./')
|
||||||
import json5
|
import json5
|
||||||
|
import configparser
|
||||||
|
import decimal
|
||||||
|
import logging
|
||||||
|
import math
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
from xml.dom.minidom import parse
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import configs
|
import configs
|
||||||
@ -253,7 +255,6 @@ def config(file_name, stack=None): # // TODO 加上.config的读取+解析
|
|||||||
cp.read(file_name) # config parser -> reader
|
cp.read(file_name) # config parser -> reader
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_At(name, in_xml, need_type=str):
|
def get_At(name, in_xml, need_type=str):
|
||||||
"""
|
"""
|
||||||
get Attribute from a XML tree
|
get Attribute from a XML tree
|
||||||
@ -278,3 +279,32 @@ def get_At(name, in_xml, need_type=str):
|
|||||||
else:
|
else:
|
||||||
raise TypeError('only str and list type is ok but you give me a' + name_type + 'type')
|
raise TypeError('only str and list type is ok but you give me a' + name_type + 'type')
|
||||||
return need_type(At)
|
return need_type(At)
|
||||||
|
|
||||||
|
|
||||||
|
names = {'{time.time}': str(time.time()),
|
||||||
|
'{dir}': str(os.getcwd()),
|
||||||
|
'{py_v}': str(sys.version.split(' ')[0])}
|
||||||
|
|
||||||
|
|
||||||
|
def default_name_handler(name: str) -> str:
|
||||||
|
"""
|
||||||
|
won't change the string
|
||||||
|
just return one
|
||||||
|
"""
|
||||||
|
name = name
|
||||||
|
name = name.replace('{time.time}', str(time.time()))
|
||||||
|
name = name.replace('{dir}', str(os.getcwd()))
|
||||||
|
name = name.replace('{py_v}', str(sys.version.split(' ')[0]))
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
def name_handler(name: str, formats=None) -> str:
|
||||||
|
if formats is None:
|
||||||
|
return default_name_handler(name)
|
||||||
|
name = default_name_handler(name)
|
||||||
|
for need_replace in formats:
|
||||||
|
replace = formats[need_replace]
|
||||||
|
if need_replace == '{date}':
|
||||||
|
replace = time.strftime(formats['{date}'], time.gmtime(time.time()))
|
||||||
|
name = name.replace(need_replace, replace)
|
||||||
|
return name
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
'caption': 'Simple Rocket {version}',
|
'caption': 'Simple Rocket {version}',
|
||||||
// {version} -> version of SR
|
// {version} -> version of SR
|
||||||
'caption_option': {
|
'caption_option': {
|
||||||
'version': '0.4.1'
|
'version': '0.4.3'
|
||||||
},
|
},
|
||||||
'resizable': 'true',
|
'resizable': 'true',
|
||||||
// bool
|
// bool
|
||||||
'visible': 'true',
|
'visible': 'true',
|
||||||
// bool
|
// bool
|
||||||
'style': 'None',
|
'style': 'None',
|
||||||
'fps': 120,
|
'fps': 60,
|
||||||
'views': [
|
'views': [
|
||||||
'space',
|
'space',
|
||||||
'map',
|
'map',
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 版本
|
## 版本
|
||||||
|
|
||||||
0.4.2 (开发DEMO.ing)
|
0.4.3 (开发DEMO.ing)
|
||||||
|
|
||||||
[更新日志](https://github.com/shenjackyuanjie/Difficult-Rocket/blob/main/docs/update_logs.md)
|
[更新日志](https://github.com/shenjackyuanjie/Difficult-Rocket/blob/main/docs/update_logs.md)
|
||||||
|
|
||||||
|
@ -5,6 +5,21 @@
|
|||||||
- [README](https://github.com/shenjackyuanjie/Difficult-Rocket)
|
- [README](https://github.com/shenjackyuanjie/Difficult-Rocket)
|
||||||
- [中文README](https://github.com/shenjackyuanjie/Difficult-Rocket/blob/main/docs/README-cn.md)
|
- [中文README](https://github.com/shenjackyuanjie/Difficult-Rocket/blob/main/docs/README-cn.md)
|
||||||
|
|
||||||
|
## 2021/06/26 V 0.4.3
|
||||||
|
|
||||||
|
### DEBUG
|
||||||
|
|
||||||
|
- some name_format bug
|
||||||
|
|
||||||
|
### Change
|
||||||
|
|
||||||
|
- doing: change render pip line ('m really doing)
|
||||||
|
- default FPS from 120 -> 60
|
||||||
|
|
||||||
|
### Add
|
||||||
|
|
||||||
|
- add performance_test folder
|
||||||
|
- add some performances test
|
||||||
|
|
||||||
## 2021/05/24 V 0.4.2
|
## 2021/05/24 V 0.4.2
|
||||||
|
|
||||||
|
33
performance_test/test_for_speed.py
Normal file
33
performance_test/test_for_speed.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# test of "for" speed
|
||||||
|
# R5 5600X 16*2GB DDR4 3200
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
from pprint import pprint
|
||||||
|
TPS = 60
|
||||||
|
SPT = 1 / TPS
|
||||||
|
|
||||||
|
list_num = 100
|
||||||
|
test_list = {}
|
||||||
|
for x in range(list_num):
|
||||||
|
test_list[x] = [random.random()]
|
||||||
|
time_list = {}
|
||||||
|
|
||||||
|
times = 100
|
||||||
|
t = 0
|
||||||
|
start_t = time.time()
|
||||||
|
while t < times:
|
||||||
|
s_t = time.time()
|
||||||
|
t += 1
|
||||||
|
for x in test_list:
|
||||||
|
if test_list[x][0] > 0.5:
|
||||||
|
print('y', end=' ')
|
||||||
|
else:
|
||||||
|
print('n', end=' ')
|
||||||
|
pass
|
||||||
|
print(t, end='\n')
|
||||||
|
e_t = time.time()
|
||||||
|
time_list[t] = [s_t, e_t, e_t-s_t]
|
||||||
|
end_time = time.time()
|
||||||
|
pprint(time_list)
|
||||||
|
pprint(test_list)
|
||||||
|
print(start_t, end_time, end_time-start_t)
|
31
performance_test/test_speed_of_sprite.py
Normal file
31
performance_test/test_speed_of_sprite.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
|
import pyglet
|
||||||
|
|
||||||
|
window = pyglet.window.Window(resizable=True)
|
||||||
|
|
||||||
|
ball_image = pyglet.image.load('/DR/textures/Atmospheres.png') # 可自定义材质
|
||||||
|
batch = pyglet.graphics.Batch()
|
||||||
|
|
||||||
|
ball_sprites = []
|
||||||
|
start_t = time.time()
|
||||||
|
for i in range(1500): # 可自定义数量
|
||||||
|
x, y = i * 10, 50
|
||||||
|
ball_sprites.append(pyglet.sprite.Sprite(ball_image, x, y, batch=batch))
|
||||||
|
end_t = time.time()
|
||||||
|
print(start_t, end_t, end_t-start_t)
|
||||||
|
|
||||||
|
a = 0
|
||||||
|
@window.event
|
||||||
|
def on_draw():
|
||||||
|
start_t = time.time()
|
||||||
|
if a:
|
||||||
|
for x in ball_sprites:
|
||||||
|
x.draw()
|
||||||
|
else:
|
||||||
|
batch.draw()
|
||||||
|
end_t = time.time()
|
||||||
|
print(start_t, end_t-start_t)
|
||||||
|
print(end_t, pyglet.clock.get_fps(), 'fps')
|
||||||
|
|
||||||
|
pyglet.app.run()
|
Loading…
Reference in New Issue
Block a user