Downloads containing ab21ctf08.j2as

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

File preview

  1. #include "MLLE-Include-1.4.asc"
  2. const bool MLLESetupSuccessful = MLLE::Setup();
  3. #pragma require "ab21ctf08-MLLE-Data-1.j2l"
  4. #pragma require "ab21ctf08.j2l"
  5. #pragma require "Scraparap2.j2t"
  6. #pragma require "Oasis.j2t"
  7. #pragma require "Twilight Park.j2t"
  8.  
  9. #pragma require "Castle2E.j2t"
  10.  
  11. void onLevelLoad() {
  12.         jjWaterLayer = 12;
  13.         jjSetWaterGradient(255,0,255, 0,0,0);
  14.        
  15.         jjTexturedBGFadePositionY = 0.4f;
  16.         jjWaterChangeSpeed = 0;
  17.        
  18.         jjPAL eclipse;
  19.         eclipse.load("Castle2E.j2t");
  20.         jjPalette.copyFrom(1, 47, 1, eclipse, 0.75f);
  21.         jjPalette.copyFrom(56, 16, 56, eclipse, 0.75f);
  22.         jjPalette.copyFrom(80, 16, 80, eclipse, 0.75f);
  23.         jjPalette.apply();
  24.        
  25.         jjANIMFRAME@ frame;
  26.        
  27.         //Big Palmtree
  28.         @frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::SPIKEPLAT].firstAnim].firstFrame];
  29.                 jjPIXELMAP(0, 0, 4*32, 5*32, 5).save(frame);
  30.                 frame.hotSpotX = -frame.width/2;
  31.                 frame.hotSpotY = -frame.height;
  32.                
  33.                 //Medium Palmtree
  34.         @frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::FRUITPLAT].firstAnim].firstFrame];
  35.                 jjPIXELMAP(7*32, 0, 3*32, 4*32, 5).save(frame);
  36.                 frame.hotSpotX = -frame.width/2;
  37.                 frame.hotSpotY = -frame.height;
  38.                
  39.         //Small Palmtree
  40.         @frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::GRASSPLAT].firstAnim].firstFrame];
  41.                 jjPIXELMAP(4*32, 0, 3*32, 4*32, 5).save(frame);
  42.                 frame.hotSpotX = -frame.width/2;
  43.                 frame.hotSpotY = -frame.height;
  44.                
  45.                 jjWeapons[WEAPON::TNT].maximum = 3;
  46.                 jjObjectPresets[OBJECT::TNT].counterEnd = 4;
  47.                
  48.                 jjObjectPresets[OBJECT::BOUNCERPOWERUP].direction = SPRITE::FLIPV;
  49.                 jjObjectPresets[OBJECT::TOASTERPOWERUP].direction = SPRITE::FLIPV;
  50.                
  51.         jjObjectPresets[OBJECT::TNTDESTRUCTSCENERY].behavior = NoSprite;
  52.        
  53.                 generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40});
  54.                 turnIntoCustomSpring(jjObjectPresets[OBJECT::GREENSPRING], 0, 24.f, false);
  55.        
  56.         jjUseLayer8Speeds = true;
  57. }
  58.  
  59. void NoSprite(jjOBJ@ obj) {
  60.     obj.behave(BEHAVIOR::DESTRUCTSCENERY);
  61.     obj.curFrame = 0;
  62.     obj.behavior = BEHAVIOR::DESTRUCTSCENERY;
  63. }
  64.  
  65. jjANIMSET@ customSpringSprite;
  66. array<int> fastCustomSpringSpeeds(jjLocalPlayerCount);
  67. bool generateCustomSpringSprites(jjANIMSET@ anim, const array<uint> &in colors) {
  68.         int length = colors.length();
  69.         bool success = (@customSpringSprite = anim).allocate(array<uint>(length * 3, 5)) !is null;
  70.         if (success) {
  71.                 uint srcSet = jjAnimSets[ANIM::SPRING];
  72.                 for (int i = 0; i < length; i++) {
  73.                         uint color = colors[i];
  74.                         uint destAnimOffset = anim + i * 3;
  75.                         for (int j = 0; j < 3; j++) {
  76.                                 uint srcAnim = jjAnimations[srcSet + j];
  77.                                 uint destAnim = jjAnimations[destAnimOffset + j];
  78.                                 for (int k = 0; k < 5; k++) {
  79.                                         jjPIXELMAP image(jjAnimFrames[destAnim + k] = jjAnimFrames[srcAnim + k]);
  80.                                         int width = image.width;
  81.                                         int height = image.height;
  82.                                         for (int l = 0; l < height; l++) {
  83.                                                 for (int m = 0; m < width; m++) {
  84.                                                         int pixel = image[m, l];
  85.                                                         if (pixel >= 32 && pixel < 40)
  86.                                                                 image[m, l] = color + (pixel & 7);
  87.                                                 }
  88.                                         }
  89.                                         if (!image.save(jjAnimFrames[destAnim + k]))
  90.                                                 return false;
  91.                                 }
  92.                         }
  93.                 }
  94.         }
  95.         return success;
  96. }
  97. void initializeCustomSpring(jjOBJ@ obj) {
  98.         int anim = obj.curAnim;
  99.         obj.behave(obj.behavior = BEHAVIOR::SPRING, false);
  100.         if (obj.curAnim != anim) {
  101.                 obj.curAnim = anim + 2;
  102.                 obj.determineCurFrame();
  103.         }
  104.         obj.draw();
  105. }
  106. void turnIntoCustomSpring(jjOBJ@ obj, uint color, float power, bool horizontal) {
  107.         if (horizontal) {
  108.                 obj.xSpeed = power;
  109.                 obj.ySpeed = 0.f;
  110.         } else {
  111.                 obj.xSpeed = 0.f;
  112.                 obj.ySpeed = -power;
  113.                 if (obj.state == STATE::START && obj.creatorType == CREATOR::LEVEL) {
  114.                         int x = int(obj.xPos) >> 5;
  115.                         int y = int(obj.yPos) >> 5;
  116.                         if (jjParameterGet(x, y, 0, 1) != 0) {
  117.                                 jjParameterSet(x, y, 0, 1, 0);
  118.                                 obj.yPos -= 4.f;
  119.                                 obj.ySpeed = power;
  120.                         }
  121.                 }
  122.         }
  123.         obj.behavior = initializeCustomSpring;
  124.         obj.curAnim = customSpringSprite + color * 3 + (horizontal ? 1 : 0);
  125.         obj.energy = obj.frameID = obj.freeze = obj.justHit = obj.light = obj.points = 0;
  126.         obj.isBlastable = obj.isTarget = obj.scriptedCollisions = obj.triggersTNT = false;
  127.         obj.deactivates = obj.isFreezable = true;
  128.         obj.bulletHandling = HANDLING::IGNOREBULLET;
  129.         obj.playerHandling = HANDLING::SPECIAL;
  130.         obj.lightType = LIGHT::NORMAL;
  131.         obj.determineCurFrame();
  132. }
  133.  
  134. void onDrawLayer1(jjPLAYER@ play, jjCANVAS@ screen) {
  135.         jjLayers[1].yOffset = jjLayers[1].yOffset + 1.25f;
  136.         if (jjLayers[1].yOffset > 24) jjLayers[1].yOffset = -24;
  137. }
  138.  
  139. void onDrawLayer6(jjPLAYER@ play, jjCANVAS@ screen) {
  140.         jjSetWaterLevel(play.cameraY + 224, true);
  141. }
  142.  
  143. void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ screen) {
  144.         jjSetWaterLevel(16000, true);
  145. }
  146.  
  147. //stolen from violet, and also suboptimal, but time is short
  148. void onDrawLayer5(jjPLAYER@ play, jjCANVAS@ screen) {
  149.                 //blue base palm
  150.         screen.drawRotatedSprite(int(21*32), int(29*32) + 4, ANIM::SPIKEPLAT, 0, 0, int(jjSin(jjGameTicks << 2) * 28),  1, 1, SPRITE::SINGLECOLOR, int(jjSin(jjGameTicks*3)*12) + 160);
  151.        
  152.                 //red base palm
  153.         screen.drawRotatedSprite(int(113*32), int(30*32) + 4, ANIM::SPIKEPLAT, 0, 0, int(jjSin(jjGameTicks << 2) * 28), -1, 1, SPRITE::SINGLECOLOR, int(jjSin(jjGameTicks*3)*12) + 160);
  154.        
  155.         //big magnet palms
  156.         screen.drawRotatedSprite(int(57*32), int(45*32) + 4, ANIM::FRUITPLAT, 0, 0, int(jjSin(jjGameTicks << 2) * 20), -1, 1, SPRITE::SINGLECOLOR, int(jjSin(jjGameTicks*2)*12) + 160);
  157.         screen.drawRotatedSprite(int(70*32), int(45*32) + 4, ANIM::GRASSPLAT, 0, 0, int(jjSin(jjGameTicks << 2) * 14), -1, 1, SPRITE::SINGLECOLOR, int(jjSin(jjGameTicks*3)*7) + 163);
  158.        
  159.         //big bottom palm
  160.         //screen.drawRotatedSprite(int(64*32), int(62*32) + 4, ANIM::SPIKEPLAT, 0, 0, int(jjSin(jjGameTicks << 2) * 28), -1, -1, SPRITE::SINGLECOLOR, int(jjSin(jjGameTicks*4)*14) + 161);
  161.        
  162.         //misc ones
  163.         screen.drawRotatedSprite(int(35*32), int(58*32) + 12, ANIM::FRUITPLAT, 0, 0, int(jjSin(jjGameTicks << 2) * 28),  1, 1, SPRITE::SINGLECOLOR, int(jjSin(jjGameTicks*3)*7) + 163);
  164.                 //screen.drawRotatedSprite(int(110*32), int(57*32) + 4, ANIM::GRASSPLAT, 0, 0, int(jjSin(jjGameTicks << 2) * 14), 1, 1, SPRITE::SINGLECOLOR, int(jjSin(jjGameTicks*2)*12) + 160);
  165.                 screen.drawRotatedSprite(int(100*32), int(54*32) + 4, ANIM::FRUITPLAT, 0, 0, int(jjSin(jjGameTicks << 2) * 20), -1, 1, SPRITE::SINGLECOLOR, int(jjSin(jjGameTicks*3)*7) + 163);
  166. }
  167.  
  168. void onPlayer(jjPLAYER@ play) {
  169.                 if (play.yPos < 9*32 + 16) jjTriggers[1] = true;
  170.                 else if (play.yPos > 16*32) jjTriggers[1] = false;
  171.                
  172.                 //fix for getting stuck inside magnets, thanks SE                              
  173.                 const int x = int(play.xPos);
  174.                 const int y = int(play.yPos);
  175.                 const int left = x - 12;
  176.                 const int right = x + 12;
  177.                 const int top = y - (play.antiGrav ? 18 : 6);
  178.                 const int bottom = y + (play.antiGrav ? 6 : 18);
  179.                 const int middle = (top + bottom) >>> 1;
  180.                 const array<int> passThroughEvents = {AREA::HOOK, AREA::ONEWAY, AREA::VINE};
  181.                 int counter = 0;
  182.                 int direction = 0;
  183.                 int topmost = bottom;
  184.                 int bottommost = top;
  185.                 for (int i = top; i <= bottom; i++) {
  186.                     for (int j = left; j < right; j++) {
  187.                         if (jjMaskedPixel(j, i) && passThroughEvents.find(jjEventAtLastMaskedPixel) < 0) {
  188.                             counter++;
  189.                             direction += i < middle ? 1 : i > middle ? -1 : 0;
  190.                             if (i < topmost)
  191.                                 topmost = i;
  192.                             if (i > bottommost)
  193.                                 bottommost = i;
  194.                         }
  195.                     }
  196.                 }
  197.                 if (counter > 32) {
  198.                     if (direction > 0)
  199.                         play.yPos += bottommost - top;
  200.                     else if (direction < 0)
  201.                         play.yPos += topmost - bottom;
  202.                 }
  203. }