Exemple #1
0
LaserTower.prototype.draw = function(surface) {
    var imgSize = this.image.getSize();
    surface.blit(this.image, [this.rect.center[0]-(imgSize[0]/2), this.rect.center[1]-(imgSize[1]/2)]);
    if(this.currentTargetEnemy != null) {
        draw.line(surface, '#FF0000', this.rect.center, this.currentTargetEnemy.rect.center);
        var particleCount = 3;
        for(var i=0; i<particleCount;i++)
        {
            var particle = new LaserParticle(this.playSurface, this.currentTargetEnemy.rect.center);
            this.playSurface.particles.push(particle);
        }
    }
    return;
};
Exemple #2
0
function main() {
   // init
   var mainSurface = gamejs.display.setMode([800, 600]);
   gamejs.display.setCaption("Example Draw");

   draw.line(mainSurface, '#ff0000', [0,0], [100,100], 1);
   draw.lines(mainSurface, '#00ff00', true, [[50,50], [100,50], [100,100], [50,100]], 4);
   draw.circle(mainSurface, '#0000ff', [150, 150], 50, 10); // outline
   draw.circle(mainSurface, '#00ccff', [250, 250], 50, 0); // fill
   draw.rect(mainSurface, '#cccccc', new gamejs.Rect(10, 150, 20, 20), 2); // outline
   draw.rect(mainSurface, '#cccccc', new gamejs.Rect(50, 150, 20, 20), 0); // fill

   // and some text
   var defaultFont = new font.Font("20px Verdana"); // css font definition
   var textSurface = defaultFont.render("Example Draw Test 101", "#bbbbbb");
   mainSurface.blit(textSurface, [300, 50]);
};
Exemple #3
0
function main() {
   // set resolution & title
   var mainSurface = gamejs.display.setMode([800, 600]);
   gamejs.display.setCaption("Example Draw");

   // last parameter in all draw.* methods is the border width. 0 = fill
   draw.line(mainSurface, '#ff0000', [0,0], [100,100], 1);
   draw.lines(mainSurface, '#00ff00', true, [[50,50], [100,50], [100,100], [50,100]], 4);

   draw.polygon(mainSurface, '#0000ff', [[150,50], [200,50], [200,100]], 0);

   draw.circle(mainSurface, '#0000ff', [150, 150], 50, 10);
   draw.circle(mainSurface, '#00ccff', [250, 250], 50, 0);

   draw.rect(mainSurface, '#cccccc', new gamejs.Rect(10, 150, 20, 20), 2);
   draw.rect(mainSurface, '#cccccc', new gamejs.Rect(50, 150, 20, 20), 0);

   // create font object
   var defaultFont = new font.Font("20px Verdana"); // css font definition
   // render text, this returns a surface
   var textSurface = defaultFont.render("Example Draw Test 101", "#bbbbbb");
   mainSurface.blit(textSurface, [300, 50]);
};