dernier commit de la journée
This commit is contained in:
parent
8081ccddf0
commit
16c23c0205
1 changed files with 48 additions and 3 deletions
51
canvas.js
51
canvas.js
|
@ -4,10 +4,20 @@ canvas = document.getElementById('canvas');
|
||||||
function DrawGameCub(x, y){
|
function DrawGameCub(x, y){
|
||||||
ctx = canvas.getContext('2d');
|
ctx = canvas.getContext('2d');
|
||||||
const a = 10;
|
const a = 10;
|
||||||
ctx.fillStyle='brown';
|
ctx.fillStyle='#DEB887';
|
||||||
ctx.fillRect(x, y, a, a);
|
ctx.fillRect(x, y, a, a);
|
||||||
ctx.save();
|
ctx.save();
|
||||||
}
|
}
|
||||||
|
//fonction dessiner cube de bois avec img
|
||||||
|
function imgDrawGameCub(x,y){
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
const dim = 100;
|
||||||
|
let cubebois = new Image();
|
||||||
|
cubebois.src = //lien de l'image;
|
||||||
|
cubebois.addEventListener('load',function(){
|
||||||
|
ctx.drawImage(cubebois,x,y,dim,dim);
|
||||||
|
},false);
|
||||||
|
}
|
||||||
|
|
||||||
//fonction pour dessiner des cercles du jeu
|
//fonction pour dessiner des cercles du jeu
|
||||||
function Drawcircle(x, y){
|
function Drawcircle(x, y){
|
||||||
|
@ -20,6 +30,16 @@ function Drawcircle(x, y){
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
ctx.save();
|
ctx.save();
|
||||||
}
|
}
|
||||||
|
//function pour dessiner des cercles à partir de l'image
|
||||||
|
function imgDrawcircle(x,y){
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
const dim = 100;
|
||||||
|
let circle = new Image();
|
||||||
|
circle.src = //lien de l'image;
|
||||||
|
circle.addEventListener('load',function(){
|
||||||
|
ctx.drawImage(circle,x,y,dim,dim);
|
||||||
|
},false);
|
||||||
|
}
|
||||||
|
|
||||||
//fonction pour dessiner un cube du labyrinthe
|
//fonction pour dessiner un cube du labyrinthe
|
||||||
function DrawLabCub(){
|
function DrawLabCub(){
|
||||||
|
@ -44,9 +64,34 @@ function Mario(x, y){
|
||||||
},false);
|
},false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//function qui met à jour le canvas
|
//function généric qui dessine une image
|
||||||
function MajJeu(){
|
function DrawImg(That){
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
const dim = 20;
|
||||||
|
let img= new Image();
|
||||||
|
img.src = //lien de l'image;
|
||||||
|
img.addEventListener('load',function(){
|
||||||
|
ctx.drawImage(img,x,y,dim,dim);
|
||||||
|
},false);
|
||||||
|
ctx.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
//function qui met à jour le canvas
|
||||||
|
function MajJeu(Mat){
|
||||||
|
while(true){
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
ctx.clearRect(0,0, canvas.width, canvas.height);
|
||||||
|
let lignes= 0; // à définir plus tard
|
||||||
|
let colones=0;// à définir plus tard
|
||||||
|
for (let i=0; i< lignes; i++){
|
||||||
|
for(let j=0; j< colones; j++){
|
||||||
|
let obj = Mat[i][j];
|
||||||
|
DrawImg(obj);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue