Part 2 – Building a simple JavaScript game

The thought of creating a game is pretty easy.  Ideas for what to put into the game are easy too…  but the ideas never seem to land in order.  Some of the topics you end up thinking about would come much later and some of the prerequisite item are pushed out of your mind.  It is still a really fun exercise to think through and talk through the things, but we will need to coral the thoughts to make progress.

Early Goals of the Game

The early goal is to create a simple game that will be set in a fantasy land like Lord of the Rings.  Not a direct copy of this world of course but some of the same concepts.  We will have a hero that will fight randomly spawned enemies in an automated fashion.  Then we can see how far this hero can make it in the game based on the random interactions with this contrived world.  The hero will have to have a chance to gain health and deal extra damage as he increases the body count of his fallen enemies.  Simple enough on the surface.

Expanding on what we have built

We put together a simple world in the previous article Building a simple JavaScript game and now we need to model our hero.   We will give him a name and a few other essential items, while trying to focus on what is necessary and required to make the early engine function.  The name for my example hero will be Foff as this was the toon name of my character in WoW…  my Horde undead warlock.  He has a name, now he will need some health.

// our hero
var hero = {
	name: "Foff",
	health: 100

Off to a good start but there are now some more complex items that we will begin to factor into the battles of our future foes.  The criteria that make up how our hero will perform in battle and that will help drive some of the random elements of the game.  Quickly our mind begins to complicate things for us as we thing of all the games that we have experienced in the past and how it was done in those.  The thoughts of armor, weapon types, defense stats, offense stats…   ugh.  What do we need?

Initially, I think he needs strength, defense, blocking capability and the ability to perform a critical strike.  That is enough complexity out of the gate to make our character interesting and allow for some items to tune and scale as we progress our hero through battles.  As we run simulations in the future, the more elements we have to consider in the attack calculations, the more complex things will become.  One point change in one criteria could potentially have a cascading effect later on as the battles get calculated.  We will gladly keep it simple for now as we reason about this game and add complexity over time.

Our hero

// our hero
var hero = {
	name: "Foff",
	health: 100,
        crit: 5,
        strength: 10,
        block: 50

It is easy to see how complex this could get as we anticipate the future but we have to exercise a bit of discipline as we move through the minimum requirements.  We will have to decorate this with additional items over time for sure, to make it more interesting and a bit more balanced as it scales.

Now that the hero is created, we need to create a worthy opponent to challenge him to a battle.  We will cover those details next time.



About b.hedge

i do database stuff and i like to solve business problems with code.
This entry was posted in coding, node js. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s