com.codingame.gameengine.module.entities.Circle Maven / Gradle / Ivy
package com.codingame.gameengine.module.entities;
/**
*
* A Circle specifies an area in a the world
defined by the Circle's center point (x,y) and its radius.
*
* The coordinates and radius are in world units.
*/
public class Circle extends Shape {
private int radius = 100;
Circle() {
super();
}
/**
* Sets the radius of this Circle
in world units.
*
*
* @param radius
* the radius for this Circle
.
* @throws IllegalArgumentException
* if radius < 0
* @return this Circle
.
*/
public Circle setRadius(int radius) {
return setRadius(radius, null);
}
/**
* Sets the radius of this Circle
in world units.
*
*
* @param radius
* the radius for this Circle
.
* @param curve
* the transition to animate between values of this property.
* @throws IllegalArgumentException
* if radius < 0
*
* @return this Circle
.
*/
public Circle setRadius(int radius, Curve curve) {
if (radius < 0) {
throw new IllegalArgumentException("A Circle's radius may not be less than zero");
}
this.radius = radius;
set("radius", radius, curve);
return this;
}
/**
*
* Returns the radius of this Circle
in world units.
*
* Default is 100.
*
* @return the radius of this Circle
.
*/
public int getRadius() {
return radius;
}
@Override
Entity.Type getType() {
return Entity.Type.CIRCLE;
}
}