For this project I need a bounding box collection detection method to find out if a cell in the grid has been clicked or not. The rest of the methods that to do with quickly setting up a canvas element, and attaching event handers to it. For now that is more or less just about it, this module does also just serve as a general dumping ground for methods that I will be using across one or more modules, and I can not think of any other place to put the method. Often I might make some new additions when it comes to these kinds of methods, but not for this project it would seem.
Even If I do not work on this project any more one good thing that came out of this is coming up with a nice basic grid module. This is a module that I can use to create a base object for a grid, to which I can then use in my plant grid module that I will be getting to in a later section in this post. For now this module just has three public methods one of which is a create method that will just create and return a grid object. Another public method is to get a cell in the gird given a canvas relative pixel location, and I have another to select or deselect an orb.
When it comes to working out the nature of the grid object I went with a design where I have just an array of objects for each cell. I thought of using bounding box as a way to find what cell was clicked, but decided to instead go with expressions rather than looping.
Here I have the main module of interest when it comes to this game, where I am creating a grid with the grid module, but then creating some custom objects for each cell, and adding additional features that are specific to this game. So then at the top of the module I have a hard coded object that is the beginnings of a hard coded plant database. I then have a public create method to create a plant grid object, and also a main update method of this module that I will be calling to update the state of this grid.
It is a usual practice of mine to have a main game state object module. However when it comes to this game so far there is not much to write about with this module just yet.
This is the current state of the draw module that is used to render things to the canvas element that is used for this.
I then have a main javaScrit file where I have what is the beginnings of a state machine, and the main app loop.
I did not put as much time into this prototype as I would have like to have, mainly because I have been working a lot more on my other prototype that is a game based off of my orb module that I started a while back. In fact the current state of the game prototype that I am just calling orb match for now is a kind part of the project folder for that module. At this time I think this project should be shelfs so I can focus better on that project, however in the event that I get burnt out on that one maybe this project would be a good thing to get back into.
At this time I think I am going to need to focus on just one game at a time, and make these blog posts a weekly rather than daily thing for a while. The full vision of this game might not be that much more complex than what it currently is, but there is still a great deal more to work on with this before the example starts to even look like a done deal. The other project I was working on this week is in far better shape so far, so I will be working more so on that one for a while in the near future.