Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by ShawnSwander

do I have to make a new entity for each enemy type to specify their image or can I put it in settings on spawn?

I am expecting something along the lines of
.spawnEntity( mob, x, y, settings )

and
settings= {"name":"orc",
                    "hp":10,
                     anims.??
                     etc};

1 decade ago by alexandre

Good question. Since you'll still need to create one Entity subclass for the purposes of developing your game, your init(x, y, settings) can take care of the dirty details.

But I think it'd be a lot simpler to just create one GameEntity class with a handler for this.

For example, say you have 3 villain types: bad, real bad, and real real bad. You could, in wm, spawn 3 GameEntity objects and give each one one of the following key/value settings:
entityType: bad (for entity #1)
entityType: real bad (for entity #2)
entityType: real real bad (for entity #3)

Then, in your MyGameEntity implementation file:
animSheet: new ig.AnimationSheet('media/sheetOfSheets.png', 16, 16),

init: function(x, y, settings)
{
  this.parent(x, y, settings);
  this.createAnims();
},

createAnims: function()
{
  if (this.entityType === "bad")
    this.addAnim('idle', 1, [0,1]);
  else if (this.entityType === "real bad")
    this.addAnim('idle', 1, [2,3]);
  else if (this.entityType === "real real bad")
    this.addAnim('idle', 1, [4,5]);
},

EDIT
Plus, tweaking timing of animations is much easier in text than through WM, and can also more easily be outsourced to others if you so wish it (just the one file to send instead of the burden of setting up at the other end)

1 decade ago by ShawnSwander

My animation script is really just a sheet of sprites that don't animate one for each mob so


      init: function( x, y, settings ) {
         this.parent( x, y, settings );
         // Add the animations
         this.health = 100;
         this.addAnim( 'efreet', 0.1, [0] );
			this.addAnim( 'manticore', 0.1, [1] );
			this.addAnim( 'centaur', 0.1, [2] );
			this.addAnim( 'kwolf', 0.1, [3] );
			this.addAnim( 'djinn', 0.1, [4] );
			this.addAnim( 'wyrm', 0.1, [5] );
			this.addAnim( 'frog', 0.1, [6] );
			this.addAnim( 'm_citizen_1', 0.1, [7] );
			this.addAnim( 'f_citizen_1', 0.1, [8] );
			this.addAnim( 'ogre', 0.1, [9] );
			this.addAnim( 'banshee', 0.1, [10] );
			this.addAnim( 'fish', 0.1, [11] );
			this.addAnim( 'oni', 0.1, [12] );
			this.addAnim( 'nymph', 0.1, [13] );
			this.addAnim( 'f_thaum', 0.1, [14] );
			this.addAnim( 'orc', 0.1, [15] );
			this.addAnim( 'aligator', 0.1, [16] );
			this.addAnim( 'f_knight', 0.1, [17] );
			this.addAnim( 'kobold', 0.1, [18] );
			this.addAnim( 'dog', 0.1, [19] );
			this.addAnim( 'duck', 0.1, [20] );
			this.addAnim( 'spider', 0.1, [21] );
			this.addAnim( 'wolf', 0.1, [22] );
			this.addAnim( 'griffon', 0.1, [23] );
			this.addAnim( 'poltergeist', 0.1, [24] );
			this.addAnim( 'hyena', 0.1, [25] );
			this.addAnim( 'cat', 0.1, [26] );
			this.addAnim( 'panda', 0.1, [27] );
			this.addAnim( 'doomorc', 0.1, [28] );
			this.addAnim( 'goblin', 0.1, [29] );
			this.addAnim( 'm_fighter', 0.1, [30] );
			this.addAnim( 'f_fighter', 0.1, [31] );
			this.addAnim( 'm_knight', 0.1, [32] );
			this.addAnim( 'f_ma', 0.1, [33] );
			this.addAnim( 'tiger', 0.1, [34] );
			this.addAnim( 'f_wiz', 0.1, [35] );
			this.addAnim( 'm_wiz', 0.1, [36] );
			this.addAnim( 'boar', 0.1, [37] );
			this.addAnim( 'salamander', 0.1, [38] );
			this.addAnim( 'waft', 0.1, [39] );
			this.addAnim( 'goose', 0.1, [40] );
			this.addAnim( 'beetle', 0.1, [41] );
			this.addAnim( 'hippo', 0.1, [42] );
			this.addAnim( 'unicorn', 0.1, [43] );
			this.addAnim( 'f_thief_old', 0.1, [44] );
			this.addAnim( 'm_thief_old', 0.1, [45] );
			this.addAnim( 'm_thaum', 0.1, [46] );
			this.addAnim( 'm_ma_red', 0.1, [47] );
			this.addAnim( 'wraith', 0.1, [48] );
			this.addAnim( 'skeleton', 0.1, [49] );
			this.addAnim( 'minotaur', 0.1, [50] );
			this.addAnim( 'snake', 0.1, [51] );
			this.addAnim( 'shark', 0.1, [52] );
			this.addAnim( 'bear', 0.1, [53] );
			this.addAnim( 'lizard', 0.1, [54] );
			this.addAnim( 'stalker', 0.1, [56] );
			this.addAnim( 'golem', 0.1, [57] );
			this.addAnim( 'sabertooth_tiger', 0.1, [58] );
			this.addAnim( 'm_citizen_2', 0.1, [59] );
			this.currentAnim = this.anims.golem;
         timer = new ig.Timer();
         this.addAnim( 'default', 0.1, [1] );
         this.currentAnim = this.anims.default;
      },

I really don't care much what they are called on the sheet either if there is a more functional way to assign their image.

I don't know if I could in their init(); check the mob name and assign an image accordingly via a switch statement or what... If anyone has better ideas I'm all ears.

For now this is what I'm doing and it works okay...
inside init()...

switch (this.gamename){
			case 'Golem':
				this.currentAnim = this.anims.golem;
			break;
			default:
				this.currentAnim = this.anims.m_citizen_2;
			break;
			}
...

and I spawn the creature with
settings = {"gamename":"Golem", "npc":"true", "level":1};
      ig.game.spawnEntity(EntityOtherplayer,550,550,settings);

I'm currently not using level but it will multiply the entities attributes
for example
mob.hp = mob.hp + (level * 10)
mob.defense = mob.defense + (level*0.5)

I do like you idea of different kinds of mobs but I don't know if its the best given the number of mobs I need. I'm planning on having spawn points that respawn them after 5 minutes or so of the mobs .kill()

1 decade ago by alexandre

You can eliminate that huge switch statement with:
this.currentAnim = this.anims[this.gamename];

Also, why use gamename instead of name? If because it is a type descriptor rather than an actual single entity name (not shared by others), it'll be clearer if you rename that to something like 'entityType'. Anyway, I'm just nitpicking.

1 decade ago by ShawnSwander

alexandre, no I don't consider it nit picking code can usually be written more effiiciently on my end.

You're right I could drop the switch part if I used your line.

To answer your question, currently I could see myself having multiple orcs... I was reserving name for something unique at this point. I could use something better.

1 decade ago by alexandre

You can further reduce that long addAnim statements sequence:
gamenames: ["efreet", "manticore", "centaur", "kwolf", "djinn", "wyrm",
"frog", "m_citizen_1", "f_citizen_1", "ogre", "banshee", "fish", "oni",
"nymph", "f_thaum", "orc", "aligator", "f_knight", "kobold", "dog", "duck",
"spider", "wolf", "griffon", "poltergeist", "hyena", "cat", "panda",
"doomorc", "goblin", "m_fighter", "f_fighter", "m_knight", "f_ma", "tiger",
"f_wiz", "m_wiz", "boar", "salamander", "waft", "goose", "beetle", "hippo",
"unicorn", "f_thief_old", "m_thief_old", "m_thaum", "m_ma_red", "wraith",
"skeleton", "minotaur", "snake", "shark", "bear", "lizard", "stalker",
"golem", "sabertooth_tiger", "m_citizen_2"],

health: 100,

init: function(x, y, settings)
{
	this.parent(x, y, settings);

	for (var i=0; i<this.gamenames.length; i++)
		this.addAnim(this.gamenames[i], 0.1, [i]);
},

EDIT
should have been
for (var i=0; i<this.gamenames.length; i++)

1 decade ago by alexandre

To answer your question, currently I could see myself having multiple orcs... I was reserving name for something unique at this point. I could use something better.


Makes perfect sense. Name is off-limit to describe a type, then.

1 decade ago by ShawnSwander

thanks for the for loop i didn't think of that.
Page 1 of 1
« first « previous next › last »