Introduction to Mocha and Chai



Previously I mentioned that I use Mocha and Chai for testing my JavaScript applications/games. Thanks to these two packages and npm I can have a great testbase for my code which can be run very quickly just by entering npm test (which can be run inside of Emacs eshell or even fired with a key).

Read more

Layered mountains: part II



A third snippet has been added to the Proving ground section: Round layered mountains. As the name says, it generates three round shapes which should resemble 2D mountains. It uses a very naïve combination of sine functions to achieve that effect.

Bad thing is, it's input is very limited (only the offsets of said shapes), because it's difficult to achieve something that looks good using this procedure, most results look artificial. However, all I wanted was to be able to do something similar to what I saw in this image from the Lost Garden's Fishing Girl Challenge. I am pretty sure that those are handmade, but simulating this kind of shapes is very interesting. I hope I can delve deeper into procedural generation to get a grip on how this could be done.

Now I want to be able to draw objects (like those trees in the image) which follow the slope of the shape, I figure it won't be difficult given how it is generated.

New section launched!



I am happy to announce a new subsection of this web: Proving ground. I intend to use it to share code snippets that I consider useful, or to try hacks that I may later use in my games. There are only two snippets so far (one to generate color transitions, and one little experiment to see if I could generate 2D mountains layered against the background, it looks good).

However, I may be uploading more experiments in the following weeks. Stay tuned.

Read more

Web revamped



It's been a while since the last time I published anything, but I have been busy redesigning the web, and tweaking many things.

Read more

On the misuse of the Singleton pattern



The Singleton pattern is known as the most overused and misused pattern among those of the GoF. Thus, I thought it appropriate to devote a whole post to convince those of you who, unknowingly, abuse this pattern to lazily couple your modules/classes and to compromise the flexibility and testability of your code. If you already know the consequences of using a Singleton and have decided to use it anyway, it's up to you.

Read more