Initial replay recording support.
- Added listener and events in Game state to record replay frames. - Send more accurate keys. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -237,9 +237,9 @@ public class Replay {
|
||||
// life data
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (lifeFrames != null) {
|
||||
NumberFormat nf = new DecimalFormat("##.##");
|
||||
NumberFormat nf = new DecimalFormat("##.##");
|
||||
for (int i = 0; i < lifeFrames.length; i++) {
|
||||
LifeFrame frame = lifeFrames[i];
|
||||
LifeFrame frame = lifeFrames[i];
|
||||
sb.append(String.format("%d|%s,",
|
||||
frame.getTime(), nf.format(frame.getPercentage())));
|
||||
}
|
||||
|
||||
@@ -44,8 +44,16 @@ public class ReplayFrame {
|
||||
private float x, y;
|
||||
|
||||
/** Keys pressed (bitmask). */
|
||||
private int keys;
|
||||
|
||||
private int keys;
|
||||
|
||||
/**
|
||||
* Returns the start frame.
|
||||
* @param t the value for the {@code time} and {@code timeDiff} fields
|
||||
*/
|
||||
public static ReplayFrame getStartFrame(int t) {
|
||||
return new ReplayFrame(t, t, 256, -500, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param timeDiff time since the previous action (in ms)
|
||||
@@ -72,6 +80,11 @@ public class ReplayFrame {
|
||||
*/
|
||||
public int getTimeDiff() { return timeDiff; }
|
||||
|
||||
/**
|
||||
* Sets the time since the previous action, in milliseconds.
|
||||
*/
|
||||
public void setTimeDiff(int diff) { this.timeDiff = diff; }
|
||||
|
||||
/**
|
||||
* Returns the scaled cursor x coordinate.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user