1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <!DOCTYPE HTML>
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>[Test Clonage Darkyl]</title>
<meta name="Author" content="NoSmoking">
<style type="text/css">
#map_du_jeu{
width: 1230px;
height: 750px;
overflow: hidden;
background-color: white;
border: 2px solid red;
position: absolute;
display: none;/**/
/* display: block;/**/
left: 20px;
top: 20px;
z-index: 10;
}
.imagefond{
height:28px;
width:44px;
position:absolute;
display:block;
z-index:1;
background : url(http://s408852608.onlinehome.fr/ressources_graphiques/textures%20map/herbe2.png);
}
</style>
</head>
<body>
<div id="debug" style="position:absolute;top:0;left:100px;"></div>
<div id="map_du_jeu"></div>
<script type="text/javascript">
var iDeb = new Date().getTime();
var LARG = 30, HAUT = 28, PENTE = 14;
var lig, nbLig = 50,
col, nbCol = 100,
posX, posY, offsetX =0;
// zone de jeu
var oClone,
oDest = document.getElementById('map_du_jeu');
var bFlag = !oDest.clientHeight;
// creation de l'element a cloner
var oFond = document.createElement('DIV');
oFond.className = 'imagefond';
// boucle de création
for( col = 0; col < nbCol; col++){
posY = 0;
posX = offsetX;
for( lig = 0; lig < nbLig; lig++){
oClone = oFond.cloneNode( true);
oClone.style.left = posX +'px';
oClone.style.top = posY +'px';
oClone.id ='case_' +lig +'_' +col;
oDest.appendChild( oClone);
posY += HAUT;
posX += PENTE;
}
offsetX += LARG;
}
if( bFlag) oDest.style.display = 'block';
document.getElementById( 'debug').innerHTML = new Date().getTime() -iDeb;
</script>
</body>
</html> |