1 decade ago by blobber
I am trying to create a simple jump-in-run game based of the jump-n-run demo where the user has to fight enemies as he passes through a level but every 3 grenades he shoots he needs to answer a simple question in order to be able to start shooting again I have tried trying to create this as an entity but its not really going that well and I could use a hand.
Heres the entity for the grenade (exact same as in the jump-n-run demo)
So basically I want to check if the user has shot 3 grenades and if this is true I want the game to show a question for example (how may pool balls on a table) and if the answer if true the user gets to keep on shooting.
Thanks
Heres the entity for the grenade (exact same as in the jump-n-run demo)
EntitySlimeGrenade = ig.Entity.extend({ size: {x: 4, y: 4}, offset: {x: 2, y: 2}, maxVel: {x: 200, y: 200}, // The fraction of force with which this entity bounces back in collisions bounciness: 0.6, type: ig.Entity.TYPE.NONE, checkAgainst: ig.Entity.TYPE.B, // Check Against B - our evil enemy group collides: ig.Entity.COLLIDES.PASSIVE, animSheet: new ig.AnimationSheet( 'media/slime-grenade.png', 8, 8 ), bounceCounter: 0, init: function( x, y, settings ) { this.parent( x, y, settings ); this.vel.x = (settings.flip ? -this.maxVel.x : this.maxVel.x); this.vel.y = -50; this.addAnim( 'idle', 0.2, [0,1] ); }, handleMovementTrace: function( res ) { this.parent( res ); if( res.collision.x || res.collision.y ) { // only bounce 3 times this.bounceCounter++; if( this.bounceCounter > 3 ) { this.kill(); } } }, // This function is called when this entity overlaps anonther entity of the // checkAgainst group. I.e. for this entity, all entities in the B group. check: function( other ) { other.receiveDamage( 10, this ); this.kill(); } });
So basically I want to check if the user has shot 3 grenades and if this is true I want the game to show a question for example (how may pool balls on a table) and if the answer if true the user gets to keep on shooting.
Thanks