lores ng (w.i.p)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
lores/examples/tiles.html

128 lines
1.8 KiB

<!DOCTYPE HTML>
<!-- requires the xpm files -->
<html>
<head>
<meta charset="utf-8">
<title>Lores: Tiles - Ondrovo.com</title>
<script src="jquery-1.10.1.min.js"></script>
<script src="jquery-migrate-1.2.1.min.js"></script>
<script src="lores.js"></script>
<style>
html,body{margin: 0; padding: 0; background: #000;}
#display {
margin: 20px auto;
width: 256px;
height: 256px;
box-shadow: 0px 0px 5px 4px cyan;
position: relative;
}
#legend {
margin: 20px auto;
width: 1020px;
color: cyan;
font-family: monospace;
text-align: center;
}
#legend a {
color: cyan;
}
</style>
<script>
var disp;
var keys;
var anim;
var dispmap;
var ROWS = 128;
var COLS = 128;
var TILES_X = 16;
var TILES_Y = 16;
var TILE_SIZE = 16;
var FPS = 10;
var liveCells = [];
$(document).ready(function(){
buildDisplay();
});
function buildDisplay() {
var BG = -1;
var helper = Lores.buildHelperCanvas('#display', COLS, ROWS, {}, BG);
var tiles = new LoresTileset(helper, 16, 16);
disp = new LoresDisplay(
$('#display'),
{
cols: COLS,
rows: ROWS,
colors: {
0: "#000",
1: "#fff",
},
bg: -1,
}
);
var dlMgr = new LoresDownloader();
dlMgr.getXpm("wall.xpm", function(pm) {
tiles.addTile("wall", pm);
});
dlMgr.getXpm("floor.xpm", function(pm) {
tiles.addTile("floor", pm);
});
dlMgr.run(function() {
for(var y=0; y<=7; y++) {
for(var x=0; x<=7; x++) {
if(x==0||x==7||y==0||y==7) {
tiles.renderTile(disp, "wall", x, y);
} else {
tiles.renderTile(disp, "floor", x, y);
}
}
}
});
}
</script>
</head>
<body>
<div id="display" class="display-wrap">
</div>
<div id="legend">
Tiles | <a href="/">→ Ondrovo.com</a>
</div>
<body>
</html>