Path finding with javaScript

In javaScript path finding is a subject that will come up when making certain games and projects that require finding a path from one cell position to another in a 2d grid typically. It is a major part of game development when it comes to any style of game that requires such methods, as well as any kind of practical application also.

There are many game frameworks that might have this built in, there are also well know javaScript dependencies such as pathfinding.js that can be used to make quick work of this aspect of javaScript Game development by making it part of the applications dependences.

However pathfinding.js is a little bloated, it comes with a collection of methods for path finding rather than just one tired yet true solution. It is also true that pathfinding.js no longer appears to be supported, which is not always such a bad thing mind you. It is true that if something is not broken there might very well not be a need to fix it after all, that sort of things happens now and then and that might very well be the case with pathinging.js.

Still there might be a need to work out a custom solution for path finding for a number of other reasons that might come up, including just making something that is a little lighter, so in this post I will be writing about making a custom path finding method in javaScript. I have not tested this solution extensively, but it is based off of what I have studied in pathfinder.js, and in any case it should still serve as a decent starting point for this sort of thing.

Read More

A Canvas Example that is a basic Space Shooter game

So this post might be the first of several canvas examples, this one will be on a basic space shooter game for starters. So this example is just a simple little game that involves a player ship that moves around and shoots at other player ships and that is it. Nothing to interesting maybe, but hey you have to start somewhere when it comes to these.
So then this is a project that I threw together in just a few hours, so it is not really a complete game at the time of this writing at least. I did not get around to polishing every little thing about it, but if this post gets enough traction maybe aI will get around to working on this one a little more. There is much more work to do when it comes to getting this to even start to look like some kind of finished product when it comes to things like at least having a basic menu system, and displaying all player stats of interest. However the initial goal was not to really make a finished product, I just want to get to a very simple starting point.

Still I had some fun with this one, and I might get around to putting more time into the project at some point in the future if this new collection of posts gets some traction.

Read More

Web Storage api in client side javaScript

There are a number of ways to store data on the client side, but in this post I will be mainly writing about the Web Storage API, rather than index db, cookies files, and many other such options for client side persistence of data in a front end javaScript environment.

The Web Storage API is easy to use as everything can just simply be stored as key value pairs of the localSorage global variable on clients that support the Web Storage API. However depending on the nature of the project it might not always be the best choice when storing large amounts of data. The indexed db option is a better choice when it comes to storage of large amounts of data on the clients computer, and cookie files will always give better backward compatibility when it comes to supporting older browsers but with a limited size.

There is also the idea of using the File reader constructor to have it so the user can save and load files anywhere on their computers local file system. So in some projects the file reader constructor might be be the best choice for handing the saving and loading of state, or other assets in general actually.

Still the Web Storage API is a good option for quickly getting the job done, and most modern browsers support the standard well, any one had to start somewhere when it comes to researching what the options are.

Read More

lodash omit method for omitting properties from an object

The lodash omit method can be used to create a new object by omitting properties from an existing object that is give as the first argument. So then the lodash omit method is like the lodash pick method only it creates a new object by omitting properties that are not wanted rather than picking properties that are wanted.

So there is using the lodash omit and or the lodash pick methods as ways to create new objects from other objects, but there are also ways of doing the same with just native javaScript itself. So in this post I will not juts be taking a quick look at the lodash methods for this, but also touch base on some additional solutions that do not make use of lodash.

Read More

Linux ps command and scripting with nodejs

So today I am taking a look at the Linux ps command. This command can be used to get a snapshot of all the processes running on Linux at the moment that the command is called. Helpful information about each process running in a selection is included in the output including a process id that can be used with other commands such as the kill command to halt a process. There are also ways of changing what the format of this output, and there are also a number of ways to set what processes to select as well.

Although the ps command is like that of the task manager in windows it does not have all the functionality that you might expect. For example if you want to kill a process that is hanging you can not do that with the ps command. However you can use the ps command to get a pid that you can then use with the kill command to end that hanging process.

The ps command is then a great basic tool to help in the process of learning a thing or two about all of the software that is running on your Linux system. Again just like that of using the task manager in windows to see the names of the process you can then research more on what each of those process dames actually do.

In this post I will be going over some typical examples of the Linux ps command, that have to do with selecting all process, processes for a user, and just instances of a single command. I will also then want to write about any and all additional topics that might come up while I am at it because this is major deal kind of command.

Read More