-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFood.pde
More file actions
30 lines (24 loc) · 968 Bytes
/
Food.pde
File metadata and controls
30 lines (24 loc) · 968 Bytes
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
class Food {
PVector pos;//position of food
//---------------------------------------------------------------------------------------------------------------------------------------------------------
//constructor
Food() {
pos = new PVector();
// set position to a random spot
pos.x = 400+floor(random(0, 40)) * 10;
pos.y = floor(random(0, 40)) * 10;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------
//show the food as a red square
void show() {
fill(255, 0, 0);
rect(pos.x, pos.y, 10, 10);
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------
//return a clone of this food
Food clone() {
Food clone = new Food();
clone.pos = new PVector(pos.x, pos.y);
return clone;
}
}