Game Development Reference
In-Depth Information
}
return false;
}
/**
* Advance Sprite
*
* @param width screen width
* @param height screen height
* @return
*/
public boolean advance(int width, int height) {
boolean wrapped;
// Update the rotation and position of the sprite based on the delta
// values. If the sprite moves off the edge of the screen, it is wrapped
// around to the other side and TRUE is returned.
this.angle += this.deltaAngle;
if (this.angle < 0)
this.angle += 2 * Math.PI;
if (this.angle > 2 * Math.PI)
this.angle -= 2 * Math.PI;
wrapped = false;
this.x += this.deltaX;
if (this.x < -width / 2) {
this.x += width;
wrapped = true;
}
if (this.x > width / 2) {
this.x -= width;
wrapped = true;
}
this.y -= this.deltaY;
if (this.y < -height / 2) {
this.y += height;
wrapped = true;
}
if (this.y > height / 2) {
this.y -= height;
wrapped = true;
}
return wrapped;
}
@Override
public String toString() {
return "Sprite: " + sprite + " Shape:" + shape;
}
Search WWH ::




Custom Search