Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will probably want to do some refactoring, as having a bunch of public functions in a single class and passing around that many parameters doesn't seem like a manageable solution. </p> <p>I would start by creating a <code>ShotPattern</code> base class or interface, with a class extending or implementing it for each type or category of shot pattern. The logic for how and when to fire bullets, and what kind of bullets to fire, would be handled by the <code>ShotPattern</code>. The <code>ShotPattern</code> could also affect the <code>Bullet</code>s after they are fired, to change their direction or speed, or even produce more <code>Bullet</code>s to create a splitting effect.</p> <p>The constructors for <code>ShotPattern</code>s could still take some parameters; the goal is just to reduce the repetition and keep a larger portion of the bullet generation logic internal to the instance. The <code>func</code> parameter in your <code>FireAroundArc</code> function is clever, and the same idea can be used by creating <code>ShotPattern</code>s that require other <code>ShotPattern</code>s as parameters. </p> <p>Each instance of an <code>Enemy</code> should keep track of its <code>ShotPattern</code>s, which in turn keep track of their <code>Bullet</code>s; that would allow clearing bullets fired by certain enemies, and the bullet creation pattern could move with the enemy.</p> <p>In terms of actually designing enemy attack patterns, there's a lot of possibility and it's a very open-ended problem. Having a solid architecture is important and will allow you to add more complexity without having to change as much existing code, but the general problem of creating patterns that are interesting, varied and challenging is beyond the scope of a Stack Overflow question.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload