One method that I have in here is a method similar to that of the lodash get method where I can pass an object, then a string that is a path to a value in that object, and then an optional default value to return in the vent that there is not a value at that path location. Another method that I have here is a kind of get a value within a range by a number between 0 and 1 method. This is another kind of method that helps with something that seems to happen fairly often when making this kind of a project. That is that I give the method a value between 0 and 1, which can also be the result of a Math random call, and then the next values are a range of values, a kind of min and max so that they return value is the per value that is between these values.
I then have a number of typical methods that I use in almost every project like this such as a mathematical module method, and distance and bounding box method. I also have a few methods that have to do with working with angles.
In revision 1 of this example I made an improved object pool library that I will likely use for future projects moving forward as a like it a lot more compared to the library that I based this off of. With my canvas example on object pools I started a library for this kind of thing that I kept copying over to other projects, each time I did so I might not change much of anything to it, other times I made improvements and added features. However with this object pool library I decided to give it a new name to help really set this one apart from the others by calling in pool normalized.
By normalized I mean thinking in terms of having a point in 2d space first and for most rather than a 2d box object with a width and height that is to be place somewhere relative to the upper left corner of the object, which was the nature of the older object pool library.
Yet another major component that I have started with this example and will likely take with me to additional projects is the unit module that I started in this example. I have made a few modules such as this in past projects, but often then end up being coded together with the game module of a project, as such it is something that I found myself writing over and over again with each project. To help put an end to this I made a stand alone units module, complete with a plug in system that will allow for me to septate logic that has to do with specific kinds of units such as units that move, units that just stay in a fixed location, and various other kinds of units such as shots.
The attackers plug in for my units module contains the logic for the units that will spawn from the outside of the canvas and then select a target that is one of the buildings and move it to attack.
I then have the fixed buildings in the center of the canvas so of course I am going to want a units plug in for that as well.
Both the attacker units and the building units will fire shots at each other, so then there will need to be another plug in for the units module that will contain the logic used for a shared object pool of shots.
So then sense most of the logic that has to do with the game is pulled out of the main game module and into units module plug ins that results in a cleaner main game module. This is still the module where I will be creating the main game state object as well as updating such an object.
Sense this is a digital art project of course there is a library that contains a collection of methods that can be used to draw the various aspects of the main game object to the canvas.
I am then just going to need a little more additional logic that will provide a main application loop, and a main state object.
So then this example turned out pretty great, and I was able to get the core idea of what I had in mind up and running pretty fast. As of this writing I have a lot planed out for the rest of the example when it comes to the additional features phase of this example, in time I might complete that phase and have something that is even more interesting than what I have all ready, but I do also have a lot of competing ideas also so we will see if I get to the maintenance phase with this one.
Even if I do not complete the additional features planed out for this example, a whole lot has been created and improved that I will be taking with me to additional examples.