/* Running uses stamina 2.0, by szmol96 http://www.jazz2online.com/snippets/90/running-uses-stamina/ */ int stamina = 0; int staminaMax = 100; //Increase this value to have more stamina. void onPlayer(jjPLAYER@ p) { if (jjGameTicks%10==0 && p.xSpeed == 0) stamina++; if (stamina < 0) stamina = 0; if (stamina > staminaMax) stamina = staminaMax; if (p.keyRun == true && p.keyLeft == true && p.xSpeed < 4 || p.keyRun == true && p.keyRight == true && p.xSpeed > 4) { if (jjGameTicks%7 == 0) { stamina--; } } if (p.keyRun == false && p.keyLeft == true && p.xSpeed < 0 || p.keyRun == false && p.keyRight == true && p.xSpeed > 0) { if (jjGameTicks%17 == 0) stamina++; } if (stamina < 1 && p.xSpeed > 4) p.xSpeed = 4; if (stamina < 1 && p.xSpeed < -4) p.xSpeed = -4; } bool onDrawHealth(jjPLAYER@ p, jjCANVAS@ screen) { screen.drawString(100, 470, "STAMINA: " + stamina + "/100", STRING::SMALL, STRING::NORMAL); return true; } void onLevelLoad() { stamina = staminaMax; }