0
\$\begingroup\$

I have the initial "Game1" class, with a "Ship" class initiated inside, and within the "Ship" class there's a List, where the "Bullet" class is used.

How can I make a bullet in a list from one of the ship classes intersect with a bullet from the other ship's bullet list?

Do I have to make a list of Rectangles too for their hitboxes?

enter image description here

\$\endgroup\$
1
\$\begingroup\$

Generally it's wise to create an object manager if your game is using collisions. The object manager will contain a list of all of your game objects, then check collision between all of them in one go, usually with a function that they all derive from a common parent class. If the objects collide, they then call another function for handling their collision. You can pass in the object it collided with if it has a specific reaction depending on what it collided with.

\$\endgroup\$
  • \$\begingroup\$ Thanks for clarifying how to approach that kind of situation! I'll try to meddle around using that concept. \$\endgroup\$ – Alexandre Laframboise Jul 4 '17 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.