Downloads containing mlcrackdown.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: The CrackdownFeatured Download cooba Capture the flag 9 Download file

File preview

#include "MLLE-Include-1.4.asc"
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "mlcrackdown-MLLE-Data-1.j2l"
#pragma require "mlcrackdown.j2l"
#pragma require "Scraparap2.j2t"
#pragma require "Oasis.j2t"
#pragma require "Twilight Park.j2t"

#pragma require "Castle2E.j2t"

void onLevelLoad() {
        jjWaterLayer = 12;
        jjSetWaterGradient(255,0,255, 0,0,0);
        
        jjTexturedBGFadePositionY = 0.4f;
        jjWaterChangeSpeed = 0;
        
        jjPAL eclipse;
        eclipse.load("Castle2E.j2t");
        jjPalette.copyFrom(1, 47, 1, eclipse, 0.75f);
        jjPalette.copyFrom(56, 16, 56, eclipse, 0.75f);
        jjPalette.copyFrom(80, 16, 80, eclipse, 0.75f);
        jjPalette.apply();
        
        jjANIMFRAME@ frame;
        
        //Big Palmtree
        @frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::SPIKEPLAT].firstAnim].firstFrame];
		jjPIXELMAP(0, 0, 4*32, 5*32, 5).save(frame);
		frame.hotSpotX = -frame.width/2;
		frame.hotSpotY = -frame.height;
		
		//Medium Palmtree
        @frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::FRUITPLAT].firstAnim].firstFrame];
		jjPIXELMAP(7*32, 0, 3*32, 4*32, 5).save(frame);
		frame.hotSpotX = -frame.width/2;
		frame.hotSpotY = -frame.height;
		
        //Small Palmtree
        @frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::GRASSPLAT].firstAnim].firstFrame];
		jjPIXELMAP(4*32, 0, 3*32, 4*32, 5).save(frame);
		frame.hotSpotX = -frame.width/2;
		frame.hotSpotY = -frame.height;
		
		jjWeapons[WEAPON::TNT].maximum = 3;
		jjObjectPresets[OBJECT::TNT].counterEnd = 4;
		
		jjObjectPresets[OBJECT::BOUNCERPOWERUP].direction = SPRITE::FLIPV;
		jjObjectPresets[OBJECT::TOASTERPOWERUP].direction = SPRITE::FLIPV;
		
        jjObjectPresets[OBJECT::TNTDESTRUCTSCENERY].behavior = NoSprite;
        
		generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40});
		turnIntoCustomSpring(jjObjectPresets[OBJECT::GREENSPRING], 0, 24.f, false);
        
        jjUseLayer8Speeds = true;
}

void NoSprite(jjOBJ@ obj) {
    obj.behave(BEHAVIOR::DESTRUCTSCENERY);
    obj.curFrame = 0;
    obj.behavior = BEHAVIOR::DESTRUCTSCENERY;
}

jjANIMSET@ customSpringSprite;
array<int> fastCustomSpringSpeeds(jjLocalPlayerCount);
bool generateCustomSpringSprites(jjANIMSET@ anim, const array<uint> &in colors) {
	int length = colors.length();
	bool success = (@customSpringSprite = anim).allocate(array<uint>(length * 3, 5)) !is null;
	if (success) {
		uint srcSet = jjAnimSets[ANIM::SPRING];
		for (int i = 0; i < length; i++) {
			uint color = colors[i];
			uint destAnimOffset = anim + i * 3;
			for (int j = 0; j < 3; j++) {
				uint srcAnim = jjAnimations[srcSet + j];
				uint destAnim = jjAnimations[destAnimOffset + j];
				for (int k = 0; k < 5; k++) {
					jjPIXELMAP image(jjAnimFrames[destAnim + k] = jjAnimFrames[srcAnim + k]);
					int width = image.width;
					int height = image.height;
					for (int l = 0; l < height; l++) {
						for (int m = 0; m < width; m++) {
							int pixel = image[m, l];
							if (pixel >= 32 && pixel < 40)
								image[m, l] = color + (pixel & 7);
						}
					}
					if (!image.save(jjAnimFrames[destAnim + k]))
						return false;
				}
			}
		}
	}
	return success;
}
void initializeCustomSpring(jjOBJ@ obj) {
	int anim = obj.curAnim;
	obj.behave(obj.behavior = BEHAVIOR::SPRING, false);
	if (obj.curAnim != anim) {
		obj.curAnim = anim + 2;
		obj.determineCurFrame();
	}
	obj.draw();
}
void turnIntoCustomSpring(jjOBJ@ obj, uint color, float power, bool horizontal) {
	if (horizontal) {
		obj.xSpeed = power;
		obj.ySpeed = 0.f;
	} else {
		obj.xSpeed = 0.f;
		obj.ySpeed = -power;
		if (obj.state == STATE::START && obj.creatorType == CREATOR::LEVEL) {
			int x = int(obj.xPos) >> 5;
			int y = int(obj.yPos) >> 5;
			if (jjParameterGet(x, y, 0, 1) != 0) {
				jjParameterSet(x, y, 0, 1, 0);
				obj.yPos -= 4.f;
				obj.ySpeed = power;
			}
		}
	}
	obj.behavior = initializeCustomSpring;
	obj.curAnim = customSpringSprite + color * 3 + (horizontal ? 1 : 0);
	obj.energy = obj.frameID = obj.freeze = obj.justHit = obj.light = obj.points = 0;
	obj.isBlastable = obj.isTarget = obj.scriptedCollisions = obj.triggersTNT = false;
	obj.deactivates = obj.isFreezable = true;
	obj.bulletHandling = HANDLING::IGNOREBULLET;
	obj.playerHandling = HANDLING::SPECIAL;
	obj.lightType = LIGHT::NORMAL;
	obj.determineCurFrame();
}

void onDrawLayer1(jjPLAYER@ play, jjCANVAS@ screen) {
        jjLayers[1].yOffset = jjLayers[1].yOffset + 1.25f;
        if (jjLayers[1].yOffset > 24) jjLayers[1].yOffset = -24;
} 
 
void onDrawLayer6(jjPLAYER@ play, jjCANVAS@ screen) {
        jjSetWaterLevel(play.cameraY + 224, true);
} 
 
void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ screen) {
        jjSetWaterLevel(16000, true);
}

//stolen from violet, and also suboptimal, but time is short
void onDrawLayer5(jjPLAYER@ play, jjCANVAS@ screen) {
		//blue base palm
        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);
        
		//red base palm
        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);
        
        //big magnet palms
        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);
        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);
        
        //big bottom palm
        //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);
        
        //misc ones
        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);
		//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);
		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);
}

void onPlayer(jjPLAYER@ play) {
		if (play.yPos < 9*32 + 16) jjTriggers[1] = true;
		else if (play.yPos > 16*32) jjTriggers[1] = false;
		
		//fix for getting stuck inside magnets, thanks SE				
		const int x = int(play.xPos);
		const int y = int(play.yPos);
		const int left = x - 12;
		const int right = x + 12;
		const int top = y - (play.antiGrav ? 18 : 6);
		const int bottom = y + (play.antiGrav ? 6 : 18);
		const int middle = (top + bottom) >>> 1;
		const array<int> passThroughEvents = {AREA::HOOK, AREA::ONEWAY, AREA::VINE};
		int counter = 0;
		int direction = 0;
		int topmost = bottom;
		int bottommost = top;
		for (int i = top; i <= bottom; i++) {
		    for (int j = left; j < right; j++) {
		        if (jjMaskedPixel(j, i) && passThroughEvents.find(jjEventAtLastMaskedPixel) < 0) {
		            counter++;
		            direction += i < middle ? 1 : i > middle ? -1 : 0;
		            if (i < topmost)
		                topmost = i;
		            if (i > bottommost)
		                bottommost = i;
		        }
		    }
		}
		if (counter > 32) {
		    if (direction > 0)
		        play.yPos += bottommost - top;
		    else if (direction < 0)
		        play.yPos += topmost - bottom;
		}
}