Class Replay
java.lang.Object
com.codename1.gaming.platformer.Replay
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
}
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Replay.ResultReplays a log, stopping at the tick the goal is reached.
-
Method Details
-
run
Replays a log, stopping at the tick the goal is reached.
Parameters
level: the levelseed: the seed the run usedlog: the recorded input
Returns
the outcome
-