-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBall.java
More file actions
183 lines (161 loc) · 3.76 KB
/
Copy pathBall.java
File metadata and controls
183 lines (161 loc) · 3.76 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/**
* Write a description of class Ball here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Ball extends MoveableObject
{
int left,right,ogX,ogY,ogXdir,ogYdir,randomdirection,direction,randomdirection2,direction2;
int pausecounter;
double Cxdir,Cydir;
String WhoScored;
boolean caught;
boolean color;
int updown;
public Ball(int xx, int yy,int aa,int bb,int xdir, int ydir)
{
super(xx,yy,aa,bb,xdir,ydir);
ogX=(int)x;
ogY=(int)y;
ogXdir=(int)xdir;
ogYdir=(int)ydir;
caught=false;
right=0;
left=0;
color=false;
}
public void Gravity(int updown)
{
this.updown=updown;
if(updown==1)
ydir=ydir+0.01;
if(updown==2)
ydir=ydir-0.01;
}
// public void hit(Boolean Catch,Player Player)
// {
// if(!caught)
// {
// Cxdir=xdir;
// Cydir=ydir;
// }
// if(!Catch)
// {
// xdir=Cxdir*-1.15;
// // if(y==Player.getY()-60)
// // ydir=Cydir*-1.15;
// // else
// ydir=Cydir*1.15;
// caught=false;
// }
// if(Catch && !caught)
// {
// xdir=0;
// ydir=0;
// caught=true;
// System.out.println(caught);
// }
// if(Catch&&caught)
// {
// y=y+Player.getYdir();
// }
// }
public void hit()
{
xdir=xdir*-1.15;
ydir=ydir*1.15;
}
public boolean getColor()
{
return color;
}
public void setColor(boolean stuff)
{
color=stuff;
}
public boolean getWithin(Player Player)
{
int nxdir=(int)xdir;
if(xdir<0)
nxdir=nxdir*-1;
// System.out.println(x+"<"+(Player.getX()+(150*nxdir)));
if(x<Player.getX()+(150*nxdir))
return true;
return false;
}
public void Score(String WWhoScored)
{
WhoScored=WWhoScored;
if(WhoScored=="left")
left=left+1;
if(WhoScored=="right")
right=right+1;
}
public String getWhoScored()
{
return WhoScored;
}
public int Reset()
{
pausecounter=0;
if(WhoScored=="left" || WhoScored=="right")
{
randomdirection = (int)(Math.random() * 2 + 1);
randomdirection2 = (int)(Math.random() * 2 + 1);
if(randomdirection==1)
direction=1;
else
direction=-1;
if(randomdirection==1)
direction2=-1;
else
direction2=1;
x=ogX;
y=ogY;
xdir=direction;
ydir=direction2;
WhoScored="";
pausecounter=250;
}
return pausecounter;
}
public int getScoreLeft()
{
return left;
}
public int getScoreRight()
{
return right;
}
public boolean equalscore()
{
if(left==right)
return true;
else return false;
}
public void walls(GameBorder gb)
{
ydir=ydir*-1.01;
if(y>gb.getY()+gb.getSizeB()-10)
{
y=gb.getY()+gb.getSizeB()-10;
}
if(y<gb.getY())
{
y=gb.getY();
}
// if(S1=="X,0")
// xdir=1;
// if(S1=="Y,0")
// {
// y=0;
// ydir=ydir*-1.15;
// System.out.println(ydir);
// }
// if(S1=="X,600")
// xdir=-1;
// if(S1=="Y,600")
// ydir=ydir*-1.15;
}
}