1说明:
1。1中英文介绍:
Pymunkisaeasytousepythonic2dphysicslibrary
pymunk是一个易于使用的pythonic2d物理库
1。2多基于pygame和pyglet的动画。
1。3官网示意图:
图1:indexvideo。gif,可以实现
2准备:
2。1官网:http:www。pymunk。orgenlatesthttps:pypi。orgprojectpymunkhttps:github。comviblopymunk
2。2环境:
华为笔记本电脑、深度deepinlinux操作系统、谷歌浏览器、python3。8和微软vscode编辑器。
2。3安装:pipinstallpymunk本机安装,且推荐国内源安装sudopip3。8installpymunkihttps:mirrors。aliyun。compypisimple
3官方example:
arrow
bouncingballs
4拿官网的动画gif来讲解:
4。1图1:indexvideo。gif,也可以实现,代码量太多了,省略,属于example。
4。2蜘蛛网:spiderweb。py对代码进行修改,注释,bug改进。
5spiderweb。py代码:
提前看看效果图:
5。1第1步:导入模块importmath,randomimportpygletimportpymunkfrompymunk。vec2dimportVec2d
5。2第2步:初始化参数设定configpyglet。gl。Config(samplebuffers1,samples2,doublebufferTrue)windowpyglet。window。...
(全文)