eviter de hardcoder le nombre de dessins

front
gwen 1 year ago
parent e5dc2cc472
commit 165c06ad7f

@ -3,7 +3,6 @@ export default{
props:["vieRestantes"], //maximum 10 props:["vieRestantes"], //maximum 10
data(){ data(){
return { return {
viesEpuisees:10-(this.vieRestantes??10),
ordreDessin:[ ordreDessin:[
this.potenceVertical, this.potenceVertical,
this.potencePoutre, this.potencePoutre,
@ -16,6 +15,7 @@ export default{
this.jambeDroite, this.jambeDroite,
this.jambeGauche this.jambeGauche
], ],
viesEpuisees:0,
ctx:null ctx:null
} }
}, },
@ -23,10 +23,11 @@ export default{
this.$refs.pendu.width=200 this.$refs.pendu.width=200
this.$refs.pendu.height=200 this.$refs.pendu.height=200
this.ctx = this.$refs.pendu.getContext("2d"); this.ctx = this.$refs.pendu.getContext("2d");
this.viesEpuisees=this.ordreDessin.length-(this.vieRestantes??this.ordreDessin.length)
}, },
methods:{ methods:{
dessiner(){ dessiner(){
if(this.viesEpuisees<=10){ if(this.viesEpuisees<this.ordreDessin.length){
this.ordreDessin[this.viesEpuisees]() this.ordreDessin[this.viesEpuisees]()
this.viesEpuisees++; this.viesEpuisees++;
} }

Loading…
Cancel
Save