Downloads containing ab23btl15.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Anniversary Bash 23 levels Jazz2Online Multiple N/A Download file

File preview

  1. #include "MLLE-Include-1.5.asc" ///@MLLE-Generated
  2. const bool MLLESetupSuccessful = MLLE::Setup();
  3. #pragma require "ab23btl15.j2l"
  4. #pragma require "Castle1.j2t"
  5. #pragma require "diamondus frozen.j2t"
  6. #pragma require "Hocus013D.j2t"
  7. #pragma require "JJ1Deserto.j2t"
  8. #pragma require "Medivo2.j2t"
  9.  
  10. enum BONUS_STATE {BONUS_OFF, BONUS_FIRE, BONUS_WATER, BONUS_SEEKERS };
  11.  
  12. /* Academy, written by CJ/Superjazz */
  13. const int ELEVATOR_TILE_X = 144;
  14. const int ELEVATOR_TILE_Y = 48;
  15. const int TEXT_BOX_BODY_COLOR = 98;
  16. const int TEXT_BOX_BORDER_COLOR = 100;
  17. const int TILE = 32;
  18. const int VERTICAL_FLIP_EVENT_ID = 149;
  19. const string ACADEMY_LITE_INFO_TEXT = "Welcome to Academy LITE! No spells or fancy stuff here.";
  20. const array<int> coinBonusLocation = {4740, 334};
  21. const array<array<int>> gemBonusLocations = {{1540, 2666}, {2596, 2762}};
  22.  
  23. array<BONUS_STATE> bonusStates = { BONUS_OFF, BONUS_OFF, BONUS_OFF, BONUS_OFF };
  24.  
  25. void drawBonus(jjPLAYER@ play, jjCANVAS@ canvas) {
  26.         jjTEXTAPPEARANCE centeredText();
  27.         centeredText.align = STRING::CENTER;
  28.         drawBox(canvas, jjSubscreenWidth / 2 - 94, jjSubscreenHeight / 2 - 52, 192, 128,
  29.                         TEXT_BOX_BODY_COLOR, SPRITE::TRANSLUCENT, true, TEXT_BOX_BORDER_COLOR);
  30.         switch (bonusStates[play.localPlayerID]) {
  31.                 case BONUS_SEEKERS:
  32.                         drawBonusSeekers(play, canvas, centeredText);
  33.                 break;
  34.                 case BONUS_FIRE:
  35.                         drawBonusFire(play, canvas, centeredText);
  36.                 break;
  37.                 case BONUS_WATER:
  38.                         drawBonusWater(play, canvas, centeredText);
  39.                 break;
  40.         }
  41. }
  42.  
  43. void drawBonusFire(jjPLAYER@ play, jjCANVAS@ canvas, jjTEXTAPPEARANCE centeredText) {
  44.         for (uint i = 5; i > 0; i--) {
  45.                 canvas.drawString(jjSubscreenWidth / 2 - 56, jjSubscreenHeight / 2 + 88 - (i*24),
  46.                                 "" + (i*10) + "x", STRING::SMALL, centeredText);
  47.                 canvas.drawResizedSprite(jjSubscreenWidth / 2 - 28, jjSubscreenHeight / 2 + 86 - (i*24),
  48.                                 ANIM::PICKUPS, 34, 0, 0.3, 0.3, SPRITE::GEM, 3);
  49.                 canvas.drawString(jjSubscreenWidth / 2 + 16, jjSubscreenHeight / 2 + 88 - (i*24),
  50.                                 " = " + (i*25) + "s", STRING::SMALL, centeredText);
  51.                 canvas.drawResizedSprite(jjSubscreenWidth / 2 + 64, jjSubscreenHeight / 2 + 84 - (i*24),
  52.                                 ANIM::PICKUPS, 31, 0, 0.6, 0.6);
  53.         }
  54. }
  55.  
  56. void drawBonusSeekers(jjPLAYER@ play, jjCANVAS@ canvas, jjTEXTAPPEARANCE centeredText) {
  57.         canvas.drawString(jjSubscreenWidth / 2, jjSubscreenHeight / 2 - 56,
  58.                                 "MAX 50x", STRING::SMALL, centeredText);
  59.         for (uint i = 5; i > 0; i--) {
  60.                 canvas.drawString(jjSubscreenWidth / 2 - 56, jjSubscreenHeight / 2 + 88 - (i*24),
  61.                                 "" + (i*20) + "x", STRING::SMALL, centeredText);
  62.                 canvas.drawResizedSprite(jjSubscreenWidth / 2 - 24, jjSubscreenHeight / 2 + 86 - (i*24),
  63.                                 ANIM::PICKUPS, 84, 0, 0.8, 0.8);
  64.                 canvas.drawString(jjSubscreenWidth / 2 + 16, jjSubscreenHeight / 2 + 88 - (i*24),
  65.                                 " = " + (i*10) + "x", STRING::SMALL, centeredText);
  66.                 canvas.drawResizedSprite(jjSubscreenWidth / 2 + 64, jjSubscreenHeight / 2 + 86 - (i*24),
  67.                                 ANIM::AMMO, 42, 0, 1.2, 1.2);
  68.         }
  69. }
  70.  
  71. void drawBonusWater(jjPLAYER@ play, jjCANVAS@ canvas, jjTEXTAPPEARANCE centeredText) {
  72.         for (uint i = 5; i > 0; i--) {
  73.                 canvas.drawString(jjSubscreenWidth / 2 - 56, jjSubscreenHeight / 2 + 88 - (i*24),
  74.                                         "" + (i*10) + "x", STRING::SMALL, centeredText);
  75.                 canvas.drawResizedSprite(jjSubscreenWidth / 2 - 28, jjSubscreenHeight / 2 + 86 - (i*24),
  76.                                 ANIM::PICKUPS, 34, 0, 0.3, 0.3, SPRITE::GEM, 3);
  77.                 canvas.drawString(jjSubscreenWidth / 2 + 16, jjSubscreenHeight / 2 + 88 - (i*24),
  78.                                 " = " + (i*20) + "s", STRING::SMALL, centeredText);
  79.                 canvas.drawResizedSprite(jjSubscreenWidth / 2 + 64, jjSubscreenHeight / 2 + 84 - (i*24),
  80.                                 ANIM::PICKUPS, 10, 0, 0.6, 0.6);
  81.         }
  82. }
  83.  
  84. void drawBox(jjCANVAS@ canvas, int originX, int originY, int width, int height, int bodyColor,
  85.                 SPRITE::Mode spriteMode, bool borders = false, int borderColor = 0) {
  86.         canvas.drawRectangle(originX, originY, width, height, bodyColor, spriteMode);
  87.         if (borders) {
  88.                 canvas.drawRectangle(originX, originY, width, 1, borderColor, spriteMode);
  89.                 canvas.drawRectangle(originX, originY, 1, height, borderColor, spriteMode);
  90.                 canvas.drawRectangle(originX, originY + height, width, 1, borderColor, spriteMode);
  91.                 canvas.drawRectangle(originX + width, originY, 1, height, borderColor, spriteMode);
  92.         }
  93. }
  94.  
  95. void drawScaledArrow(jjCANVAS@ canvas, int x, int y, int angle, float scale) {
  96.         canvas.drawRotatedSprite(x, y, ANIM::FLAG, 0, 0, angle, scale, scale, SPRITE::SINGLECOLOR, 15);
  97. }
  98.  
  99. void flipVerticalTiles() {
  100.         for (int x = 0; x < jjLayerWidth[4]; x++) {
  101.                 for (int y = 0; y < jjLayerHeight[4]; y++) {
  102.                   uint16 tile = jjTileGet(4, x, y);
  103.                            
  104.                   if (jjEventGet(x, y) == VERTICAL_FLIP_EVENT_ID) jjTileSet(4, x, y, tile ^ TILE::VFLIPPED);
  105.                 }
  106.         }
  107. }
  108.  
  109. void givePoweredUpSeekers(jjPLAYER@ play, int amount) {
  110.         int currentSeekerAmmo = play.ammo[WEAPON::SEEKER];
  111.         play.ammo[WEAPON::SEEKER] = currentSeekerAmmo + amount;
  112.         play.powerup[WEAPON::SEEKER] = true;
  113.         if (play.ammo[WEAPON::SEEKER] > 50) {
  114.                 play.ammo[WEAPON::SEEKER] = 50;
  115.         }
  116.         jjSamplePriority(SOUND::COMMON_GLASS2);
  117.         bonusStates[play.localPlayerID] = BONUS_OFF;
  118. }
  119.  
  120. void giveShield(jjPLAYER@ play, int time, int shieldType) {
  121.         play.shieldTime += time;
  122.         play.shieldType = shieldType;
  123.         jjSamplePriority(SOUND::COMMON_BELL_FIRE);
  124.         bonusStates[play.localPlayerID] = BONUS_OFF;
  125. }
  126.  
  127. void handleBonus(jjPLAYER@ play) {
  128.         switch (bonusStates[play.localPlayerID]) {
  129.                 case BONUS_SEEKERS:
  130.                         handleBonusSeekers(play);
  131.                 break;
  132.                 case BONUS_FIRE:
  133.                         handleBonusFire(play);
  134.                 break;
  135.                 case BONUS_WATER:
  136.                         handleBonusWater(play);
  137.                 break;
  138.         }
  139. }
  140.  
  141. void handleBonusFire(jjPLAYER@ play) {
  142.         if (play.testForGems(50, GEM::PURPLE)) {
  143.                 giveShield(play, 8750, SHIELD::FIRE);
  144.         } else if (play.testForGems(40, GEM::PURPLE)) {
  145.                 giveShield(play, 7000, SHIELD::FIRE);
  146.         } else if (play.testForGems(30, GEM::PURPLE)) {
  147.                 giveShield(play, 5250, SHIELD::FIRE);
  148.         } else if (play.testForGems(20, GEM::PURPLE)) {
  149.                 giveShield(play, 3500, SHIELD::FIRE);
  150.         } else if (play.testForGems(10, GEM::PURPLE)) {
  151.                 giveShield(play, 1750, SHIELD::FIRE);
  152.         }
  153. }
  154.  
  155. void handleBonusSeekers(jjPLAYER@ play) {
  156.         if (play.testForCoins(100)) {
  157.                 givePoweredUpSeekers(play, 50);
  158.         } else if (play.testForCoins(80)) {
  159.                 givePoweredUpSeekers(play, 40);
  160.         } else if (play.testForCoins(60)) {
  161.                 givePoweredUpSeekers(play, 30);
  162.         } else if (play.testForCoins(40)) {
  163.                 givePoweredUpSeekers(play, 20);
  164.         } else if (play.testForCoins(20)) {
  165.                 givePoweredUpSeekers(play, 10);
  166.         }
  167. }
  168.  
  169. void handleBonusWater(jjPLAYER@ play) {
  170.         if (play.testForGems(50, GEM::PURPLE)) {
  171.                 giveShield(play, 7000, SHIELD::WATER);
  172.         } else if (play.testForGems(40, GEM::PURPLE)) {
  173.                 giveShield(play, 5600, SHIELD::WATER);
  174.         } else if (play.testForGems(30, GEM::PURPLE)) {
  175.                 giveShield(play, 4200, SHIELD::WATER);
  176.         } else if (play.testForGems(20, GEM::PURPLE)) {
  177.                 giveShield(play, 2800, SHIELD::WATER);
  178.         } else if (play.testForGems(10, GEM::PURPLE)) {
  179.                 giveShield(play, 1400, SHIELD::WATER);
  180.         }
  181. }
  182.  
  183. bool onDrawAmmo(jjPLAYER@ play, jjCANVAS@ canvas) {
  184.         if (bonusStates[play.localPlayerID] != BONUS_OFF) {
  185.                 drawBonus(play, canvas);
  186.         }
  187.         return false;
  188. }
  189.  
  190. void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ canvas) {
  191.         drawScaledArrow(canvas, ELEVATOR_TILE_X * TILE + 16, ELEVATOR_TILE_Y * TILE + 16, 196, 0.7);
  192.         for (uint i = 0; i < gemBonusLocations.length; i++) {
  193.                 array<int> location = gemBonusLocations[i];
  194.                 canvas.drawResizedSprite(location[0], location[1], ANIM::PICKUPS, 34, 0, 0.3, 0.3, SPRITE::GEM, 3);
  195.         }
  196.         canvas.drawResizedSprite(coinBonusLocation[0], coinBonusLocation[1], ANIM::PICKUPS, 84, 0, 0.8, 0.8);
  197. }
  198.  
  199. void onFunction0(jjPLAYER@ play) {
  200.         bonusStates[play.localPlayerID] = BONUS_OFF;
  201.         play.noFire = false;
  202.         jjEnabledASFunctions[1] = true;
  203.         jjEnabledASFunctions[2] = true;
  204.         jjEnabledASFunctions[3] = true;
  205. }
  206.  
  207. void onFunction1(jjPLAYER@ play) {
  208.         bonusStates[play.localPlayerID] = BONUS_SEEKERS;
  209.         play.noFire = true;
  210. }
  211.  
  212. void onFunction2(jjPLAYER@ play) {
  213.         bonusStates[play.localPlayerID] = BONUS_WATER;
  214.         play.noFire = true;
  215. }
  216.  
  217. void onFunction3(jjPLAYER@ play) {
  218.         bonusStates[play.localPlayerID] = BONUS_FIRE;
  219.         play.noFire = true;
  220. }
  221.  
  222. void onLevelBegin() {
  223.         flipVerticalTiles();
  224.         jjConsole(ACADEMY_LITE_INFO_TEXT);
  225. }
  226.  
  227. void onPlayerInput(jjPLAYER@ play) {
  228.         if (play.keyUp && int(play.xPos/TILE) == ELEVATOR_TILE_X && int(play.yPos/TILE) == ELEVATOR_TILE_Y) {
  229.                 play.warpToID(0, true);
  230.         }
  231.         if (play.keyFire && bonusStates[play.localPlayerID] != BONUS_OFF) {
  232.                 handleBonus(play);
  233.         }
  234. }