```"""

pymunk手册：http://www.pymunk.org/en/latest/pymunk.html

"""
import random
import pymunk
import timeit
import math
import os

SCREEN_WIDTH = 1200
SCREEN_HEIGHT = 800

"""继承自窗口的游戏类 """

def __init__(self, width, height):

self.frames_counter = 0             # 帧计数器

#  Pymunk 重力空间
self.space = pymunk.Space()         # 游戏的重力空间
self.space.gravity = (0.0, -180.0)  # 设置游戏重力空间的重力参数

def spawn(self):

"""产生一枚金币金币"""
size = 45
mass = 1
inertia = pymunk.moment_for_circle(mass, 0, radius, (0, 0))       # 惯性
body = pymunk.Body(mass, inertia)
body.position = pymunk.Vec2d(SCREEN_WIDTH//2,SCREEN_HEIGHT//2)

self.sprite_list.append(sprite)

def on_draw(self):
"""        渲染屏幕.        """

# 记录此帧开始渲染时间
draw_start_time = timeit.default_timer()

# 画所有的角色
self.sprite_list.draw()

# 画地板
for line in self.static_lines:
body = line.body
pv1 = body.position + line.a.rotated(body.angle)
pv2 = body.position + line.b.rotated(body.angle)

# 显示时间
output = f"处理时间: {self.processing_time:.3f}"

output = f"渲染时间: {self.draw_time:.3f}"

self.draw_time = timeit.default_timer() - draw_start_time # 渲染此帧所用时间

def update(self, delta_time):
start_time = timeit.default_timer()
self.frames_counter +=1
if self.frames_counter % 20 == 0 :        self.spawn()

def main():
MyGame(SCREEN_WIDTH, SCREEN_HEIGHT)

if __name__ == "__main__":
main()
```

(会员专属：能浏览所有文章，下载所有带链接的Python资源。)