-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchived.txt
42 lines (40 loc) · 1.4 KB
/
archived.txt
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
38
39
40
41
42
////////////////////////////////ARCHIVED/////////////////////////////////////
//(Code block slow...O(n))
void keyPressed() {
//selects the eligible cell for a key press to act on!
for (ChocoCell cell : chocolateBox.box) {
//if cell is not active or hovered then the key changes are not for this cell!
if (!cell.containsCursor()) continue;
if (key == ' ') cell.switchVisibility();
//if cell is not visible but active(hovered) then also that active cell should not recieve keyboard changes!
if (!cell.visible) continue;
//perform the operation in desired cell according to the key pressed!
switch(key) {
//next flavor
case'a':
cell.switchFlavor(true);
break;
//prev flavor
case's':
cell.switchFlavor(false);
break;
//next shape
case'd':
cell.switchShape(true);
break;
//prev shape
case'f':
cell.switchShape(false);
break;
};
}
}
//slow time complexity O(n)
void draw() {
background(64,64,64);
//lets draw the cells and the chocolates inside them present in the chocolate box
for (ChocoCell cell : chocolateBox.box) {
//here drawCell function is smart enough to autocheck the cursor presence inside cell O(1)time!
cell.drawCell();
};
}