Downloads containing ab19btl16.j2as

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

File preview

#pragma require "ab19btl16ex.j2l"
#pragma require "rain.wav"

uint palshift = 0;
uint type = 3;

int showerInterval = 4200;
int showerDuration = 2101;

uint R = 125;
uint G = 220;
uint B = 250;
uint light = 100;

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.causesRicochet = 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 handleFastCustomSpringSpeeds(jjPLAYER@ player) {
	if (player.ySpeed < -32.f) {
		fastCustomSpringSpeeds[player.localPlayerID] = int(ceil((player.ySpeed + 32.f) / -0.125f));
	} else if (fastCustomSpringSpeeds[player.localPlayerID] != 0) {
		if (player.ySpeed < -31.f) {
			fastCustomSpringSpeeds[player.localPlayerID]--;
			player.ySpeed = -32.f;
		} else {
			fastCustomSpringSpeeds[player.localPlayerID] = 0;
		}
	}
}

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {64});
	turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 34.f, false);
	
	for (int i = 1; i < 255; i++) {
		if (jjObjectPresets[i].playerHandling == HANDLING::PICKUP) {
			jjObjectPresets[i].behavior = CannotBeShotDown;
		}
	}
	
	jjObjectPresets[OBJECT::APPLE].behavior =
	jjObjectPresets[OBJECT::BANANA].behavior =
	jjObjectPresets[OBJECT::CANDY].behavior =
	jjObjectPresets[OBJECT::CHERRY].behavior =
	jjObjectPresets[OBJECT::DONUT].behavior =
	jjObjectPresets[OBJECT::FRIES].behavior = ColoredMoth;
	
	jjAnimSets[ANIM::MOTH].load();
	
	jjSampleLoad(SOUND::INTRO_BLOW, "rain.wav");
	
	array<jjLAYER@> extraRocks = jjLayersFromLevel("ab19btl16ex.j2l", array<uint> = {1,2,3,5,6,7,8}, 0);
	jjLayerOrderSet(array<jjLAYER@> = {jjLayers[1], jjLayers[2], jjLayers[3], jjLayers[4], jjLayers[5], extraRocks[0], extraRocks[1], extraRocks[2], extraRocks[3], extraRocks[4], extraRocks[5], extraRocks[6], jjLayers[6], jjLayers[7], jjLayers[8]});
}

void CannotBeShotDown(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::PICKUP);
	if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT;
}

void ColoredMoth(jjOBJ@ obj) {
	switch (obj.eventID) {
		case OBJECT::APPLE: palshift = 8; type = 3; break;
		case OBJECT::BANANA: palshift = 240; type = 2; break;
		case OBJECT::CANDY: palshift = 192; type = 2; break;
		case OBJECT::CHERRY: palshift = 240; type = 3; break;
		case OBJECT::DONUT: palshift = 248; type = 2; break;
		case OBJECT::FRIES: palshift = 224; type = 3; break;
	}
	jjDrawSprite(obj.xPos, obj.yPos + 6, ANIM::MOTH, type, obj.curFrame, obj.direction, SPRITE::PALSHIFT, palshift);
	obj.playerHandling = jjObjectPresets[OBJECT::MOTH].playerHandling;
	obj.bulletHandling = jjObjectPresets[OBJECT::MOTH].bulletHandling;
	obj.behave(BEHAVIOR::MOTH, false);
}

void onPlayer(jjPLAYER@ player) {
	handleFastCustomSpringSpeeds(player);
	
	player.lightType = LIGHT::NONE;
	player.lighting = light;
}

void onMain() {
	if (showerInterval > 0) showerInterval--;
	else if (showerInterval == 0) showerDuration--;
	
	if (showerDuration == 0) {
		showerInterval = 4200;
		showerDuration = 2101;
	}
	
	if (!jjLowDetail) {
		jjIsSnowing = showerDuration < 2101? true:false;
		if (jjIsSnowing && jjGameTicks % 140 == 0) jjSample(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::INTRO_BLOW, 0, 0);
	
		if (showerInterval < 280 || showerInterval > 3920 && jjGameTicks > 281) {
			if (light > 90) light--;
			if (R > 45) R--;
			if (G > 140) G--;
			if (B > 170) B--;
		}
		else {
			if (light < 100) light++;
			if (R < 125) R++;
			if (G < 220) G++;
			if (B < 250) B++;
		}
	}
	else {
		jjIsSnowing = false;
		light = 100;
		R = 125;
		G = 220;
		B = 250;
	}
	
	jjSetFadeColors(R,G,B);
}