In other words there is just taking a value like 25 and diving it over 100 to get 0.25, and as I increase the first value that is the numerator by one on each update then the value between zero and one will go up in a way in which the change can be graphed as a straight line. Another way of thinking about this is having a box and having a straight line draw from the bottom left corner to the upper left corner. However sometimes I might want things to move or update in a way that would be graphed in a different way than that.
1 - The utility module
So here I made a utilities module with a few methods that take a percentage value as a first argument and returns another percentage as a product. What I had in mind was a function that I can use to turn a percentage value that would otherwise go up in a linear kind of way, and get a percentage value that goes up by way of a curve instead. So I am going to want to just work out a few methods that make use of something like Math.cos, and or Math.log.
Now that I have this out of the way I am now going to want to build a whole lot of code on top of this in order to really get a good idea of how these kinds of methods can effect something. I am thinking some kind of canvas example that has a bunch of display objects that will move around in different ways as a result of the use of these methods. So I will want a module that will be used to create a state object of some kind, another modules to draw aspects of one of these stats to a canvas element, and a little more code to pull this all together.
2 - A Game module that makes use of the methods
So now that I have my utility module I now want to work out a quick module that will make use of the methods in it. I am thinking that I have a module that will create a basic object pool, and then update the positions of the display objects in the pool using these methods that i have worked out in my utility module there.
So then this game module if you can call it that will contain just two public methods one to create a game state object and the other to update such an object. Inside the private area of the module I have an array of methods that are used to update the position of an active display object in the object pool that make used of the two methods that return percent values.
3 - Draw to a canvas element
In just about any module like this I often have a method that will just draw a simple solid color background for the canvas element, and another that will draw some basic debug into to the canvas. For this example though I have a method that will draw the current state of the object pool of a game state object creation with the game module that I went over.
And just a little html to tie it all up together.
5 - Conclusion