Class Replay

java.lang.Object
com.codename1.gaming.platformer.Replay

public final class Replay extends Object

Plays a recorded run against a level and reports what happened, which is how a server verifies a score instead of trusting it.

import com.codename1.gaming.platformer.*;

// levelJson, seed, upload and claimedTicks arrive with the player's claim
String levelJson = "{\"tileSize\":16,\"tiles\":[\"....\",\"####\"]}";
long seed = 1;
String upload = new InputLog().encode();
int claimedTicks = 0;
Replay.Result r = Replay.run(LevelData.parse(levelJson), seed, InputLog.decode(upload, 60 * 60 * 15));
if (r.isComplete() && r.getTicks() == claimedTicks) {
    // the time is real
}
  • Method Details

    • run

      public static Replay.Result run(LevelData level, long seed, InputLog log)

      Replays a log, stopping at the tick the goal is reached.

      Parameters
      • level: the level
      • seed: the seed the run used
      • log: the recorded input
      Returns

      the outcome