show FPS!
This commit is contained in:
parent
5113a801c1
commit
07735dc30f
@ -74,6 +74,9 @@ class window(pyglet.window.Window):
|
|||||||
self.SPF = 1.0 / self.FPS
|
self.SPF = 1.0 / self.FPS
|
||||||
self.view = 'space'
|
self.view = 'space'
|
||||||
self.net_mode = net_mode
|
self.net_mode = net_mode
|
||||||
|
# FPS
|
||||||
|
self.max_fps = self.FPS
|
||||||
|
self.min_fps = self.FPS
|
||||||
# configs
|
# configs
|
||||||
self.lang = tools.config('sys_value/lang/%s.json5' % language)
|
self.lang = tools.config('sys_value/lang/%s.json5' % language)
|
||||||
self.view = tools.config('configs/view.json5')
|
self.view = tools.config('configs/view.json5')
|
||||||
@ -92,7 +95,7 @@ class window(pyglet.window.Window):
|
|||||||
self.textures = {}
|
self.textures = {}
|
||||||
# setup
|
# setup
|
||||||
self.setup()
|
self.setup()
|
||||||
pyglet.clock.schedule_interval(self.update(), self.SPF)
|
pyglet.clock.schedule_interval(self.update, self.SPF)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
# net_mode
|
# net_mode
|
||||||
@ -114,13 +117,18 @@ class window(pyglet.window.Window):
|
|||||||
|
|
||||||
# draws
|
# draws
|
||||||
|
|
||||||
def update(self):
|
def update(self, ree):
|
||||||
self.info_label.x = random.randint(100, 500)
|
now_FPS = pyglet.clock.get_fps()
|
||||||
self.info_label.y = random.randint(100, 500)
|
if now_FPS > self.max_fps:
|
||||||
|
self.max_fps = now_FPS
|
||||||
|
elif now_FPS < self.min_fps:
|
||||||
|
self.min_fps = now_FPS
|
||||||
|
self.info_label.text = 'now FPS: %03d \n max FPS: %02d \n min FPS: %02d' % (now_FPS, self.max_fps, self.min_fps)
|
||||||
|
self.info_label.anchor_x = 'left'
|
||||||
|
self.info_label.anchor_y = 'top'
|
||||||
|
|
||||||
def on_draw(self):
|
def on_draw(self):
|
||||||
self.draw_batch()
|
self.draw_batch()
|
||||||
print(time.time())
|
|
||||||
|
|
||||||
def draw_batch(self):
|
def draw_batch(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user