Skip to content

Commit b7caa5e

Browse files
authored
Update sketch.js
1 parent 354cf0d commit b7caa5e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sketch.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class People_C {//constructor
107107
} else if (this.all[r][c].dead) {
108108
this.all[r][c].setColor(color(colors.WHITE));
109109
} else if (this.all[r][c].sick >= 10) {
110+
console.log(this.all[r][c])
110111
this.all[r][c].setColor(color(colors.RED));
111112
} else if (this.all[r][c].sick == 0) {
112113
this.all[r][c].setColor(color(colors.BLUE));
@@ -152,9 +153,10 @@ class People_C {//constructor
152153
spreadDisease(People, conti) {
153154
if (!this.startDisease && People) {//false enter the loop
154155
let a = random(this.nb_rows), b = random(this.nb_cols)
155-
const patientZero = this.all[a][b].sick
156+
console.log(a,b)
157+
let patientZero = this.all[a][b].sick
158+
156159
this.vaccinate()
157-
// console.log("TCL: People_kC -> spreadDisease -> patientZero", a, b)
158160
if (this.all[a][b].Vaccinate) return People.spreadDisease()
159161
this.all[a][b].sick = 10;
160162
this.NBInfected++
@@ -202,7 +204,7 @@ class People_C {//constructor
202204
x2 = neighbour[0]
203205
y2 = neighbour[1]
204206
//fix the issue with the y2 don't exist if we select the Nomber of rows and column is different.
205-
if (this.all[x2]&&!this.all[x2][y2].Vaccinate && this.all[x2][y2].sick === 0 && this.all[x2][y2]) {
207+
if (this.all[x2]&&this.all[x2][y2]&&!this.all[x2][y2].Vaccinate && this.all[x2][y2].sick === 0 && this.all[x2][y2]) {
206208
this.all[x2][y2].sick = 10;
207209
this.NBInfected = this.NBInfected + 1
208210

@@ -286,11 +288,13 @@ function draw() {
286288
}
287289
function run() {
288290
conti = true
291+
setup();
292+
draw();
289293

290294
// console.log("TCL: run -> run")
291295
loop();
292296
}
293297

294-
function reload() {
295-
setup();
296-
}
298+
// function reload() {
299+
// setup();
300+
// }

0 commit comments

Comments
 (0)