HTML and CSS Reference
In-Depth Information
//remove
saucerMissiles.splice(saucerMissileCtr,1)
tempSaucerMissile = null;
}
}
}
function updateParticles() {
var tempParticle = {};
var particleLength = particles.length-1;
//ConsoleLog.log("particle=" + particleLength)
for (var particleCtr=particleLength;particleCtr>=0;particleCtr--){
var remove = false;
tempParticle = particles[particleCtr];
tempParticle.x += tempParticle.dx;
tempParticle.y += tempParticle.dy;
tempParticle.lifeCtr++;
//ConsoleLog.log("particle.lifeCtr=" + tempParticle.lifeCtr);
//try{
if (tempParticle.lifeCtr > tempParticle.life){
remove = true;
} else if ((tempParticle.x > xMax) || (tempParticle.x<xMin)
|| (tempParticle.y > yMax) || (tempParticle.y<yMin)){
remove = true;
}
//}
//catch(err) {
// ConsoleLog.log ("error in particle");
// ConsoleLog.log("particle:" + particleCtr);
//}
if (remove) {
particles.splice(particleCtr,1)
tempParticle = null;
}
}
}
function renderPlayerShip(x,y,rotation, scale) {
//transformation
var angleInRadians = rotation * Math.PI / 180;
context.save(); //save current state in stack
context.setTransform(1,0,0,1,0,0); // reset to identity
//translate the canvas origin to the center of the player
context.translate(x+player.halfWidth,y+player.halfHeight);
context.rotate(angleInRadians);
context.scale(scale,scale);
Search WWH ::




Custom Search