This file contains hidden or 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
function render(redrawNametags) { | |
// immediately draw canvas as black | |
app.graphics.handle.fillStyle = "rgb(0,0,0)"; | |
app.graphics.handle.fillRect(0, 0, app.graphics.viewport.WIDTH_PIXEL, app.graphics.viewport.HEIGHT_PIXEL); | |
var i, j; | |
var mapX = 0; | |
var mapY = 0; | |
var tile; | |
if (redrawNametags) app.graphics.nametags.hide(); |
This file contains hidden or 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; |
This file contains hidden or 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
drawTile: function(x, y, tile) { | |
var x_pixel = x * app.graphics.TILE_WIDTH_PIXEL; | |
var y_pixel = y * app.graphics.TILE_HEIGHT_PIXEL; | |
if (tile == null || isNaN(tile[0])) { | |
return; | |
} | |
app.graphics.handle.drawImage( | |
app.graphics.tilesets.terrain, |
This file contains hidden or 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
initialize: function() { | |
var view = app.graphics.viewport; | |
view.WIDTH_TILE = Math.floor($(window).width() / app.graphics.TILE_WIDTH_PIXEL); | |
view.HEIGHT_TILE = Math.floor($(window).height() / app.graphics.TILE_HEIGHT_PIXEL); | |
view.WIDTH_PIXEL = app.graphics.viewport.WIDTH_TILE * app.graphics.TILE_WIDTH_PIXEL; | |
view.HEIGHT_PIXEL = app.graphics.viewport.HEIGHT_TILE * app.graphics.TILE_HEIGHT_PIXEL; | |
view.PLAYER_OFFSET_TOP_TILE = Math.floor(view.HEIGHT_TILE / 2); | |
view.PLAYER_OFFSET_LEFT_TILE = Math.floor(view.WIDTH_TILE / 2) + 1; | |
$('#gamefield').append('<canvas id="map" width="' + view.WIDTH_PIXEL + '" height="' + view.HEIGHT_PIXEL + '"></canvas>'); | |
$('#page, #nametags').width(view.WIDTH_PIXEL).height(view.HEIGHT_PIXEL); |
This file contains hidden or 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 currentFrame = 0; | |
setInterval(function() { | |
currentFrame++; | |
if (currentFrame % 3 == 0) { | |
currentFrame = 0; | |
// redraw every 150 ms, but change animation every 450 ms | |
app.graphics.globalAnimationFrame = !app.graphics.globalAnimationFrame; | |
app.player.killIfNpcNearby(); | |
} | |
app.environment.map.render(currentFrame === 0); |
NewerOlder