put more information in gameobject
This commit is contained in:
parent
4769c1cfda
commit
e7e33cd406
|
@ -25,13 +25,25 @@ import org.newdawn.slick.Graphics;
|
||||||
/**
|
/**
|
||||||
* Interface for hit object types used during gameplay.
|
* Interface for hit object types used during gameplay.
|
||||||
*/
|
*/
|
||||||
public interface GameObject {
|
public abstract class GameObject {
|
||||||
|
|
||||||
|
public Vec2f start;
|
||||||
|
public Vec2f end;
|
||||||
|
|
||||||
|
private int time;
|
||||||
|
|
||||||
|
public void updateStartEndPositions(int startTime) {
|
||||||
|
time = startTime;
|
||||||
|
start = getPointAt(startTime);
|
||||||
|
end = getPointAt(getEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the hit object to the graphics context.
|
* Draws the hit object to the graphics context.
|
||||||
* @param g the graphics context
|
* @param g the graphics context
|
||||||
* @param trackPosition the current track position
|
* @param trackPosition the current track position
|
||||||
*/
|
*/
|
||||||
public void draw(Graphics g, int trackPosition);
|
public abstract void draw(Graphics g, int trackPosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the hit object.
|
* Updates the hit object.
|
||||||
|
@ -43,7 +55,7 @@ public interface GameObject {
|
||||||
* @param trackPosition the track position
|
* @param trackPosition the track position
|
||||||
* @return true if object ended
|
* @return true if object ended
|
||||||
*/
|
*/
|
||||||
public boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition);
|
public abstract boolean update(boolean overlap, int delta, int mouseX, int mouseY, boolean keyPressed, int trackPosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a mouse click.
|
* Processes a mouse click.
|
||||||
|
@ -52,28 +64,32 @@ public interface GameObject {
|
||||||
* @param trackPosition the track position
|
* @param trackPosition the track position
|
||||||
* @return true if a hit result was processed
|
* @return true if a hit result was processed
|
||||||
*/
|
*/
|
||||||
public boolean mousePressed(int x, int y, int trackPosition);
|
public abstract boolean mousePressed(int x, int y, int trackPosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the coordinates of the hit object at a given track position.
|
* Returns the coordinates of the hit object at a given track position.
|
||||||
* @param trackPosition the track position
|
* @param trackPosition the track position
|
||||||
* @return the position vector
|
* @return the position vector
|
||||||
*/
|
*/
|
||||||
public Vec2f getPointAt(int trackPosition);
|
public abstract Vec2f getPointAt(int trackPosition);
|
||||||
|
|
||||||
|
public int getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the end time of the hit object.
|
* Returns the end time of the hit object.
|
||||||
* @return the end time, in milliseconds
|
* @return the end time, in milliseconds
|
||||||
*/
|
*/
|
||||||
public int getEndTime();
|
public abstract int getEndTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the position of the hit object.
|
* Updates the position of the hit object.
|
||||||
*/
|
*/
|
||||||
public void updatePosition();
|
public abstract void updatePosition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets all internal state so that the hit object can be reused.
|
* Resets all internal state so that the hit object can be reused.
|
||||||
*/
|
*/
|
||||||
public void reset();
|
public abstract void reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1216,8 +1216,8 @@ public class Game extends BasicGameState {
|
||||||
ErrorHandler.error(String.format("Failed to create %s at index %d:\n%s",
|
ErrorHandler.error(String.format("Failed to create %s at index %d:\n%s",
|
||||||
hitObject.getTypeName(), i, hitObject.toString()), e, true);
|
hitObject.getTypeName(), i, hitObject.toString()), e, true);
|
||||||
gameObjects[i] = new DummyObject(hitObject);
|
gameObjects[i] = new DummyObject(hitObject);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
gameObjects[i].updateStartEndPositions(hitObjectTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stack calculations
|
// stack calculations
|
||||||
|
|
Loading…
Reference in New Issue
Block a user