📄 orbitingbody.java
字号:
/*
* OrbitingBody.java
*
* Copyright (C) 2000 Jason M. Hanley
* Released under the GNU General Public License (GPL)
* See license.txt for additional information.
*
* Created on July 30, 2000, 10:17 PM
*/
package fate.world;
import java.io.*;
/**
* Base class for any orbiting object in the universe.
*
* @author preylude@s3m.com
* @version 0.1.0
*/
public class OrbitingBody extends WorldObject
implements Comparable, Serializable {
/** Position along the circumference of orbit, in radians */
public double position;
/** Distance from the central object, no specific unit */
public int distance;
/** Orbiting Speed: position delta in an update interval.
Positive is clockwise, Negative is counter-clockwise */
public double velocity;
/** Creates new OrbitingBody */
public OrbitingBody() {
super();
position = 0.0;
distance = 0;
velocity = 0.0;
}
/** Calculate X coordinate */
public int x() {
double retx = Math.cos( position );
retx *= distance;
return (int)Math.round( retx );
}
/** Calculate Y coordinate */
public int y() {
double rety = Math.sin( position );
rety *= distance;
return (int)Math.round( rety );
}
/** Compare two OrbitingBody objects (for sorting) */
public int compareTo( Object o ) {
Integer intOther = new Integer( ((OrbitingBody)o).distance );
return (new Integer( distance )).compareTo( intOther );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -