-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGround.pde
47 lines (42 loc) · 1.13 KB
/
Ground.pde
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
43
44
45
46
47
class Ground{
//Colour Variables
color groundColour;
color currentColour;
color nightGroundColour;
//Positioning and size
int posX;
int posY;
PImage groundProps;
//Constructor
Ground(int inpX, int inpY, color inpGround, color inpNight){
posX = inpX;
posY = inpY;
groundColour = inpGround;
nightGroundColour = inpNight;
groundProps = loadImage("backgroundProps.png");
}
//Draw Ground obv
void drawGround(){
pushMatrix();
imageMode(CORNER);
noStroke();
tint(255, 255);
fill(currentColour);
rect(posX, posY, width, height);
image(groundProps, 0, 1);
popMatrix();
}
//USING THE AMOUNT OF MINUTES PASSED SINCE 6AM.
//If outside 6AM/6PM range, do nothing.
void calculateGroundColour(int sunMinute){
if(sunMinute < 0){
currentColour = nightGroundColour;
}
else if(sunMinute >= 0 && sunMinute <= 360){
currentColour = lerpColor(nightGroundColour, groundColour, (float)sunMinute/360.0);
}
else if(sunMinute > 360){
currentColour = lerpColor(groundColour, nightGroundColour, (float)(sunMinute - 360)/360.0);
}
}
}