Permalink
Browse files

Added javadoc 1

Added javadoc for classes PlatformController, Player,
SceneObjectDataSource and ShadowedSpotlightControl
  • Loading branch information...
1 parent 827ca8b commit ed24706a097fb5d89fa49ae19542a8f20fe097fa @JonatanKilhamn JonatanKilhamn committed Mar 7, 2013
@@ -11,14 +11,28 @@
import variables.P;
/**
- *
+ * A class that holds and handles all platforms.
+ * A starting set of platforms are generated in the constructor, and an
+ * ordered list of platforms are always accessible.
* @author dagen
*/
public class PlatformController {
private AssetManager assetManager;
+ /**
+ * A list containing all platforms in the game.
+ * The initial set of platforms are ordered from left to right in space.
+ * Usage: take the first platform, remake it into the next platform, and
+ * move it to the end of the list.
+ */
public LinkedList<Platform> platforms;
-
+ /**
+ * Creates a PlatformController.
+ * Creates a starting set of platforms at increasing x-distance, each
+ * varying in height by a random amount.
+ * @param platformFactory A PlatformFactory that generates Platforms
+ * that are visible and physical.
+ */
public PlatformController(PlatformFactory platformFactory){
platforms = new LinkedList<Platform>();
Platform platform;
@@ -35,17 +49,28 @@ public PlatformController(PlatformFactory platformFactory){
random=new Random();
randomNumber=(random.nextInt(9)-4);
platform = platformFactory.createPlatform();
- platform.setPlatformPosition(new Vector3f((P.platformDistance+2*P.platformLength)*i,
- (float)(platforms.getLast().getPlatformPosition().y+randomNumber),0));
+ platform.setPlatformPosition(new Vector3f(
+ (P.platformDistance + 2 * P.platformLength) * i,
+ (float)(platforms.getLast().getPlatformPosition().y +
+ randomNumber), 0));
this.platforms.addLast(platform);
}
}
+ /**
+ * Adds a platform to the end of the list.
+ * The normal usage is to always have the rightmost platform at the
+ * end of the list.
+ * @param platform The platform to add.
+ */
public void addPlatform(Platform platform){
this.platforms.add(platform);
}
+ /**
+ * Deletes the first (usually leftmost) platform.
+ */
public void deletePlatform() {
platforms.remove(0);
}
@@ -21,7 +21,10 @@
*/
/**
- *
+ * Class for keeping everything relating to the player in one place.
+ * Currently keeps the spatial (along with the model) and the physics control
+ * object which makes the player run and fall.
+ *
* @author dagen
*/
public class Player {
@@ -33,20 +36,28 @@
// Physics connection
public CharacterControl characterControl;
-
+ /**
+ * Generates the player.
+ * @param dataSource An object that generates the spatial to be used to
+ * represent the player.
+ */
public Player(SceneObjectDataSource dataSource){
Node node = new Node();
// meshNode = new Node();
this.meshNode = new Node();
Spatial spatial = dataSource.getSceneObject();
+ // create a CharacterControl, controlling the (physical) behaviour of
+ // the player.
CapsuleCollisionShape shape = new CapsuleCollisionShape(1f,0.5f);
CharacterControl characterControl = new CharacterControl(shape, 0.05f);
- characterControl.setJumpSpeed(P.jump_speed);
+ // set the constant walking direction and jump speed
Vector3f walkDirection = Vector3f.UNIT_X.multLocal(P.run_speed);
characterControl.setWalkDirection(walkDirection);
+ characterControl.setJumpSpeed(P.jump_speed);
+ // Place the player in the world
Vector3f vt = new Vector3f(0, 15f, 0);
spatial.setLocalTranslation(vt);
@@ -7,7 +7,11 @@
import com.jme3.scene.Spatial;
/**
- *
+ * An interface for classes which generate spatials.
+ * A SceneObjectDataSource can generate a spatial to use for a certain purpose,
+ * such as to represent the player or a platform. Each such object has other
+ * properties as well, not contained in the spatial, and DataSources make sure
+ * whatever needed the spatial need not concern itself with its details.
* @author dagen
*/
public interface SceneObjectDataSource {
@@ -16,7 +16,10 @@
import java.io.IOException;
/**
- *
+ * A class to keep a SpotLight focussed on a spatial.
+ * Optionally also keeps a PssmShadowRenderer in the same diretion,
+ * making sure the shadow follows the light's movements.
+ *
* @author jonatankilhamn
*/
public class ShadowedSpotlightControl implements Control {
@@ -27,26 +30,46 @@
PssmShadowRenderer shadowRenderer;
Vector3f defaultPositionOffset = new Vector3f(0,50,0);
+ /**
+ * @param spotlight The spotlight to keep aimed at a spatial.
+ */
public ShadowedSpotlightControl(SpotLight spotlight) {
super();
this.spotlight = spotlight;
}
+ /**
+ * @Inheritdoc
+ */
public Control cloneForSpatial(Spatial spatial) {
ShadowedSpotlightControl newSSC = new ShadowedSpotlightControl((SpotLight)spotlight.clone());
newSSC.setSpatial(spatial);
return newSSC;
}
+ /**
+ * @Inheritdoc
+ */
public void setSpatial(Spatial spatial) {
this.spatial = spatial;
update(0f);
}
+ /**
+ * Sets the shadowrenderer to follow this light.
+ * More than one shadowrenderers can be active in a scene, and could
+ * then follow one light each.
+ * @param shadowRenderer
+ */
public void setShadowRenderer(PssmShadowRenderer shadowRenderer) {
this.shadowRenderer = shadowRenderer;
}
+ /**
+ * Sets the default relative position between the spotlight
+ * and the spatial it is shining on.
+ * @param defaultPositionOffset
+ */
public void setDefaultPositionOffset(Vector3f defaultPositionOffset) {
this.defaultPositionOffset = defaultPositionOffset;
}

0 comments on commit ed24706

Please sign in to comment.