|
|
@@ -0,0 +1,68 @@
|
|
|
+package model.objects;
|
|
|
+
|
|
|
+import java.awt.Color;
|
|
|
+import java.awt.Graphics2D;
|
|
|
+import java.awt.Shape;
|
|
|
+import java.awt.geom.Ellipse2D;
|
|
|
+
|
|
|
+
|
|
|
+public class Ball {
|
|
|
+ private Color color;
|
|
|
+ private int size, bounceheight;
|
|
|
+ private Ellipse2D.Double bal;
|
|
|
+
|
|
|
+ public Ball(int size, int bounceheight, Color color, int x, int y){
|
|
|
+ this.color = color;
|
|
|
+ this.size = size;
|
|
|
+ this.bounceheight = bounceheight;
|
|
|
+ bal = new Ellipse2D.Double(x,y,size*20,size*20);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void paint(Graphics2D g2d)
|
|
|
+ {
|
|
|
+ g2d.setColor(color);
|
|
|
+ g2d.fill(bal);
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getSize(){
|
|
|
+ return size;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getBounceHeight(){
|
|
|
+ return bounceheight;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getX(){
|
|
|
+ return (int)bal.getX();
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getY(){
|
|
|
+ return (int)bal.getY();
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getWidth(){
|
|
|
+ return (int)bal.getWidth();
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getHeight(){
|
|
|
+ return (int)bal.getHeight();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void setX(int x){
|
|
|
+ bal.setFrame(x, getY(), getWidth(),getHeight());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setY(int y){
|
|
|
+ bal.setFrame(getX(), y, getWidth(), getHeight());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setWidth(int w){
|
|
|
+ bal.setFrame(getX(), getY(), w, getHeight());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setHeight(int h){
|
|
|
+ bal.setFrame(getX(), getY(), getWidth(), h);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|