Downloads containing ab23btl15.j2as

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

File preview

#include "MLLE-Include-1.5.asc" ///@MLLE-Generated
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "ab23btl15.j2l"
#pragma require "Castle1.j2t"
#pragma require "diamondus frozen.j2t"
#pragma require "Hocus013D.j2t"
#pragma require "JJ1Deserto.j2t"
#pragma require "Medivo2.j2t"

enum BONUS_STATE {BONUS_OFF, BONUS_FIRE, BONUS_WATER, BONUS_SEEKERS };

/* Academy, written by CJ/Superjazz */
const int ELEVATOR_TILE_X = 144;
const int ELEVATOR_TILE_Y = 48;
const int TEXT_BOX_BODY_COLOR = 98;
const int TEXT_BOX_BORDER_COLOR = 100;
const int TILE = 32;
const int VERTICAL_FLIP_EVENT_ID = 149;
const string ACADEMY_LITE_INFO_TEXT = "Welcome to Academy LITE! No spells or fancy stuff here.";
const array<int> coinBonusLocation = {4740, 334};
const array<array<int>> gemBonusLocations = {{1540, 2666}, {2596, 2762}};

array<BONUS_STATE> bonusStates = { BONUS_OFF, BONUS_OFF, BONUS_OFF, BONUS_OFF };

void drawBonus(jjPLAYER@ play, jjCANVAS@ canvas) {
	jjTEXTAPPEARANCE centeredText();
	centeredText.align = STRING::CENTER;
	drawBox(canvas, jjSubscreenWidth / 2 - 94, jjSubscreenHeight / 2 - 52, 192, 128,
			TEXT_BOX_BODY_COLOR, SPRITE::TRANSLUCENT, true, TEXT_BOX_BORDER_COLOR);
	switch (bonusStates[play.localPlayerID]) {
		case BONUS_SEEKERS:
			drawBonusSeekers(play, canvas, centeredText);
		break;
		case BONUS_FIRE:
			drawBonusFire(play, canvas, centeredText);
		break;
		case BONUS_WATER:
			drawBonusWater(play, canvas, centeredText);
		break;
	}
}

void drawBonusFire(jjPLAYER@ play, jjCANVAS@ canvas, jjTEXTAPPEARANCE centeredText) {
	for (uint i = 5; i > 0; i--) {
		canvas.drawString(jjSubscreenWidth / 2 - 56, jjSubscreenHeight / 2 + 88 - (i*24),
				"" + (i*10) + "x", STRING::SMALL, centeredText);
		canvas.drawResizedSprite(jjSubscreenWidth / 2 - 28, jjSubscreenHeight / 2 + 86 - (i*24),
				ANIM::PICKUPS, 34, 0, 0.3, 0.3, SPRITE::GEM, 3);
		canvas.drawString(jjSubscreenWidth / 2 + 16, jjSubscreenHeight / 2 + 88 - (i*24),
				" = " + (i*25) + "s", STRING::SMALL, centeredText);
		canvas.drawResizedSprite(jjSubscreenWidth / 2 + 64, jjSubscreenHeight / 2 + 84 - (i*24),
				ANIM::PICKUPS, 31, 0, 0.6, 0.6);
	}
}

void drawBonusSeekers(jjPLAYER@ play, jjCANVAS@ canvas, jjTEXTAPPEARANCE centeredText) {
	canvas.drawString(jjSubscreenWidth / 2, jjSubscreenHeight / 2 - 56,
				"MAX 50x", STRING::SMALL, centeredText);
	for (uint i = 5; i > 0; i--) {
		canvas.drawString(jjSubscreenWidth / 2 - 56, jjSubscreenHeight / 2 + 88 - (i*24),
				"" + (i*20) + "x", STRING::SMALL, centeredText);
		canvas.drawResizedSprite(jjSubscreenWidth / 2 - 24, jjSubscreenHeight / 2 + 86 - (i*24),
				ANIM::PICKUPS, 84, 0, 0.8, 0.8);
		canvas.drawString(jjSubscreenWidth / 2 + 16, jjSubscreenHeight / 2 + 88 - (i*24),
				" = " + (i*10) + "x", STRING::SMALL, centeredText);
		canvas.drawResizedSprite(jjSubscreenWidth / 2 + 64, jjSubscreenHeight / 2 + 86 - (i*24),
				ANIM::AMMO, 42, 0, 1.2, 1.2);
	}
}

void drawBonusWater(jjPLAYER@ play, jjCANVAS@ canvas, jjTEXTAPPEARANCE centeredText) {
	for (uint i = 5; i > 0; i--) {
		canvas.drawString(jjSubscreenWidth / 2 - 56, jjSubscreenHeight / 2 + 88 - (i*24),
					"" + (i*10) + "x", STRING::SMALL, centeredText);
		canvas.drawResizedSprite(jjSubscreenWidth / 2 - 28, jjSubscreenHeight / 2 + 86 - (i*24),
				ANIM::PICKUPS, 34, 0, 0.3, 0.3, SPRITE::GEM, 3);
		canvas.drawString(jjSubscreenWidth / 2 + 16, jjSubscreenHeight / 2 + 88 - (i*24),
				" = " + (i*20) + "s", STRING::SMALL, centeredText);
		canvas.drawResizedSprite(jjSubscreenWidth / 2 + 64, jjSubscreenHeight / 2 + 84 - (i*24),
				ANIM::PICKUPS, 10, 0, 0.6, 0.6);
	}
}

void drawBox(jjCANVAS@ canvas, int originX, int originY, int width, int height, int bodyColor,
		SPRITE::Mode spriteMode, bool borders = false, int borderColor = 0) {
	canvas.drawRectangle(originX, originY, width, height, bodyColor, spriteMode);
	if (borders) {
		canvas.drawRectangle(originX, originY, width, 1, borderColor, spriteMode);
		canvas.drawRectangle(originX, originY, 1, height, borderColor, spriteMode);
		canvas.drawRectangle(originX, originY + height, width, 1, borderColor, spriteMode);
		canvas.drawRectangle(originX + width, originY, 1, height, borderColor, spriteMode);
	}
}

void drawScaledArrow(jjCANVAS@ canvas, int x, int y, int angle, float scale) {
	canvas.drawRotatedSprite(x, y, ANIM::FLAG, 0, 0, angle, scale, scale, SPRITE::SINGLECOLOR, 15);
}

void flipVerticalTiles() {
	for (int x = 0; x < jjLayerWidth[4]; x++) {
		for (int y = 0; y < jjLayerHeight[4]; y++) {
		  uint16 tile = jjTileGet(4, x, y);
			   
		  if (jjEventGet(x, y) == VERTICAL_FLIP_EVENT_ID) jjTileSet(4, x, y, tile ^ TILE::VFLIPPED);
		}
	}
}

void givePoweredUpSeekers(jjPLAYER@ play, int amount) {
	int currentSeekerAmmo = play.ammo[WEAPON::SEEKER];
	play.ammo[WEAPON::SEEKER] = currentSeekerAmmo + amount;
	play.powerup[WEAPON::SEEKER] = true;
	if (play.ammo[WEAPON::SEEKER] > 50) {
		play.ammo[WEAPON::SEEKER] = 50;
	}
	jjSamplePriority(SOUND::COMMON_GLASS2);
	bonusStates[play.localPlayerID] = BONUS_OFF;
}

void giveShield(jjPLAYER@ play, int time, int shieldType) {
	play.shieldTime += time;
	play.shieldType = shieldType;
	jjSamplePriority(SOUND::COMMON_BELL_FIRE);
	bonusStates[play.localPlayerID] = BONUS_OFF;
}

void handleBonus(jjPLAYER@ play) {
	switch (bonusStates[play.localPlayerID]) {
		case BONUS_SEEKERS:
			handleBonusSeekers(play);
		break;
		case BONUS_FIRE:
			handleBonusFire(play);
		break;
		case BONUS_WATER:
			handleBonusWater(play);
		break;
	}
}

void handleBonusFire(jjPLAYER@ play) {
	if (play.testForGems(50, GEM::PURPLE)) {
		giveShield(play, 8750, SHIELD::FIRE);
	} else if (play.testForGems(40, GEM::PURPLE)) {
		giveShield(play, 7000, SHIELD::FIRE);
	} else if (play.testForGems(30, GEM::PURPLE)) {
		giveShield(play, 5250, SHIELD::FIRE);
	} else if (play.testForGems(20, GEM::PURPLE)) {
		giveShield(play, 3500, SHIELD::FIRE);
	} else if (play.testForGems(10, GEM::PURPLE)) {
		giveShield(play, 1750, SHIELD::FIRE);
	}
}

void handleBonusSeekers(jjPLAYER@ play) {
	if (play.testForCoins(100)) {
		givePoweredUpSeekers(play, 50);
	} else if (play.testForCoins(80)) {
		givePoweredUpSeekers(play, 40);
	} else if (play.testForCoins(60)) {
		givePoweredUpSeekers(play, 30);
	} else if (play.testForCoins(40)) {
		givePoweredUpSeekers(play, 20);
	} else if (play.testForCoins(20)) {
		givePoweredUpSeekers(play, 10);
	}
}

void handleBonusWater(jjPLAYER@ play) {
	if (play.testForGems(50, GEM::PURPLE)) {
		giveShield(play, 7000, SHIELD::WATER);
	} else if (play.testForGems(40, GEM::PURPLE)) {
		giveShield(play, 5600, SHIELD::WATER);
	} else if (play.testForGems(30, GEM::PURPLE)) {
		giveShield(play, 4200, SHIELD::WATER);
	} else if (play.testForGems(20, GEM::PURPLE)) {
		giveShield(play, 2800, SHIELD::WATER);
	} else if (play.testForGems(10, GEM::PURPLE)) {
		giveShield(play, 1400, SHIELD::WATER);
	}
}

bool onDrawAmmo(jjPLAYER@ play, jjCANVAS@ canvas) {
	if (bonusStates[play.localPlayerID] != BONUS_OFF) {
		drawBonus(play, canvas);
	}
	return false;
}

void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ canvas) {
	drawScaledArrow(canvas, ELEVATOR_TILE_X * TILE + 16, ELEVATOR_TILE_Y * TILE + 16, 196, 0.7);
	for (uint i = 0; i < gemBonusLocations.length; i++) {
		array<int> location = gemBonusLocations[i];
		canvas.drawResizedSprite(location[0], location[1], ANIM::PICKUPS, 34, 0, 0.3, 0.3, SPRITE::GEM, 3);
	}
	canvas.drawResizedSprite(coinBonusLocation[0], coinBonusLocation[1], ANIM::PICKUPS, 84, 0, 0.8, 0.8);
}

void onFunction0(jjPLAYER@ play) {
	bonusStates[play.localPlayerID] = BONUS_OFF;
	play.noFire = false;
	jjEnabledASFunctions[1] = true;
	jjEnabledASFunctions[2] = true;
	jjEnabledASFunctions[3] = true;
}

void onFunction1(jjPLAYER@ play) {
	bonusStates[play.localPlayerID] = BONUS_SEEKERS;
	play.noFire = true;
}

void onFunction2(jjPLAYER@ play) {
	bonusStates[play.localPlayerID] = BONUS_WATER;
	play.noFire = true;
}

void onFunction3(jjPLAYER@ play) {
	bonusStates[play.localPlayerID] = BONUS_FIRE;
	play.noFire = true;
}

void onLevelBegin() {
	flipVerticalTiles();
	jjConsole(ACADEMY_LITE_INFO_TEXT);
}

void onPlayerInput(jjPLAYER@ play) {
	if (play.keyUp && int(play.xPos/TILE) == ELEVATOR_TILE_X && int(play.yPos/TILE) == ELEVATOR_TILE_Y) {
		play.warpToID(0, true);
	}
	if (play.keyFire && bonusStates[play.localPlayerID] != BONUS_OFF) {
		handleBonus(play);
	}
}