Downloads containing xlmacademylite_backup.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Academy Superjazz Battle N/A Download file

File preview

#include "MLLE-Include-1.4.asc"
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "xlmacademylite.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;
	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) {
	drawBox(canvas, jjSubscreenWidth / 2 - 100, jjSubscreenHeight / 2 - 60, 200, 120,
			TEXT_BOX_BODY_COLOR, SPRITE::TRANSLUCENT, true, TEXT_BOX_BORDER_COLOR);
	for (uint i = 5; i > 0; i--) {
		canvas.drawString(jjSubscreenWidth / 2 - 56, jjSubscreenHeight / 2 - 32,
				"" + (i*10) + "x", STRING::SMALL, centeredText);
		canvas.drawResizedSprite(jjSubscreenWidth / 2 - 28, jjSubscreenHeight / 2 - 34, ANIM::PICKUPS, 34, 0, 0.3, 0.3, SPRITE::GEM, 3);
		canvas.drawString(jjSubscreenWidth / 2 + 16, jjSubscreenHeight / 2 - 32,
				" = " + (i*20) "s", STRING::SMALL, centeredText);
		canvas.drawResizedSprite(jjSubscreenWidth / 2 + 64, jjSubscreenHeight / 2 - 36, ANIM::PICKUPS, 31, 0, 0.6, 0.6);
	}
}

void drawBonusSeekers(jjPLAYER@ play, jjCANVAS@ canvas, jjTEXTAPPEARANCE centeredText) {
	
}

void drawBonusWater(jjPLAYER@ play, jjCANVAS@ canvas, jjTEXTAPPEARANCE centeredText) {
	
}

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);
}

void giveShield(jjPLAYER@ play, int time, int shieldType) {
	play.shieldTime += time;
	play.shieldType = shieldType;
}

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;
	}
	bonusStates[play.localPlayerID] = BONUS_OFF;
}

void handleBonusFire(jjPLAYER@ play) {
	if (play.testForGems(50, GEM::PURPLE)) {
		giveShield(play, 7000, SHIELD::FIRE);
	}
	else if (play.testForGems(40, GEM::PURPLE)) {
		giveShield(play, 5600, SHIELD::FIRE);
	}
	else if (play.testForGems(30, GEM::PURPLE)) {
		giveShield(play, 4200, SHIELD::FIRE);
	}
	else if (play.testForGems(20, GEM::PURPLE)) {
		giveShield(play, 2800, SHIELD::FIRE);
	}
	else if (play.testForGems(10, GEM::PURPLE)) {
		giveShield(play, 1400, 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_FIRE;
	play.noFire = true;
}

void onFunction3(jjPLAYER@ play) {
	bonusStates[play.localPlayerID] = BONUS_WATER;
	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);
	}
}