在弯曲的交叉点阻挡球? [Java]
我想在我的太空飞船前面有一个弯曲的盾牌来阻挡传入的攻击。
关于如何使用图像并使其仅检测像素的位置或类似的东西有什么想法吗?即使我有两个对象,一个是图像,另一个是曲线之类的东西,这应该是可能的,对吧?谢谢!
I want to have a curved shield in front of my space ship to block incoming attacks.
Any ideas on how to use an image and make it only detect where the pixels are or something similar? Even if I have two objects, being the image and something else like a curved line, this should be possible right? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在真正的 MVC(模型-视图-控制器)设计中,您将拥有一个仅描述您的宇宙飞船所在位置的模型,或许还有一个描述您的护盾的数学公式。然后视图组件基于此绘制图像。如果您检查碰撞,则无需处理像素。您可以计算射击的路径(例如自游戏引擎的最后一个周期以来射击移动的路径,该路径仅覆盖毫秒),然后使用简单的数学检查它是否与任何物体发生碰撞。
In a real MVC (Model-View-Controller) design you would have a model that just describes where your spaceship is and perhaps a math formula describing your shield. Then the view component draws images based on that. If you check for collision you don't need to work on pixels. You can calculate the path of a shot (like the path the shot has moved since the last cycle of your game engine which will only cover milliseconds) and then check whether it collided with anything using plain math.
这个弹性碰撞的动力学模型采用了 MVC 设计,本文介绍了二维弹性碰撞可能具有指导意义。
This kinetic model of elastic collisions uses an MVC design, and this paper on 2-Dimensional Elastic Collisions may be instructive.