Created
October 31, 2010 21:55
-
-
Save DanielBaulig/657213 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drawUnits: function( dirtyRect ) { | |
var ressources = this.ressources; | |
var zones = ressources.game.zones; | |
var sprites = ressources.sprites; | |
var bufferContext = this.bufferContext; | |
bufferContext.save(); | |
if (dirtyRect) { | |
this.setClipping( dirtyRect ); | |
} | |
bufferContext.shadowOffsetX = UNIT_SHADOW / 2; | |
bufferContext.shadowOffsetY = UNIT_SHADOW / 2; | |
bufferContext.shadowBlur = UNIT_SHADOW / 2; | |
bufferContext.shadowColor = 'black'; | |
bufferContext.textBaseline = 'middle'; | |
//bufferContext.lineWidth = 1; | |
bufferContext.fillStyle = 'white'; | |
bufferContext.strokeStyle = 'red'; | |
bufferContext.font = 'bold 11pt Sans-serif'; | |
for (var z in zones) { | |
var zone = zones[z]; | |
var places = ressources.polygons[z].places; | |
var i = 0; | |
for(var n in zone) { | |
var nation = zone[n]; | |
for(var u in nation) { | |
var unit = nation[u]; | |
var place = places[i++]; | |
if ( unit > 0 ) { | |
bufferContext.drawImage( sprites[n][u], place[0], place[1], UNIT_WIDTH, UNIT_HEIGHT ); | |
if (this.stroke) | |
bufferContext.strokeText( unit, place[0] + Math.floor(UNIT_WIDTH/4), place[1] + UNIT_HEIGHT ); | |
bufferContext.fillText( unit, place[0] + Math.floor(UNIT_WIDTH/4), place[1] + UNIT_HEIGHT ); | |
} | |
} | |
} | |
} | |
bufferContext.restore(); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment