forked from udohi/GameArena
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSun.java
More file actions
75 lines (67 loc) · 1.38 KB
/
Sun.java
File metadata and controls
75 lines (67 loc) · 1.38 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* This class extends the Ball class.
*
* The Sun class creates an orange ball (the Sun) and the co-ordinates of this dictate the Background's shade.
*
* @see Ball
* @see Background
*
* @author Harry Almond, Adam Bogg
*/
public class Sun extends Ball
{
public Sun()
{
super(-100, 720, 100, "ORANGE");
//super(640, 360, 100, "ORANGE");
}
public Sun(String col)
{
super(-100, 720, 100, col);
}
private static int speed = 1;
public static double firstYSpeed = 1;
public static double ySpeed = firstYSpeed;
public int getSpeed()
{
return speed;
}
public void move()
{
setXPosition(getXPosition() + getSpeed());
if (getXPosition() < 640)
setYPosition(getYPosition() - getSpeed()) ;
else if (getXPosition() < 1380)
setYPosition(getYPosition() + getSpeed());
else
setXPosition(-100);
}
public void arcMove()
{
setXPosition(getXPosition() + getSpeed());
setYPosition(getYPosition() - ySpeed);
ySpeed = ySpeed - 0.0014;
if (getXPosition() > 1380)
{
ySpeed = firstYSpeed;
setXPosition(-100);
setYPosition(720);
}
}
public void boolArcMove()
{
if (Moon.getSM())
{
setXPosition(getXPosition() + getSpeed());
setYPosition(getYPosition() - ySpeed);
ySpeed = ySpeed - 0.0014;
if (getXPosition() > 1380)
{
ySpeed = firstYSpeed;
setXPosition(-100);
setYPosition(720);
Moon.setSM(false);
}
}
}
}