Downloads containing ab20btl19.j2as

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

File preview

  1. #pragma require "Heaven.j2t"
  2. #pragma require "ab20btl19-Extra.j2l"
  3.  
  4. void onLevelLoad() {
  5.         loadExtraLayers();
  6.  
  7.         jjTilesFromTileset("Desolation03.j2t", 0, 0); //hack to restore current tileset's CRC32
  8.  
  9.         for (int eventID = OBJECT::BLASTERBULLET; eventID <= OBJECT::BULLET; ++eventID) {
  10.                 jjObjectPresets[eventID].behavior = BulletWrapper(jjObjectPresets[eventID].behavior);
  11.         }
  12. }
  13.  
  14. class BulletWrapper : jjBEHAVIORINTERFACE {
  15.         private jjBEHAVIOR nativeBehavior;
  16.         BulletWrapper(const jjBEHAVIOR &in nb) {
  17.                 nativeBehavior = nb;
  18.         }
  19.  
  20.         void onBehave(jjOBJ@ obj) {
  21.                 obj.behave(nativeBehavior);
  22.  
  23.                 float xPixelLimit = 1;
  24.                 if (obj.xPos > (jjLayers[4].width) * 32 - (xPixelLimit + 1) && obj.xSpeed > 0) {
  25.                         obj.xPos = xPixelLimit;
  26.                 } else if (obj.xPos < xPixelLimit && obj.xSpeed < 0) {
  27.                         obj.xPos = jjLayers[4].width * 32 + (xPixelLimit + 1);
  28.                 }
  29.         }
  30.         bool onIsRFBullet(jjOBJ@ obj) {
  31.                 return nativeBehavior == BEHAVIOR::RFBULLET;
  32.         }
  33. }
  34.  
  35. void loadExtraLayers() {
  36.         const int oldTileCount = jjTileCount;
  37.         if (!jjTilesFromTileset("Heaven.j2t", 520, 100)) { //first tileID
  38.                 jjAlert("|ERROR: Heaven.j2t not found!", false, STRING::MEDIUM);
  39.                 return;
  40.         }
  41.  
  42.         array<jjLAYER@> heavenLayers = jjLayersFromLevel(
  43.                 "ab20btl19-Extra.j2l",
  44.                 array<uint> = {6,7}, //Which (1-indexed) layers to copy
  45.                 oldTileCount - 520
  46.         );
  47.         if (heavenLayers.length == 0) {
  48.                 jjAlert("|ERROR: Heaven.j2l not found!", false, STRING::MEDIUM);
  49.                 return;
  50.         }
  51.  
  52.         for (uint layerID = 0; layerID < heavenLayers.length; ++layerID) {
  53.                 heavenLayers[layerID].yOffset = 10 * 32;
  54.                 heavenLayers[layerID].limitVisibleRegion = false;
  55.                 heavenLayers[layerID].spriteMode = SPRITE::TRANSLUCENTTILE;
  56.         }
  57.  
  58.         jjLAYER@ blackLayer = jjLAYER(4, jjLayers[6].height);
  59.         blackLayer.generateSettableTileArea();
  60.         blackLayer.xSpeed = jjLayers[6].xSpeed;
  61.         blackLayer.ySpeed = jjLayers[6].ySpeed;
  62.         blackLayer.tileWidth = true;
  63.         for (int y = 70; y < blackLayer.height; y++) {
  64.                 for (int x = 0; x < blackLayer.width; x++) {
  65.                         blackLayer.tileSet(x, y, 404); //black tile
  66.                 }
  67.         }
  68.  
  69.         array<jjLAYER@> extraBuildingLayers;
  70.         addBuilderLayers( 0, 4, 8, extraBuildingLayers);
  71.         addBuilderLayers(16, 4, 12, extraBuildingLayers);
  72.         addBuilderLayers(36, 4, 10, extraBuildingLayers);
  73.         addBuilderLayers(48, 4, 8, extraBuildingLayers);
  74.         addBuilderLayers(64, 4, 12, extraBuildingLayers);
  75.         addBuilderLayers(86, 4, 10, extraBuildingLayers);
  76.         addBuilderLayers(102, 4, 8, extraBuildingLayers);
  77.         //recreate first two to imitate tiled width
  78.         addBuilderLayers(120, 4, 8, extraBuildingLayers);
  79.         addBuilderLayers(136, 4, 12, extraBuildingLayers);
  80.         //recreate last to imitate tiled width
  81.         addBuilderLayers(-18, 4, 8, extraBuildingLayers);
  82.  
  83.         jjTexturedBGTexture = TEXTURE::WISETYNESS;
  84.         jjSetFadeColors(70, 64, 66); //above, but a bit darker
  85.         jjUseLayer8Speeds = true;
  86.         jjLayers[7].spriteMode = SPRITE::TRANSLUCENTTILE; //barely visible moon
  87.  
  88.         array<jjLAYER@> layers;
  89.         layers.insertLast(jjLayers[1]);
  90.         layers.insertLast(jjLayers[2]);
  91.         layers.insertLast(jjLayers[3]);
  92.         layers.insertLast(jjLayers[4]);
  93.         layers.insertLast(jjLayers[5]);
  94.         layers.insertLast(jjLayers[6]);
  95.         layers.insertLast(blackLayer);
  96.  
  97.         layers.insertAt(layers.length(), extraBuildingLayers);
  98.  
  99.         layers.insertLast(heavenLayers[0]);
  100.         layers.insertLast(heavenLayers[1]);
  101.         layers.insertLast(jjLayers[7]);
  102.         layers.insertLast(jjLayers[8]);
  103.         jjLayerOrderSet(layers);
  104. }
  105.  
  106. void addBuilderLayers(int xTile, int yStart, int buildingWidth, array<jjLAYER@>@ layers) {
  107.         int layerWidth = (buildingWidth + 3) & ~0x03;
  108.  
  109.         int xStart = 0;
  110.  
  111.         jjLAYER@ baseLayer = jjLAYER(layerWidth, 100);
  112.         baseLayer.generateSettableTileArea();
  113.         baseLayer.xSpeed = 0.75f;
  114.         baseLayer.ySpeed = 0.75f;
  115.         baseLayer.xOffset = 32 * (-1 - (xTile - buildingWidth / 2));
  116.         addBuilding(baseLayer, xStart, yStart, buildingWidth);
  117.  
  118.         layers.insertLast(baseLayer);
  119.  
  120.         int i = 10;
  121.         jjLAYER@ layer = jjLAYER(baseLayer);
  122.         layer.spriteMode = SPRITE::SINGLECOLOR;
  123.         layer.spriteParam = 200;
  124.         float speedOffset = (i + 1) / 256.0;
  125.         float offset = (i + 1) * ((5.375 * xTile) - (4 * buildingWidth) + 16) / 32;
  126.         layer.xSpeed -= speedOffset;
  127.         layer.xOffset += offset;
  128.         layers.insertLast(layer);
  129. }
  130.  
  131. void addBuilding(jjLAYER@ layer, int xStart, int yStart, int width) {
  132.         uint16 topLeft   = 640;
  133.         uint16 topMiddle = 641;
  134.         uint16 topRight  = 642;
  135.         uint16 left   = 650;
  136.         uint16 middle = 671; //light on
  137.         uint16 right  = 652;
  138.  
  139.         int xEnd = xStart + width;
  140.         int yEnd = layer.height;
  141.  
  142.         for (int x = xStart; x < xEnd; x++) {
  143.                 for (int y = yStart; y < yEnd; y++) {
  144.                         uint16 tileID;
  145.                         if (y == yStart) {
  146.                                 if (x == xStart) {
  147.                                         tileID = topLeft;
  148.                                 } else if (x == xEnd - 1) {
  149.                                         tileID = topRight;
  150.                                 } else {
  151.                                         tileID = topMiddle;
  152.                                 }
  153.                         } else if (x == xStart) {
  154.                                 tileID = left;
  155.                         } else if (x == xEnd - 1) {
  156.                                 tileID = right;
  157.                         } else {
  158.                                 tileID = middle;
  159.                         }
  160.                         layer.tileSet(x, y, tileID);
  161.                 }
  162.         }
  163. }
  164.  
  165. int min(int a, int b) {
  166.         return a < b ? a : b;
  167. }
  168.  
  169. void onPlayer(jjPLAYER@ player) {
  170.         float xPixelLimit = 1;
  171.         if (player.xPos > (jjLayers[4].width) * 32 - (xPixelLimit + 1) && player.xSpeed > 0) {
  172.                 player.offsetPosition(int(-(player.xPos - xPixelLimit)), 0);
  173.         } else if (player.xPos < xPixelLimit && player.xSpeed < 0) {
  174.                 player.offsetPosition(int(-(player.xPos - (jjLayers[4].width) * 32 - (xPixelLimit + 1))), 0);
  175.         }
  176. }
  177.