forked from udohi/GameArena
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackground.java
More file actions
47 lines (43 loc) · 955 Bytes
/
Background.java
File metadata and controls
47 lines (43 loc) · 955 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import javafx.scene.paint.*;
/**
* This class creates a background for the GameArena.
*
* It 'reacts' to the x co-ordinates (and through this the y co-ordinates) of the Sun to change shade accordingly.
*
* @see GameArena
* @see Sun
*
* @author Adam Bogg, Harry Almond
*/
public class Background
{
public SmartRectangle r;
int i = 0;
//public int col = 003366;
public Color col = Color.web("003366");
public Background(GameArena arena)
{
r = new SmartRectangle(640, 360, 1280, 720, "003366");
arena.addRectangle(r);
}
public void change()
{
if (Driver.b.getXPosition() == -90)
{
col = Color.web("003366");
i = 0;
}
else if (Driver.b.getXPosition() < 640 && Driver.b.getXPosition() > 0 && i == 200)
{
col = col.brighter();
i = 0;
}
else if (Driver.b.getXPosition() < 1380 && Driver.b.getXPosition() > 0 && i == 200)
{
col = col.darker();
i = 0;
}
r.changeColour(col.toString());
i++;
}
}