Skip to content

v0.2 Update

SolarLune edited this page Sep 30, 2018 · 2 revisions

Yo! So here's another update with more major changes!

  • Changing resolv.go to use pointer references more. This should avoid making copies of data when passing them around from function to function. That was useful to have, but it can be expensive when dealing with a lot of Shapes at a time, as it means it has to allocate memory to create new Shapes all of the time.

  • As a result, adding Shape.WouldBeColliding(). This allows you to easily see if moving a Shape by delta values would make it collide with another given Shape. This is used extensively by the Resolve() functions. Basically, it just shortens this process:

r.X += dx
r.Y += dy
isColliding := r.IsColliding(other)
r.X -= dx
r.Y -= dy

into this:

isColliding := r.WouldBeColliding(other, dx, dy)
  • Changing the Resolve() functions to work with this in mind (rather than making copies of Shapes to test, it moves them into place, gets the collision check result, and the Shape moves itself back). That means the main Resolve() function doesn't work with absolute positions anymore, really.

  • Exposing the generic resolve() function (renaming to Resolve()).

  • Changing Shapes' IsColliding() functions to avoid using IsCollideable() when possible.

  • Getting rid of the Shapes' Resolve() functions. There's not really a situation I can think of that would necessitate you to resolve a Shape against one single other one specifically, and if there is, then you can just use resolv.Resolve(), as mentioned above.

  • Adding a "touch" visualization to world1. Now when boxes touch each other, they light up.

  • Fixing the Worlds to abide by the slightly different API.

Clone this wiki locally