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
| function setSpace(stars){
var sx=0; sy=0; var index=0;
stars.src="img/stars/stars.png";
stars.onload=function(){
for(let lig=0; lig<=100; lig++){
espace[lig]=new Array();
for(let col=0; col<=4; col++){
var index=Math.floor(Math.random()*4);
var rwidth=Math.floor(Math.random()*24);
var rheight=rwidth;
var dx=Math.floor(Math.random()*1000);
var dy=Math.floor(Math.random()*700);
sx=index*32;
etoile=new Etoiles(sx,sy,dx,dy,rwidth,rheight);
espace[lig][col]=etoile;
}
}
}
}
function getSpace(ligne){
var sx=0; sy=0; var index=0;
for(let lig=0; lig<=100; lig++){
for(let col=0; col<=4; col++){
etoile.sx=espace[lig][col].sx; //<<<<<<<<<<<< Erreur dans cette ligne. >>>>>>>>>>>>>>>
etoile.sy=espace[lig][col].sy;
etoile.dx=espace[lig][col].dx;
etoile.dy=espace[lig][col].dy;
etoile.w=espace[lig][col].w;
etoile.h=espace[lig][col].h;
ctx1.drawImage(stars,etoile.sx,etoile.sy,32,32,etoile.dx,ligne+etoile.dy,etoile.w,etoile.h);
}
}
} |
Partager