Sort planets javaScript example

I have wrote a post on the array sort method before hand, and the general idea I have in mind now is to have at least a one if not more javaScript example posts that help to show why the array sort method is useful. Very basic examples are helpful, but they do not help to get people to really understand the connection between the array sort method, and something that is at least starting to look like some kind of project that is fun, interesting or useful. Sorting an array of objects is something that will come up often in javaScript so I thought I would make a fun little javaScript project that would be an example of why sorting is helpful.

This javaScript example will not be a full game, but it will be one little mechanic that could be used in a full game that will of course make use of array sort. Say you have an array of objects, and each object is a planet in some kind of game that has to do with taking over planets. Anyway there would be a lot of code that would need to be written to make a fun little planet attack game, but one feature that I would want is to have a method where I can give a position, and get a list of planets where the first planet in the list is the one that is the closest to that position. This javaScript example will then just be this one little aspect of game development using javaScript, I will also put together some additional code that will be a very basic canvas display.

Read More

The javaScript module object literal pattern

So there are many patterns and standards when it comes to javaScript modules these days. Just when it comes to making them the tired yet true way in a es5 spec javaScript kind of way things can quickly spiral down in to a major rabbit hole when it comes to the various patterns, and standards with old school style javaScript. Then there is of course the new ways to go about making javaScript modules in modern javaScript specs when it comes to using import and export.

However if you are new to javaScript module design, you have to start somewhere, and maybe a good starting point would be to just start playing around with plain old object literals as a javaScript module pattern in client side javaScript. This might not be the best way to go about making modules in javaScript, but it sure is a good first step in the right direction if you are not sure where to start. Also in some cases the pattern will still work okay in some situations in which I am making a client side module in which it is okay to make everything public. Also I can still wrap things up into an IIFE when it comes to making a single property value for a public key of the main object literal that will compose such a module.

Read More

Skill Point system

I have found that a component that I would like to have in many game projects that I might start, or improve in time would be a skill point system. This skill point system as I have come to call it would be a way to gain skill points in a game, and then have a way to invest these skill points into upgrades. The upgrades in turn would then increase stats for various items in a main game state object. So maybe it would be a good idea to start one or more javaScript examples in which I explore, and refine this narrow little topic when it comes to javaScript game design.

What I have in mind is a system that is a more advanced version of the experience point system that I made a while back. So my skill point system will be more or less the same thing as that at the core of it, but with maybe one additional public method that can be used as a way to create values that are based off of a level object of the experience point system, and a skill point value. In time I might make additional skill point systems that are there own independent thing, that may of may not be a better way of doing things, but as far as this post is concerned this is the system that I will be writing about here.

So in this post I will be writing about another kind of experience point system, but with this additional feature that can be used as a way to create stat values with a level object, and a skill point value from zero to positive infinity. This will not be a post in which I will be going over every little detail when it comes to using a module like this in an actual project though. However I will be going over a simple demo that will make use of it just for the sake of getting an idea how this will work as a player levels up in a game.

Read More

Monster Smash canvas game example

I will be making at least a few more canvas examples this summer, some of which I might continue developing if some people show interest in them. Last week I started working on one of many game prototype ideas that I am currently just calling Monster Smash. The general idea is not clear, aside from just some very vague concepts that have to do with just moving a player object inside a grid, and have enemies come to the location. I am thinking somewhat in terms of a kind or RPG style game like Dragon Warrior, the early Pokemon games, or some like of Roguelike game, but I am not so sure yet. That is okay though I can ways fork off of what I work out here as long as I get the very basic idea of what I want working.

I would like to have at least one canvas example that is just a nice little RPG style game where you move a player object around and battle enemies and level up. Nothing to ground breaking or exciting, just a nice little RPG like that of dragon warrior maybe.

Read More

grid game unit movement javaScript example

So this week I started working on a new canvas example prototype, and the very first minor release of the prototype thus far strikes me as something good to write about as a simple stand alone javaScript example post. Thus far it is just a simple example of having a grid, and having a player unit move around in the grid when a player clicks on a given cell location. The basic idea that I have together thus far with it could be taken in a whole range of different directions when it comes to making it into something that is more of a game beyond that of what I have in mind for the canvas example prototype. So I thought I would copy and past the source code over to another location and maintain it as just a simple starting point for a grid type game that involves moving a unit around a simple grid.

I have made many projects in the past that involve the use of a grid in one form or another such as my grid defense canvas example, I also have another canvas example when it comes to creating and drawing grids in general with canvas. Shortly after I wrote this post for the first time I made another example where the aim is to make a grid module that can be used over and over again from one project to another rather than making a custom solution for a single project or examples such as the case with this example that I am writing about here. The problem with that as I see it s far is that making a grid module is something that I never seem to get just right, so I need to keep making new ones. So maybe some times it is a good idea to just create a custom grid module on a project by project basis rather than trying to make some kind of magic grid module that will work well in every possible project.

However in this one I have an idea that I have not done yet with grids, and would like to move forward with it. Also in this post I am touching base on a lot of other topics when it comes to starting a foundation to which I will build on top of when it comes to making a real project rather than just yet another simple javaScript code example. This is a cycle that I would very much like to break at some point in my life.

It may seem as a very simple, trivial example, and for a veteran javaScript developer I suppose it is. However there are still many topics that are covered when it comes to just getting to this simple starting point, and also even when it comes to being an experienced javaScript developer there is the topic of how to go about structuring a complex projects that might at one point in the future consist of thousands of lines of code. This is a topic that I still strugle with even though I have many years of experience thus far. So then this should prove to be a nice little starting point for a simple game that involves a player controlled unit, so lets take a look at the source code.

Read More