简体   繁体   English

为什么我的碰撞在 pygame 中不起作用?

[英]Why is my collision not working in pygame?

This post is part of the Color Meaning Blog Series, detailing the meanings associated with colors such as red, orange, yellow, green, blue, purple, grey, black, white, brown, pink, turquoise, gold, silver, and beige.这篇文章是颜色含义博客系列的一部分,详细介绍了与 colors 相关的含义,例如红色、橙色、黄色、绿色、蓝色、紫色、灰色、黑色、白色、棕色、粉红色、绿松石色、金色、银色和米色。

Yellow, the color of sunshine, hope, and happiness, has conflicting associations.黄色,阳光、希望和幸福的颜色,有着相互矛盾的联想。 On one hand yellow stands for freshness, happiness, positivity, clarity, energy, optimism, enlightenment, remembrance, intellect, honor, loyalty, and joy, but on the other, it represents cowardice and deceit.一方面,黄色代表新鲜、幸福、积极、清晰、活力、乐观、启蒙、纪念、智慧、荣誉、忠诚和快乐,但另一方面,它代表懦弱和欺骗。 A dull or dingy yellow may represent caution, sickness, and jealousy.暗淡或暗淡的黄色可能代表谨慎、疾病和嫉妒。

Studies show that the meaning of the color yellow can be warmth, cheerfulness, increased mental activity, increased muscle energy.研究表明,黄色的含义可以是温暖、快乐、增加心理活动、增加肌肉能量。 The color yellow helps activate the memory, encourage communication, enhance vision, build confidence, and stimulate the nervous system.黄色有助于激活 memory,鼓励交流,增强视力,建立信心并刺激神经系统。

i am no python programmer but just looking at your collide function我不是 python 程序员,但只是看着你的碰撞 function

assuming that your colliding base on distance between 2 points on a 2D plane假设您的碰撞基于 2D 平面上 2 个点之间的距离

after getting the distance, you did a (distance mod the sqrt of 2).得到距离后,你做了一个(距离 mod the sqrt of 2)。

a mod get your the remainder of a division, to be exactly 0 means that your number will be a multiple of sqrt2, and since in computer science a floating point 0 is almost impossible to get due to how floating points values is stored.一个 mod 得到你除法的余数,正好是 0 意味着你的数字将是 sqrt2 的倍数,并且由于在计算机科学中,由于浮点值的存储方式,几乎不可能得到浮点 0。

and after your check whether formula is getting your 0 OR an negative number.在您检查公式是否得到您的 0 或负数之后。 since sqrt will never get a negative value from your distance formula for your collide to be true it has to be 0.因为 sqrt 永远不会从距离公式中得到负值,所以碰撞为真,它必须为 0。

suggestion for change, after getting the distance,拉开距离后的改变建议,

Do a check whether it falls within a RANGE with each, if it is true, else false.检查它是否在每个范围内,如果为真,否则为假。

google: circle to point collision, my syntax maybe wrong as i am a primarily c programmer,hope it helps谷歌:圆点碰撞,我的语法可能错误,因为我主要是 c 程序员,希望它有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM