Simple mine idle game javaScript examples
It has been a while sense the last time I made a simple javaScript project examples type post, so today I thought I would put something together real fast that I might put some more time into if I think it is something that is worth more time. The aim here is to not do anything fancy, just get together some javaScript code that will serve as a basic starting point for a simple idle game type project. This is not the first time I have made such a project, but maybe this time I will finally break old habits and continue working on this as a separate stand alone project rather than just a little javaScript code.
The main feature that I have in mine here is to just have a module that will create an instance of a kind of standard mine object. Each mine object will contain properties that defile what ores there are to obtain at the mine, and also the current state of a ship that will move back and forth from the mine. So the mine module is then use to create one of these mine objects, and update the state of the object when it comes to the position of the ship, the rate at which resources are mined, and create to a main home object. Speaking of the main home object I will also want at least that kind of module also that will be used to create and update that also.
1 - The mine module
First off I have my mine module that I will be using to create an object that will represents a single mine. Each mine in the game will have a single space ship that moves from the location of the mine to a home base location and back again over and over again. Each time it will end up at the mine it will load some some ore, and each time it comes back home it will unload that ore.
|
|
2 - The home object module
I will want to have some kind of main game state object, for this I have a module that will create and return that object. So then this module has a main create method that I will use in the main javaScript file to create a new main home object with the create method of this module. When I do so I can pass some data that will serve as a way to set up what all the ores are for the game.
|
|
3 - Conclusion
That will be it for now when it comes to this javaScript example, at least until I get around to editing this post and when I do so maybe I will put a little more time into the source code also while I am at it. I can not say that I get around to doing that with all of these posts, but some are more deserve of more time and energy than others. This one might be different if I do manage to break the cycle of starting projects like this but never really finishing them. There are a lot more things that I would like to get done with this one, but still only so many, I would like to keep this one fairly simple.