facerix / Canvassa

Dojo-powered JavaScript clone of the Legend of Zelda
http://www.buyog.com/code/loc/Canvassa
12 stars 3 forks source link

Fix Zola monster AI #3

Open facerix opened 14 years ago

facerix commented 14 years ago
facerix commented 14 years ago

I've added the fireball sprites to items.png; here's the code that should handle the rest:

dojo.declare("loc.FireballProj", loc.Projectile, { constructor: function(args){ dojo.mixin(this, args); this.vel = {x: this.vector.x * 6, y: this.vector.y * 6}; this.width = 8; this.height = 10;

    this._stateDefs = [ { faceted:false, nextState: 0, canMove: true,
        anim: [ [{x:160,y:0,t:1},{x:168,y:0,t:1},{x:176,y:0,t:1},{x:184,y:0,t:1}] ] }];
}

});

// Zola.js: // (should inherit from both loc.Monster and loc.Shooter, which right now we're not) getProjectile: function() { // don't use this._getProjectileArgs()... better to just get my own vector right here var args = { vector: {x: randomBetween-1.0and1.0(), y: randomBetween-1.0and1.0()}, pos: dojo.clone(this.pos), size: {w:8, h:8}, scale: 1, spriteSrc: "items" };

    args.size.h = 10;
    return new loc.FireballProj(args);
}