Hi joncom!
Thanks for your response but I just fixed my issue. I was calling the random number generator outside the init: function like the following.
/**
* Created by Logan Looker on 10/31/13.
*/
ig.module(
'game.entities.enemy'
)
.requires(
'impact.entity',
'game.entities.player',
'game.entities.bullet',
'game.entities.ammo',
'game.entities.medkit',
'game.entities.healthbar'
)
.defines(function(){
EntityEnemy = ig.Entity.extend({
font: new ig.Font( 'media/04b03.font.png' ),
//Enemy Properties
size: {x:32,y:48},
drop: Math.floor((Math.random()*5)+1), //Sets a random drop number for the enemies drop on death
speed: Math.floor((Math.random()*50)+10), //Sets a random speed for the enemy
//Collision Detection
collides: ig.Entity.COLLIDES.PASSIVE,
type: ig.Entity.TYPE.B,
checkAgainst: ig.Entity.TYPE.A,
//Animation Sheet
animSheet: new ig.AnimationSheet( 'media/tilesets/enemy1.png', 32, 48),
init: function( x, y, settings ) {
this.parent( x, y, settings );
},
I was getting the same random number throughout every enemy, it would generate a random number for the first enemy and then use that same number for all enemies instead of each enemy generating their own independent drop and speed..
After placing the random generating code into the init: function I got the results I was looking for.. Each enemy has its own independent random speed and drop. Like this:
/**
* Created by Logan Looker on 10/31/13.
*/
ig.module(
'game.entities.enemy'
)
.requires(
'impact.entity',
'game.entities.player',
'game.entities.bullet',
'game.entities.ammo',
'game.entities.medkit',
'game.entities.healthbar'
)
.defines(function(){
EntityEnemy = ig.Entity.extend({
font: new ig.Font( 'media/04b03.font.png' ),
//Player Properties
size: {x:32,y:48},
drop: 0,
speed: 0,
//Collision Detection
collides: ig.Entity.COLLIDES.PASSIVE,
type: ig.Entity.TYPE.B,
checkAgainst: ig.Entity.TYPE.A,
//ANIMATION SHEET
animSheet: new ig.AnimationSheet( 'media/tilesets/enemy1.png', 32, 48),
init: function( x, y, settings ) {
this.parent( x, y, settings );
//RANDOM GENERATORS!
this.drop = Math.floor((Math.random()*5)+1); //Sets a random drop number for the enemies drop on death
this.speed = Math.floor((Math.random()*50)+10); //Sets a random speed for the enemy
//RANDOM GENERATORS!
if( !ig.global.wm )
{
ig.game.spawnEntity(EntityHealthbar, this.pos.x, this.pos.y,{ Unit: this });
}
},