Created
September 17, 2012 23:18
-
-
Save tlhunter/3740369 to your computer and use it in GitHub Desktop.
Cobalt Calibur Draw Avatar
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
var len = app.players.data.length; | |
for (var k = 0; k < len; k++) { | |
var player = app.players.data[k]; | |
if (player.x == mapX && player.y == mapY) { | |
var index = app.graphics.getAvatarFrame(player.direction, app.graphics.globalAnimationFrame); | |
var player_name = player.name || '???'; | |
var picture_id = player.picture; | |
if (isNaN(picture_id)) { | |
picture_id = 0; | |
} | |
if (redrawNametags) app.graphics.nametags.add(player.name, i, j, false); | |
app.graphics.drawAvatar(i, j, index, picture_id, 'characters'); | |
} | |
} | |
// app.graphics.drawAvatar: | |
function drawAvatar(x, y, tile_x, tile_y, tileset) { | |
var x_pixel = x * app.graphics.TILE_WIDTH_PIXEL; | |
var y_pixel = y * app.graphics.TILE_HEIGHT_PIXEL; | |
var tile_height = 32; | |
if (tileset == 'monsters') { | |
tileset = app.graphics.tilesets.monsters; | |
tile_height = 32; | |
} else if (tileset == 'characters') { | |
tileset = app.graphics.tilesets.characters; | |
y_pixel -= 16; | |
tile_height = 48; | |
} | |
app.graphics.handle.drawImage( | |
tileset, | |
tile_x * app.graphics.TILE_WIDTH_PIXEL, | |
tile_y * tile_height, | |
app.graphics.TILE_WIDTH_PIXEL, | |
tile_height, | |
x_pixel, | |
y_pixel, | |
app.graphics.TILE_WIDTH_PIXEL, | |
tile_height | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment