对我的设计 v3 的评论
好吧,在考虑了我在太空入侵者游戏的类图 v1 和 v2 上获得的所有有用评论后,我再次更新了我的类图以实现所有更改。
言归正传,我将介绍 v3:
摘要中的 Move 和 Update 方法 Bullet 类不执行任何操作,方法的实现位于从Bullet 继承的具体类中。这些具体类中的每一个也将从 IMovable 接口继承 Speed 属性,并且每个类都有自己的速度集。整个抽象的Bullet类及其具体的派生类就是策略模式。
我想问一些事情:Ship和Invader类一次只能有一颗子弹 - 但Invader类也可以没有子弹。例如,当所有排的外星人都完好无损时,那么只有第一排的外星人可以发射子弹。他们上面的行无法射击。但是我如何在 Invader 类中实现这一点呢?无法射击的入侵者的Invader类中的bullet变量应该设置还是留为空?或者有更好的选择吗?
我希望我越来越接近获得正确的设计,欢迎您的所有评论!
Well, after taking into consideration all the helpful comments I got on v1 and v2 of my class diagram for the space invader game, I updated my class diagram once again to implement all the changes.
With no further ado, I present v3:
The Move and Update methods in the abstract Bullet class are doing nothing, the implementations of the methods are in the concrete classes that inherit from bullet. Each of these concrete classes will also inherit the Speed property from the IMovable interface, and each will have their own speed set. The whole abstract Bullet class and their concrete class derivatives is the strategy pattern.
Some things I want to ask: The Ship and Invader class can only have one bullet at a time - but the Invader class can also have no bullets. This is e.g. when all the rows of aliens are still intact, then only the first row of aliens can fire bullets. The rows above them are not able to shoot. But how would I implement this in the Invader class? Should the bullet variable in the Invader class of the invaders who are not able to shoot be set or left to null? Or is there a better option?
I hope I am getting closer and closer to getting the right design, all your comments are welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来整个设计可以折叠为以下抽象:
我不确定这是否足以推理你的游戏实施。 《毁灭公爵 3D》也是精灵的集合,它们之间具有某种组合关系。这是否意味着你们的设计与《毁灭公爵 3D》相同?我个人认为该图缺乏完整性和清晰度。那么“游戏板”呢?它如何与 Sprite 交互?物理引擎呢?
只是给你留下一些值得深思的东西。祝你好运!
Looks like the whole design could be collapsed to the following abstraction:
I'm not sure if it's enough to reason about your game implementation. Duke Nukem 3D is also collection of sprites with some kind of composition relationship between them. Does it mean you have the same design as Duke Nukem 3D? I personally feel the diagram lacks completion and clarity. What about "game board"? How does it interact with Sprites? What about physics engine?
Just leaving you with some food for thought. Good luck!