Example of implementing a scoring system in a simple distance-based jumping challenge.
The goal is to jump as far as you can, and use the distance as a record value.
#include "uniTestManagerApi.asc"
const int JUMP_START_POS_X = 14 * 32;
void onLevelLoad()
{
jjPUBLICINTERFACE@ pi = jjGetPublicInterface("uniTM.mut");
if (pi !is null)
{
@tm = cast<UniTM::ITestManagerApi>(pi);
if (tm !is null && jjIsServer) tm.configureCustomRanking(
true,
"tile",
"tiles",
false,
1
);
}
}
void onFunction0(jjPLAYER@ player)
{
if (tm !is null) tm.initTest(player);
}
void onFunction1(jjPLAYER@ player)
{
if (tm !is null) tm.beginTest(player);
}
void onFunction2(jjPLAYER@ player)
{
if (player.warpID == 0)
{
int record = (int(player.xPos) - JUMP_START_POS_X) * 100 / 32;
if (tm !is null)
{
jjAlert("|||||||Your score: ||||" + tm.formatRecord(record));
}
player.warpToID(0);
}
}
const uint8 ON_NEW_PERSONAL_BEST
Definition uniTestManagerApi.asc:290
const uint8 DECIMAL2
Definition uniTestManagerApi.asc:267
Definition uniTestManagerApi.asc:14