I polygon and done it

Today on Devember day 10 we finally run into the (probably common) issue of finding the time to write code for at least an hour (easy) and write a dev entry about it (sometimes tricky).

Today’s repository contributions involved adding some new engine functionality and creating a new Entity subclass which represents the pill bottle in the game and which will hold the bulk of the game logic; or at least, the parts of it having to do with the pill segments in the bottle contents.

To be more specific about the changes that were made to the core engine code in the engine branch of the repository:

  • Actually finish fixing the “bug” alluded to yesterday with regards to MouseEvent/KeyboardEvent replacing usages of generic Event in method signatures. It turns out that I actually just fixed the methods in the Stage class; that’s not useful, but the actual methods in the Scene class are fixed now too.
  • Allow the mouse input handling to stop event bubbling. In particular, the keyboard events have always been handled with methods that return a boolean to indicate if they were handled or not; in Stage, if the Scene says it handled the event, the event propagation stops and no other default handling is done. Now the mouse input does the same thing.
  • The Point class has a new API extension; Point.toArray()/Point.setToArray() which return an array representation of the point and set values from an array, respectively. These are extensions provided because of the last thing in the list, which is
  • The Renderer interface (and the concrete CanvasRenderer implementation) now have a Renderer.fillPolygon() method. This takes an array of arrays of points and simply connects them together and fills them. This is a generic version of the code previously implemented to render the virus segment representations.

On the Rx front, the only visual change is that now that there is a bottle entity, it renders itself around the contents of the bottle.

Simple screenshot showing bottle rendering currently implemented

Third Devember Dr. Mario clone Screenshot; let there be bottle

This actually represents a lot of encapsulation of the various data members that were previously crammed into the GameScene class for initial testing, separating things and making the code altogether more clear.

With these last changes, actual game development can happen in earnest. The plan for tomorrow is to extend the debug glue logic a bit so that instead of toggling bottle contents on click, which is what happens now, we can instead pick and place pieces to put into the bottle contents. With that done I can start in on the logic of things such as gravity for the capsule segments inside the bottle and possibly some matching as well.

We’ll see what the day brings.