所以我想用pygame编写一个模拟器,但是我卡住了
我试图让粒子落下并沉淀下来,但我希望它们在撞击墙壁时堆叠并停止
这听起来可能令人困惑,因此下面是一个例子:
http://www.coolmath-games.com/0-sugar-sugar/
我想制作类似于上面游戏中的糖的粒子:
我开始尝试:
if pygame.sprite.spritecollideany(self, self.game.block_list):
self.rect.x += 0
self.rect.y += 0
但是这些粒子就会停下来,不会滚下倾斜的表面
我还需要知道如何检查一个精灵是否与它的团队中的任何其他精灵发生碰撞
所以如果有人知道我如何在pygame中复制这种类似液体的粒子运动,那就太棒了!在
谢谢你!在
如上所述,我试图用pygame编写完全相同的游戏,但没有完成。
首先,我不想把这些粒子作为不同的对象来存储。相反,我用字典来存储它们的坐标。我这么做是因为有几百个,你必须检查每一个碰撞每秒50次。如果你试图让它们都是不同的对象,那么在某个时候可能会失去控制。
检测到碰撞后,为了使它们滚下斜面,也让它们沿对角线移动。首先检查下面的单元格,如果该单元格不是空的,请检查粒子左下角和右下角的单元格。
顺便说一句,我发现我的函数可以移动粒子,但它并不可读。在
相关问题 更多 >
编程相关推荐