Sunday, February 10, 2013

Morf, JavaScript and Laziness

First off, let me begin by saying that Morf will be released very soon. We still have some polishing and balancing to do, but the final release will be out by next Saturday (16th of February). The final version will consist of 20 levels, 5 different level themes, 20 monster types and over 50 items. While you wait, feast your eyes on a screenshot of me playing through endgame content:


Now, allow me to apologize for my absence. Lots of factors contributed to me being too busy to post; day-job stuff, gamedev stuff and my laziness being the largest of those. But nevertheless, I'm back to let you know what I've been up to.

When I started Morf I didn't have a very comprehensive vision of where the game was going (as is mostly the case when I start a game) and as a result of that, lots of the code was not generic enough to suit the growing needs Terri (my artist and teammate) and I have for the game. Specifically, I'm talking about how monster abilities and items are defined.

The amount of monster types and items that need to be defined started to really become an issue. In the original engine, I would define an item something like this:
 add_item(name, model, handler, targeting, value1, value2, type, position);  

And every few days I needed a new parameter passed to the Item object, making the syntax bulkier and bulkier. Not to mention trying to modify any of those values when you have a list of 40 of those declarations were a massive pain. So, I took all the data and put it into a neat document and wrote a parser for it. JavaScript's Duck typing made this really easy to do. Now, I can easily define items and monsters like this:
 weapon
 name|steel axe
 %damage|6
 %durability|5
 %min_lvl|5
 %max_lvl|8 

And the best part is, I can extend the document format and the parser would simply add the new properties to objects due to the fact that you can do this in JavaScript:
 object[property] = value;  

This simple fact alone has been the reason I am starting to love developing games in JavaScript more and more. But I'm rambling.

Check back next weekend and you'll be able to check Morf out for yourself!

2 comments:

  1. Why use your own format and not JSON?

    ReplyDelete
    Replies
    1. This question was posed on Reddit as well so please excuse me pasting my answer from there:

      * I use JSON every day at my day-job so it would feel too much like work
      * I like doing everything myself and feeling completely in control
      * I am busy working on a JavaScript game engine (see previous point) and something like this felt like it fit in nicely.

      Delete