V0.2!
This commit is contained in:
parent
d6cd82a140
commit
4e5f74c414
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
### Version
|
### Version
|
||||||
|
|
||||||
0.1 (developing and have no DEMO)
|
0.2 (developing and have no DEMO)
|
||||||
|
|
||||||
中文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)
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ class window(pyglet.window.Window):
|
|||||||
pyglet.resource.reindex()
|
pyglet.resource.reindex()
|
||||||
# dic
|
# dic
|
||||||
self.button_hitbox = {}
|
self.button_hitbox = {}
|
||||||
|
self.button_show = {}
|
||||||
self.ships = {} # all ship(part)
|
self.ships = {} # all ship(part)
|
||||||
self.planet_system = tools.config('sys_value/planet.json5') # hole planet system
|
self.planet_system = tools.config('sys_value/planet.json5') # hole planet system
|
||||||
# list
|
# list
|
||||||
@ -111,7 +112,6 @@ class window(pyglet.window.Window):
|
|||||||
def setup(self):
|
def setup(self):
|
||||||
# values
|
# values
|
||||||
self.zoom = -1
|
self.zoom = -1
|
||||||
self.add_part = -1
|
|
||||||
# net_mode
|
# net_mode
|
||||||
if self.net_mode == 'local':
|
if self.net_mode == 'local':
|
||||||
pass
|
pass
|
||||||
@ -125,17 +125,21 @@ class window(pyglet.window.Window):
|
|||||||
# runtimes textures
|
# runtimes textures
|
||||||
self.textures['runtime'] = {}
|
self.textures['runtime'] = {}
|
||||||
runtimes = tools.config('sys_value/runtime.json5')
|
runtimes = tools.config('sys_value/runtime.json5')
|
||||||
|
# load textures
|
||||||
for runtime in runtimes['textures']:
|
for runtime in runtimes['textures']:
|
||||||
path = runtimes['textures'][runtime]
|
path = runtimes['textures'][runtime]
|
||||||
runtime_image = pyglet.resource.image(path)
|
runtime_image = pyglet.resource.image(path)
|
||||||
self.textures['runtime'][runtime] = runtime_image
|
self.textures['runtime'][runtime] = runtime_image
|
||||||
|
# load button's textures
|
||||||
for runtime in runtimes['button']:
|
for runtime in runtimes['button']:
|
||||||
path = runtimes['button'][runtime]
|
path = runtimes['button'][runtime]
|
||||||
runtime_image = pyglet.resource.image(path)
|
runtime_image = pyglet.resource.image(path)
|
||||||
runtime_sprite = pyglet.sprite.Sprite(img=runtime_image, batch=self.runtime_batch, x=self.width + 1,
|
runtime_sprite = pyglet.sprite.Sprite(img=runtime_image, batch=self.runtime_batch, x=self.width + 1,
|
||||||
y=self.height + 1)
|
y=self.height + 1)
|
||||||
self.textures['runtime'][runtime] = runtime_image
|
# self.textures['runtime'][runtime] = runtime_image
|
||||||
self.textures['runtime'][runtime + '_sprite'] = runtime_sprite
|
self.textures['runtime'][runtime] = runtime_sprite
|
||||||
|
self.button_hitbox[runtime] = [runtime_image.width, runtime_image.height]
|
||||||
|
self.button_show[runtime] = -1
|
||||||
|
|
||||||
# info_label
|
# info_label
|
||||||
self.info_label = pyglet.text.Label(text='test %s' % pyglet.clock.get_fps(),
|
self.info_label = pyglet.text.Label(text='test %s' % pyglet.clock.get_fps(),
|
||||||
@ -147,6 +151,7 @@ class window(pyglet.window.Window):
|
|||||||
|
|
||||||
def update(self, ree):
|
def update(self, ree):
|
||||||
self.FPS_update()
|
self.FPS_update()
|
||||||
|
self.hit_box_update()
|
||||||
|
|
||||||
def FPS_update(self):
|
def FPS_update(self):
|
||||||
now_FPS = pyglet.clock.get_fps()
|
now_FPS = pyglet.clock.get_fps()
|
||||||
@ -162,6 +167,13 @@ class window(pyglet.window.Window):
|
|||||||
self.info_label.text = 'now FPS: %03d max FPS: %02d min FPS: %02d' % (
|
self.info_label.text = 'now FPS: %03d max FPS: %02d min FPS: %02d' % (
|
||||||
now_FPS, self.max_fps[0], self.min_fps[0])
|
now_FPS, self.max_fps[0], self.min_fps[0])
|
||||||
|
|
||||||
|
def hit_box_update(self):
|
||||||
|
for hit_box in self.button_hitbox:
|
||||||
|
box_ = self.button_hitbox[hit_box]
|
||||||
|
button = self.textures['runtime'][hit_box]
|
||||||
|
box = [button.x, button.y, button.x + button.width, button.y + button.height]
|
||||||
|
self.button_hitbox[hit_box] = box
|
||||||
|
|
||||||
def on_draw(self):
|
def on_draw(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
self.build_draw()
|
self.build_draw()
|
||||||
@ -184,27 +196,28 @@ class window(pyglet.window.Window):
|
|||||||
while back < self.width:
|
while back < self.width:
|
||||||
self.textures['runtime']['toolbar_light'].blit(x=back, y=0)
|
self.textures['runtime']['toolbar_light'].blit(x=back, y=0)
|
||||||
back += self.textures['runtime']['toolbar_light'].width
|
back += self.textures['runtime']['toolbar_light'].width
|
||||||
self.textures['runtime']['to_menu_sprite'].x = 20
|
self.textures['runtime']['to_menu'].x = 20
|
||||||
self.textures['runtime']['to_menu_sprite'].y = tool_y
|
self.textures['runtime']['to_menu'].y = tool_y
|
||||||
self.textures['runtime']['add_part_sprite'].x = 100
|
self.textures['runtime']['add_part'].x = 100
|
||||||
self.textures['runtime']['add_part_sprite'].y = tool_y
|
self.textures['runtime']['add_part'].y = tool_y
|
||||||
self.textures['runtime']['stage_sprite'].x = 180
|
self.textures['runtime']['stage'].x = 180
|
||||||
self.textures['runtime']['stage_sprite'].y = tool_y
|
self.textures['runtime']['stage'].y = tool_y
|
||||||
self.textures['runtime']['zoom_sprite'].x = 260
|
self.textures['runtime']['zoom'].x = 260
|
||||||
self.textures['runtime']['zoom_sprite'].y = tool_y
|
self.textures['runtime']['zoom'].y = tool_y
|
||||||
if self.zoom != -1:
|
if self.button_show['zoom'] != -1:
|
||||||
self.textures['runtime']['zoom_in_sprite'].x = 260 - 40
|
self.textures['runtime']['zoom_in'].x = 260 - 40
|
||||||
self.textures['runtime']['zoom_in_sprite'].y = tool_y + 25 + 50
|
self.textures['runtime']['zoom_in'].y = tool_y + 25 + 50
|
||||||
self.textures['runtime']['zoom_out_sprite'].x = 260 + 40
|
self.textures['runtime']['zoom_out'].x = 260 + 40
|
||||||
self.textures['runtime']['zoom_out_sprite'].y = tool_y + 25 + 50
|
self.textures['runtime']['zoom_out'].y = tool_y + 25 + 50
|
||||||
else:
|
else:
|
||||||
self.textures['runtime']['zoom_in_sprite'].x = self.width + 1
|
self.textures['runtime']['zoom_in'].x = self.width + 1
|
||||||
self.textures['runtime']['zoom_out_sprite'].x = self.width + 1
|
self.textures['runtime']['zoom_out'].x = self.width + 1
|
||||||
|
|
||||||
# //todo 把所有要素都加进来+整个设置图标+布局
|
# //todo 把所有要素都加进来+整个设置图标+布局
|
||||||
|
|
||||||
def space_draw(self):
|
def space_draw(self):
|
||||||
# render parts
|
# render parts
|
||||||
|
|
||||||
for ship in self.ships:
|
for ship in self.ships:
|
||||||
# get ship poi
|
# get ship poi
|
||||||
ship_poi = ship['brain'][3]
|
ship_poi = ship['brain'][3]
|
||||||
@ -225,10 +238,15 @@ class window(pyglet.window.Window):
|
|||||||
def on_mouse_press(self, x, y, button, modifiers):
|
def on_mouse_press(self, x, y, button, modifiers):
|
||||||
print(x, y, button, modifiers)
|
print(x, y, button, modifiers)
|
||||||
if button == mouse.LEFT:
|
if button == mouse.LEFT:
|
||||||
self.logger.info('左键!')
|
self.logger.info('左键! 在 x:%s y:%s' % (x, y))
|
||||||
self.zoom *= -1
|
for hit_box in self.button_hitbox:
|
||||||
|
box = self.button_hitbox[hit_box]
|
||||||
|
if (box[0] <= x <= box[2]) and (box[1] <= y <= box[3]):
|
||||||
|
self.button_show[hit_box] *= -1
|
||||||
|
self.logger.info('%s 被左键点击 显示状态为:%s' % (hit_box, self.button_show[hit_box]))
|
||||||
|
break
|
||||||
elif button == mouse.RIGHT:
|
elif button == mouse.RIGHT:
|
||||||
self.logger.info('右键!')
|
self.logger.info('右键! 在 x:%s y:%s' % (x, y))
|
||||||
|
|
||||||
def on_key_press(self, symbol, modifiers):
|
def on_key_press(self, symbol, modifiers):
|
||||||
print(symbol, modifiers)
|
print(symbol, modifiers)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 版本
|
## 版本
|
||||||
|
|
||||||
0.1 (开发.ing 没有DEMO(除非你能管一个乌漆嘛黑的页面+三个东西叫DEMO))
|
0.2 (开发.ing 没有DEMO(除非你能管一个乌漆嘛黑的页面+五个东西叫DEMO))
|
||||||
|
|
||||||
For an English version of readme, please move [here](https://github.com/shenjackyuanjie/Difficult-Rocket).
|
For an English version of readme, please move [here](https://github.com/shenjackyuanjie/Difficult-Rocket).
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
'textures': {
|
'textures': {
|
||||||
'toolbar_dark': 'Editor/ToolbarDark.png',
|
'toolbar_dark': 'Editor/ToolbarDark.png',
|
||||||
'toolbar_light': 'Editor/ToolbarLight.png'
|
'toolbar_light': 'Editor/ToolbarLight.png',
|
||||||
|
'trash_can': 'Editor/TrashCan.png'
|
||||||
},
|
},
|
||||||
'button': {
|
'button': {
|
||||||
'trash_can': 'Editor/TrashCan.png',
|
|
||||||
'rotate': 'Editor/RotateButton.png',
|
'rotate': 'Editor/RotateButton.png',
|
||||||
'add_part': 'Editor/ToolbarIconAddPart.png',
|
'add_part': 'Editor/ToolbarIconAddPart.png',
|
||||||
'to_menu': 'Editor/ToolbarIconMenu.png',
|
'to_menu': 'Editor/ToolbarIconMenu.png',
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
'caption': 'Simple Rocket {version}',
|
'caption': 'Simple Rocket {version}',
|
||||||
// {version} -> version of SR
|
// {version} -> version of SR
|
||||||
'caption_option': {
|
'caption_option': {
|
||||||
'{version}': '0.1'
|
'{version}': '0.2'
|
||||||
},
|
},
|
||||||
'resizable': 'true',
|
'resizable': 'true',
|
||||||
// bool
|
// bool
|
||||||
|
Loading…
Reference in New Issue
Block a user