-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarrier.java
More file actions
127 lines (110 loc) · 3.93 KB
/
Copy pathBarrier.java
File metadata and controls
127 lines (110 loc) · 3.93 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import java.util.ArrayList;
/**
* Write a description of class Barrier here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Barrier extends GameObject
{
// instance variables - replace the example below with your
int middle,range,bottom,index;
int positionX;
int ogb;
boolean neat;
/**
* Constructor for objects of class Barrier
*/
public Barrier(int xx,int yy,int aa,int bb)
{
super(xx,yy,aa,bb);
middle=0;
range=0;
bottom=0;
}
public Barrier(Ball Ball, ArrayList<Barrier>Barriers)
{
super(00,00,15,60);
middle=377;
range=190;
bottom=440;
ChangeXY(Ball,Barriers);
}
public void ChangeXY(Ball Ball, ArrayList<Barrier>Barriers)
{
int positionY;
boolean NewLocation=false;
// if(Ball.getScoreLeft()>(Ball.getScoreRight()*2)+Ball.getScoreRight()&&!Lever)
// {
// middle=middle+100;
// range=range-100;
// Lever=true;
// }
while(!NewLocation)
{
// if(Ball.getScoreLeft()>Ball.getScoreRight())
// {
// positionX=middle-(int)(Math.random()*range+10);
// }
// if(Ball.getScoreLeft()<Ball.getScoreRight())
// {
// positionX=(middle+(int)(Math.random()*range+10));
// }
// System.out.println(Barriers.size());
if(Ball.getScoreLeft()<Ball.getScoreRight())
{
positionX=(middle+(int)(Math.random()*range+10));
}
if(Ball.getScoreLeft()==Ball.getScoreRight())
{
positionX=(middle);
}
if(Ball.getScoreLeft()>Ball.getScoreRight())
{
positionX=middle-(int)(Math.random()*range+10);
}
positionY=(60+(int)(Math.random()*(bottom-60)+1));
if(Barriers.size()>1)
{
boolean okay=true;
for (index=0;index<Barriers.size();index++)
{
// if(!neat)
// System.out.println("for loop stuck");
// neat=true;
// if((this !=Barriers.get(index)) && !(
// positionX > Barriers.get(index).getX() - (a * 5)
// && positionX < Barriers.get(index).getX() + (Barriers.get(index).getSizeA() * 5)
// && positionY > Barriers.get(index).getY() - (b * 5)
// && positionY < Barriers.get(index).getY() + (Barriers.get(index).getSizeB() * 5)))
if((this !=Barriers.get(index)))
if((
positionX > Barriers.get(index).getX() - (a * 2)
&& positionX < Barriers.get(index).getX() + (Barriers.get(index).getSizeA() * 2)
&& positionY > Barriers.get(index).getY() - (b * 2)
&& positionY < Barriers.get(index).getY() + (Barriers.get(index).getSizeB() * 2))
// && !(positionX > Ball.getX() - (a*2)
// && positionX < Ball.getX() + (Ball.getSizeA()*2)
// && positionY > Ball.getY() - (b*2)
// && positionY < Ball.getY() + (Ball.getSizeB()*2))
)
{
okay=false;
}
}
if(okay)
{
NewLocation=true;
setX(positionX);
setY(positionY);
}
}
else
{
setX(positionX);
setY(positionY);
NewLocation=true;
}
}
}
}