Downloads containing Fio2_d.j2as

Downloads
Name Author Game Mode Rating
JJ2+ Only: Find It Out (Single Player)Featured Download Superjazz Single player 8.7 Download file

File preview

#include "Fio_common.asc"
#include "Fio_cutscene.asc"
#include "Fio_entities.asc"
#include "Fio_globals.asc"

const float CAMERA_FINAL_X = TILE * 47.5;
const float CAMERA_FINAL_Y = TILE * 91;
const float CAMERA_INITIAL_X = TILE * 47.5;
const float CAMERA_INITIAL_Y = TILE * 160;
const float CAMERA_SCROLL_DURATION = CUTSCENE_SECOND * 30;
const float CAMERA_STILL_DURATION = CUTSCENE_SECOND * 22;
const float DEMON_ANIMATION_DURATION = CUTSCENE_SECOND * 6;
const float DEMON_ONE_X = TILE * 46;
const float DEMON_TWO_X = TILE * 49;
const float DEMON_Y = TILE * 91.5;
const float DISSOLVE_ANIMATION_DURATION = CUTSCENE_SECOND * 3;
const float FADE_DURATION_TOTAL = CUTSCENE_SECOND * 4;
const float FADE_DURATION_BLACKOUT = CUTSCENE_SECOND * 2;
const float SOUL_BALL_X = TILE * 47.5;
const float SOUL_BALL_Y = TILE * 91.5;
const float WIZARD_INTO_SOUL_BALL_ANIM_DURATION = CUTSCENE_SECOND * 13;

const string NEXT_LEVEL_FILENAME = "Fio2_e.j2l";

bool drawUpperDemonSprites = true;

array<string> cutsceneTexts = {
	"|||Greetings savior! If that is what I should call you. You have gone through a challenging journey so far.",
	"|||You have proven to be as strong as I expected. You have made your way intuitively to me...with a little assistance.",
	"|||And you touched the greater mindstone to telepathically communicate with me, so I could explain things to you a bit.",
	"|Wait! What do you mean by a little assistance? Do you have something to do with me getting captured and warped around realms too?",
	"|Who are you even?",
	"|||Well, now I'm a cursed little soul. But I used to be somebody great.",
	"|||My name was Nicholas, as you may call me still. Nicholas The Wizard.",
	"|Right. So what are you doing here then?",
	"|||Let me take you on a mind trip back in time, to when it all began.",
	"|||A long time ago, the tower of Nicus was my home. I had just graduated as a fresh, young wizard, but only a few days later...",
	"|||...I did a terrible mistake, by trying to cast one of the most arcane spells known. I wanted to banish the demons who were lurking around my tower.",
	"|||However, before I was successful, the demons caught me. They invaded Nicus and confronted me.",
	"|||They turned me into an ethereal soul and carried me here in a small soul ball. They cursed me and locked me up in this cell.",
	"|||As a cursed soul I cannot move through the gates of the cell unlike you. I haven't had a chance to escape, until now.",
	"|||Luckily my minions knew what happened to me. They ensured that they would find my savior eventually, although it did take a while.",
	"|||Now, you are the one. You'll need to set me free, although it won't be easy."
};

void createWizardAnimation() {
	
	// Duration, xOrigin, yOrigin, xDestination, yDestination, angle, scaleX, scaleY, animSet, animationId,
	// startingFrame, finalFrame, frameRate, repetitions (optional), isReversed (optional)
	// REMINDER: DON'T FORGET TO REMOVE THE TRAILING COMMA, SINCE OTHERWISE AS WILL INSERT A NULL HANDLE AFTER THE LAST ACTUAL OBJECT ELEMENT
	
	const array<fioCut::Animation@> animationsWizard = {
		fioCut::Animation(WIZARD_INTO_SOUL_BALL_ANIM_DURATION, SOUL_BALL_X, SOUL_BALL_Y, SOUL_BALL_X, SOUL_BALL_Y,
				0, 2, 2, ANIM::AMMO, 10, 3, 0, 3, 1, true),
		fioCut::Animation(DISSOLVE_ANIMATION_DURATION, SOUL_BALL_X, SOUL_BALL_Y, SOUL_BALL_X, SOUL_BALL_Y,
				0, 2, 2, ANIM::AMMO, 10, 0, 0, 3, 1, true, 1, SPRITE::BLEND_DISSOLVE, 255, 0)
	};
	fioCut::createAnimationChain(animationsWizard);
}

void createDemonAnimations() {
	
	// Duration, xOrigin, yOrigin, xDestination, yDestination, angle, scaleX, scaleY, animSet, animationId,
	// startingFrame, finalFrame, frameRate, repetitions (optional), isReversed (optional), direction (optional)
	// spriteMode (optional), spriteParamInitial (optional), spriteParamFinal (optional)
	// REMINDER: DON'T FORGET TO REMOVE THE TRAILING COMMA, SINCE OTHERWISE AS WILL INSERT A NULL HANDLE AFTER THE LAST ACTUAL OBJECT ELEMENT
	
	const array<fioCut::Animation@> animationsDemonOne = {
		fioCut::Animation(DEMON_ANIMATION_DURATION, DEMON_ONE_X, DEMON_Y, DEMON_ONE_X, DEMON_Y,
				0, 1, 1, ANIM::DEMON, 3, 0, 3, 3, 1, false, 1),
		fioCut::Animation(DISSOLVE_ANIMATION_DURATION, DEMON_ONE_X, DEMON_Y, DEMON_ONE_X, DEMON_Y,
				0, 1, 1, ANIM::DEMON, 3, 3, 3, 3, 1, false, 1, SPRITE::BLEND_DISSOLVE, 255, 0)
	};
	const array<fioCut::Animation@> animationsDemonTwo = {
		fioCut::Animation(DEMON_ANIMATION_DURATION, DEMON_TWO_X, DEMON_Y, DEMON_TWO_X, DEMON_Y,
				0, 1, 1, ANIM::DEMON, 3, 0, 3, 3, 1, false, -1),
		fioCut::Animation(DISSOLVE_ANIMATION_DURATION, DEMON_TWO_X, DEMON_Y, DEMON_TWO_X, DEMON_Y,
				0, 1, 1, ANIM::DEMON, 3, 3, 3, 3, 1, false, -1, SPRITE::BLEND_DISSOLVE, 255, 0)
	};
	fioCut::createAnimationChain(animationsDemonOne);
	fioCut::createAnimationChain(animationsDemonTwo);
}

// Required for each level
bool onCheat(string &in cheat) {
	return fio::handleCheat(cheat, NEXT_LEVEL_FILENAME);
}

bool onDrawHealth(jjPLAYER@ play, jjCANVAS@ canvas) {
	fioCut::drawCutscene(canvas, centeredText);
	return true;
}

bool onDrawLives(jjPLAYER@ play, jjCANVAS@ canvas) {
	return true;
}

void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ canvas) {
	fioCut::renderAnimations(canvas);
	canvas.drawSprite(TILE * 46, TILE * 103.5, ANIM::DEMON, 0, 0, -1);
	canvas.drawSprite(TILE * 49, TILE * 103.5, ANIM::DEMON, 0, 0, 1);
	if (drawUpperDemonSprites) {
		canvas.drawSprite(DEMON_ONE_X, DEMON_Y, ANIM::DEMON, 2, 1, 1);
		canvas.drawSprite(DEMON_TWO_X, DEMON_Y, ANIM::DEMON, 2, 1, -1);
	}
}

bool onDrawScore(jjPLAYER@ play, jjCANVAS@ canvas) {
	return true;
}

void onLevelBegin() {
	fioCut::initializeCutscene(@processTickEvents, cutsceneTexts);
}

void onLevelLoad() {
	initializeGlobals(array<Checkpoint@> = {});
	fioCut::clearAnimationChains();
	jjAnimSets[ANIM::DEMON].load();
}

void onPlayer(jjPLAYER@ play) {
	fioCut::run();
	fio::controlPressedKeys();

	if (jjGameTicks == 1) {
		play.noFire = true;
		play.cameraFreeze(CAMERA_INITIAL_X, CAMERA_INITIAL_Y, true, true);
	}
	
	if (!fioCut::isTickEventsProcessed()) {
		processTickEvents(play);
		fioCut::setTickEventsProcessed(true);
	}
}

void onPlayerInput(jjPLAYER@ play) {
	fioCut::controlPlayerInput(play);
	if (fioCut::isCutsceneSkipInitiatedAfterDelay(play)) {
		fioCut::setCutsceneSkipInitiated();
		fio::handleLevelCycle(NEXT_LEVEL_FILENAME, true, true);
	}
}

void processTickEvents(jjPLAYER@ play) {
	switch(uint(fioCut::getElapsedCutscene())) {
		case CUTSCENE_SECOND * 1:
			fioCut::startTextSliding();
			break;
		case CUTSCENE_SECOND * 50:
			fioCut::createEventCameraScroll(CAMERA_SCROLL_DURATION, CAMERA_INITIAL_X, CAMERA_INITIAL_Y,
					CAMERA_FINAL_X, CAMERA_FINAL_Y);
			break;
		case CUTSCENE_SECOND * 80:
			fioCut::createEventCameraScroll(CAMERA_STILL_DURATION, CAMERA_FINAL_X, CAMERA_FINAL_Y,
					CAMERA_FINAL_X, CAMERA_FINAL_Y);
			break;
		case CUTSCENE_SECOND * 81:
			createWizardAnimation();
			jjTileSet(4, 47, 90, 217);
			jjTileSet(4, 47, 91, 217);
			jjTileSet(4, 46, 91, 217);
			break;
		case CUTSCENE_SECOND * 88:
			drawUpperDemonSprites = false;
			createDemonAnimations();
			break;
		case CUTSCENE_SECOND * 100:
			fioCut::createEventFade(FADE_DURATION_TOTAL, FADE_DURATION_BLACKOUT, true, false);
			break;
		case CUTSCENE_SECOND * 101:
			play.xPos = TILE * 36;
			play.yPos = TILE * 176;
			play.ballTime = 0;
			break;
		case CUTSCENE_SECOND * 102:
			fio::increaseCutscenesWatchedIfFastForwardWasNotUsed(fioCut::wasFastForwardUsed);
			fio::handleLevelCycle(NEXT_LEVEL_FILENAME, false, true);
			break;
	}
}