Downloads containing xlmacademylite_backup.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Academy Superjazz Battle N/A Download file

File preview

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