Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PenneyGadget/31b6399bb54fc2e77e2afbf66d5f02e7 to your computer and use it in GitHub Desktop.
Save PenneyGadget/31b6399bb54fc2e77e2afbf66d5f02e7 to your computer and use it in GitHub Desktop.

This was so fun to watch!

  • What is one approach you can take from Mary's code and implement in your project?

Space Invaders is very different from what Beth and I are building, however I think the concept of the 5 checks for collison detection are invaluable and can be applied in all sorts of scenarios. These 5 checks tell us that 2 objects are NOT colliding if:

  1. object1 is the same as object2
  2. the right-most side of object1 is to the left of the left-most side of object2
  3. the left-most side of object1 is to the right of the right-most side of object2
  4. the top side of object1 is below the bottom side of object2
  5. the bottom side of object1 is above the top side of object2

Beth and I could potentially implement our checks for a winning pattern by using similar logic. We opted instead to determine a winning puzzle by matching the orientation of each piece to it's "winningOrientation" (a property we set on the object at it's creation). But I feel like I will use the logic of collision detection in the future and I think it's super cool to know (I thought collision detection sounded terrifyingly complicated and was sure I wouldn't understand it. It was nice to have it laid out in such an understandable way).

I also really liked the way Mary created the tick funciton that instructs the game to update and draw itself. Beth and I may be too far down our own path now, but we sort of have a set up like this and, as we refactor, it seems our lay out is getting closer to this concept. I think ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment