class Food { color c = color(0, 255, 0); int size; int x; int Ypos = 9; int lastPos; int random; int wait = 0; int bombChance = 1; // op vijf boolean bomb; Food(int TempSpacing) { size = TempSpacing; x = int(random(0, 10)); random = 4; bomb = false; } void move() { if (frameCount%Speed == 0) { Ypos = Ypos - 1; } } void respawn() { if (Ypos < 0) { lastPos = x; x = int(random(0, 10)); if (x == lastPos) { //correction(); } Ypos = 9; random = int(random(5)); // 1 op vijf kans op een bom if(random < bombChance) { bomb = true; ledGrid._foodColor = color(255,0,0); } else { bomb = false; c = color(0,255,0); ledGrid._foodColor = color(0,255,0); } } } void correction() { int or; int r = round(random(1)); if (r == 1 && x != 0) { or = size; } else { or = -size; } if (r == 0 && x != 9) { or = -size; } else { or = size; } x += or; } void boundary() { if (x > 9) { x = 0; } if (x < 0) { x = 9; } } }