-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBall.java
More file actions
38 lines (32 loc) · 744 Bytes
/
Ball.java
File metadata and controls
38 lines (32 loc) · 744 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
public class Ball extends GameObject {
// Add any state variables here
private int xVelocity = 0;
private int yVelocity = 0;
/**
* Fill in this method with code that describes the behavior
* of a ball from one moment to the next
*/
public void act() {
setX(getX() + xVelocity);
setY(getY() + yVelocity);
setYVelocity(0);
setXVelocity(0);
}
public int getXVelocity()
{
return xVelocity;
}
public int getYVelocity()
{
return yVelocity;
}
public void setYVelocity(int vIn)
{
yVelocity = vIn;
}
public void setXVelocity(int xIn)
{
xVelocity = xIn;
}
// Add any additional methods here
}