Downloads containing OneFroggyEvening.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Anniversary Bash 19 Levels Jazz2Online Multiple N/A Download file
JJ2+ Only: One Froggy EveningFeatured Download Violet CLM Custom / Concept 9 Download file

File preview

#pragma require "SwampsD.j2t"

jjLAYER@ SwampTrees1, SwampTrees2;
const uint emptyFoliageHeight = 2;

class Vine {
	private uint x, y;
	Vine(){}
	Vine(uint xx, uint yy) { x = xx; y = yy; }
	void setEvent(AREA::Area area) { jjEventSet(x, y, area); }
}
array<Vine> Vines;
void SetVines(bool toVine) {
	for (uint i = 0; i < Vines.length; ++i)
		Vines[i].setEvent(toVine ? AREA::VINE : AREA::ONEWAY);
}

void onLevelLoad() {
	for (int i = 16; i <= 95; ++i) {
		const jjPALCOLOR color = jjPalette.color[i];
		uint sat = uint(color.getSat() * 1.4);
		if (sat > 255) sat = 255;
		uint light = uint(color.getLight() * 1.33);
		if (light > 255) light = 255;
		jjPalette.color[i].setHSL(color.getHue(), sat, light);
	}

	jjPalette.gradient(jjPALCOLOR(135, 103, 0), jjPALCOLOR(46, 57, 23), 104, 5); //foliage
	jjPalette.gradient(jjPALCOLOR(46, 57, 23), jjPALCOLOR(38, 39, 10), 108, 4); //foliage2
	//jjPalette.gradient(jjPALCOLOR(30, 93, 65), jjPALCOLOR(12, 42, 66), 144, 11); //rock
	//jjPalette.gradient(jjPALCOLOR(12, 42, 66), jjPALCOLOR(7, 12, 6), 152, 6); //rock2
	for (uint i = 0; i < 32; ++i)
		jjPalette.color[144 + i].swizzle(COLOR::BLUE, COLOR::GREEN, COLOR::RED);
	jjPalette.gradient(jjPALCOLOR(90, 113, 45), jjPALCOLOR(7, 12, 19), 96, 8); //grass
	jjPalette.gradient(jjPALCOLOR(138, 88, 47), jjPALCOLOR(20, 12, 12), 120, 8); //wood
	jjPalette.gradient(jjPALCOLOR(190,40,70), jjPALCOLOR(20,0,5), 112, 8); //flowers
	jjPalette.gradient(jjPALCOLOR(154,180,96), jjPALCOLOR(46,62,23)); //water
	jjSetWaterGradient(jjPALCOLOR(46,62,23), jjPALCOLOR(0, 0, 0));
	jjSetFadeColors(jjPALCOLOR(0, 0, 0));
	jjPalette.apply();
	
	jjTexturedBGStyle = TEXTURE::WARPHORIZON;
	jjUseLayer8Speeds = true;
	
	jjDelayGeneratedCrateOrigins = true;
	//jjObjectPresets[OBJECT::BLUESPRING].ySpeed -= 19;
	
	{
		jjMASKMAP unmasked(false);
		jjMASKMAP floor(60);
		floor.save(107, true);
		floor.save(108, true);
		for (uint y = 18; y <= 19; ++y)
			for (uint x = 1; x <= 7; ++x)
				unmasked.save(x + y*10, true);
	}
	{
		jjPIXELMAP lockBlock(18);
		for (uint x = 0; x < 32; ++x)
			for (uint y = 0; y < 32; ++y)
				lockBlock[x,y] += 16;
		lockBlock.save(19);
	}
	{
		for (uint x = 0; x < 3; ++x)
			for (uint y = 0; y < 3; ++y) {
				jjPIXELMAP pillar(720 + x + y*10);
				for (uint xx = 0; xx < 32; ++xx)
					for (uint yy = 0; yy < 32; ++yy)
						if (pillar[xx,yy] != 0)
							pillar[xx,yy] += 16;
				pillar.save(720 + x + y*10);
			}
	}
	
	for (int x = jjLayerWidth[4] - 1; x >= 0; --x)
		for (int y = jjLayerHeight[4] - 1; y >= 0; --y) {
			if (jjEventGet(x, y) == AREA::VINE)
				Vines.insertLast(Vine(x,y));
		}
	
	const auto firstSwampTile = jjTileCount;
	
	{
		jjPAL SwampsPalette;
		SwampsPalette.load("SwampsD.j2t");
		array<uint8> SwampColorMapping(256, 0);
		for (uint i = 1; i < SwampColorMapping.length; ++i) {
			const jjPALCOLOR color = SwampsPalette.color[i];
			if (color.blue > color.green && color.blue > color.red)
				continue; //blue colors are transparent
			else if (color.green > color.red)
				SwampColorMapping[i] = 111 - (color.green / 29);
			else
				SwampColorMapping[i] = 129 - (color.red / 24);
		}
		jjTilesFromTileset(
			"SwampsD.j2t",
			64 * 10,
			23 * 10,
			SwampColorMapping
		);
		jjTilesFromTileset("Psych3N.j2t", 0,0); //bug fix for 5.4
		for (uint i = firstSwampTile; i < jjTileCount; ++i) {
			jjPIXELMAP swampTile(i);
			for (uint x = 0; x < 32; ++x)
				for (uint y = 0; y < 32; ++y)
					if (SwampColorMapping[swampTile[x,y]] == 0)
						swampTile[x,y] = 0;
			swampTile.save(i);
		}
	}
	
	@SwampTrees1 = jjLAYER(20, 12);
	SwampTrees1.generateSettableTileArea();
	for (int x = 0; x < SwampTrees1.width; ++x) {
		const auto xMod = x % 10;
		for (int y = 0; y < SwampTrees1.height; ++y)
			if (!(y >= 5 && y <= 10 && (
				(xMod == 0) ||
				(xMod == 9) ||
				((xMod == 1 || xMod == 7) && (y == 6 || y == 7)) ||
				((xMod == 2 || xMod == 6) && y == 6) ||
				(xMod == 8 && y >= 6 && y <= 8)
			)))
				SwampTrees1.tileSet(x, y, firstSwampTile + 11*10 + xMod + y*10);
	}
	SwampTrees1.tileWidth = true;
	SwampTrees1.xSpeed = 0.17;
	SwampTrees1.ySpeed = 0.07;
	SwampTrees1.yOffset = SwampTrees1.ySpeed * -40;
	
	@SwampTrees2 = jjLAYER(20, (600 + 31) / 32);
	SwampTrees2.generateSettableTileArea();
	for (int x = 0; x < SwampTrees2.width; ++x) {
		const auto xMod = x % 10;
		for (int y = 0; y < SwampTrees2.height; ++y) {
			int ySrc;
			if (y <= 2)
				ySrc = y;
			else if (y <= (2 + emptyFoliageHeight)) {
				SwampTrees2.tileSet(x, y, firstSwampTile + 60);
				continue;
			} else {
				ySrc = y - emptyFoliageHeight;
				if (ySrc > 10)
					continue; //ySrc = 10;
			}
				
			if (!(xMod == 0 && ySrc == 6))
				SwampTrees2.tileSet(x, y, firstSwampTile + xMod + ySrc*10);
		}
	}
	SwampTrees2.tileWidth = true;
	SwampTrees2.xSpeed = 0.09;
	SwampTrees2.ySpeed = 0.02;
	SwampTrees2.yOffset = SwampTrees2.ySpeed * -40;
	
	jjLayers[3].spriteMode = SPRITE::BRIGHTNESS;
	jjLayers[2].spriteMode = SPRITE::BRIGHTNESS;
	jjLayers[1].spriteMode = SPRITE::BRIGHTNESS;
	jjLayers[3].spriteParam = 90;
	jjLayers[2].spriteParam = 55;
	jjLayers[1].spriteParam = 20;
	
	jjWaterLayer = 8;
	jjLayerOrderSet(array<jjLAYER@> = {jjLayers[1], jjLayers[2], jjLayers[3], jjLayers[4], jjLayers[5], SwampTrees1, SwampTrees2, jjLayers[8]});
	
	for (int i = 0; i <= 243; ++i) {
		jjObjectPresets[i].lightType = LIGHT::BRIGHT;
		jjObjectPresets[i].light = 9;
	}
	
	jjObjectPresets[OBJECT::FRIES].determineCurAnim(ANIM::DRAGFLY, 0);
	jjObjectPresets[OBJECT::FRIES].playerHandling = HANDLING::PARTICLE;
	for (uint i = 0; i < jjAnimations[jjAnimSets[ANIM::DRAGFLY]].frameCount; ++i)
		jjAnimFrames[jjAnimations[jjAnimSets[ANIM::DRAGFLY]] + i].transparent = true;
	
	jjObjectPresets[OBJECT::FRIES].lightType = LIGHT::NONE; //noninteractive
	jjObjectPresets[OBJECT::GENERATOR].lightType = LIGHT::NONE;
	jjObjectPresets[OBJECT::TRIGGERSCENERY].lightType = LIGHT::NONE;
	
	jjObjectPresets[OBJECT::SILVERCOIN].ySpeed = 1;
	
	jjObjectPresets[OBJECT::TWEEDLEBOSS].behavior = Firefly;
	jjObjectPresets[OBJECT::TWEEDLEBOSS].lightType = LIGHT::POINT;
	jjObjectPresets[OBJECT::TWEEDLEBOSS].deactivates = false;
	jjObjectPresets[OBJECT::TWEEDLEBOSS].isTarget = false;
	jjObjectPresets[OBJECT::TWEEDLEBOSS].playerHandling = HANDLING::PARTICLE;
	jjObjectPresets[OBJECT::TWEEDLEBOSS].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::TWEEDLEBOSS].curFrame = jjAnimations[jjAnimSets[ANIM::AMMO] + 4];
	for (int x = 24; x >= 0; x -= 1)
		for (int y = 19; y >= 0; y -= 2)
			jjAddObject(OBJECT::TWEEDLEBOSS, x * 32, y * 32);
	
	jjAnimSets[ANIM::PLUS_SCENERY].load();
	jjAnimSets[ANIM::EVA].load();
	jjAnimSets[ANIM::WITCH].load();
	jjIsSnowing = true;
	jjIsSnowingOutdoorsOnly = true;
	jjSnowingType = SNOWING::LEAF;
	
	const jjANIMATION@ leafAnim = jjAnimations[jjAnimSets[ANIM::PLUS_SCENERY] + 0];
	for (uint i = 0; i < leafAnim.frameCount; ++i) {
		jjANIMFRAME@ leafFrame = jjAnimFrames[leafAnim + i];
		jjPIXELMAP leaf(leafFrame);
		for (uint x = 0; x < leaf.width; ++x)
			for (uint y = 0; y < leaf.height; ++y)
				if (leaf[x,y] != 0)
					leaf[x,y] = 103 + (leaf[x,y] & 7);
		leaf.save(leafFrame);
		//leafFrame.transparent = true;
	}
	{
		jjANIMFRAME@ fruitFrame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::FRUITPLAT]+1]];
		jjPIXELMAP fruit(fruitFrame);
		for (uint x = 0; x < fruit.width; ++x)
			for (uint y = 0; y < fruit.height; ++y)
				if (fruit[x,y] != 0)
					fruit[x,y] = 96 + (fruit[x,y] & 7);
		fruit.save(fruitFrame);
	}
	
	for (uint i = 40; i <= 44; ++i)
		jjAnimations[jjAnimSets[ANIM::AMMO] + i] = jjAnimations[jjAnimSets[ANIM::WITCH] + 3];
	jjAnimations[jjAnimSets[ANIM::AMMO] + 33] = jjAnimations[jjAnimSets[ANIM::WITCH] + 3];
	jjObjectPresets[OBJECT::SEEKERBULLETPU].playerHandling = HANDLING::SPECIAL;
	jjObjectPresets[OBJECT::SEEKERBULLETPU].scriptedCollisions = true;
	jjObjectPresets[OBJECT::SEEKERBULLETPU].behavior = WitchSeeker();
	
	jjObjectPresets[OBJECT::CAKE].behavior = BEHAVIOR::FLICKERGEM; //coins from crates
	jjObjectPresets[OBJECT::CAKE].counter = jjObjectPresets[OBJECT::FLICKERGEM].counter / 2;
	jjObjectPresets[OBJECT::CAKE].curAnim = jjObjectPresets[OBJECT::SILVERCOIN].curAnim;
	jjObjectPresets[OBJECT::CAKE].curFrame = jjObjectPresets[OBJECT::SILVERCOIN].curFrame;
	jjObjectPresets[OBJECT::CAKE].eventID = OBJECT::SILVERCOIN;
	
	jjCharacters[CHAR::FROG].canRun = true;
	jjCharacters[CHAR::FROG].canHurt = true;
	jjWeapons[WEAPON::GUN9].comesFromGunCrates = false; //can't scavenge other people's leftover EB
	
	jjMusicLoad("This Is Gonna Be Good.mp3", true) || jjMusicLoad("megaforests") || jjMusicLoad("dark.s3m") || jjMusicLoad("FUNKYB");
}

void onDrawLayer8(jjPLAYER@ play, jjCANVAS@) {
	SwampTrees2.yOffset = -(100 - jjSubscreenHeight / 2) + SwampTrees2.height * 16 - jjSubscreenHeight / 2;
	if (!jjLowDetail)
		jjSetWaterLevel(0, true);//play.cameraY - SwampTrees2.getYPosition(play) + 230 + emptyFoliageHeight*32, true);
}
void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ screen) {
	jjSetWaterLevel(32 * 100, true);
	
	for (uint i = jjObjectCount - 1; i > 0; --i) {
		jjOBJ@ obj = jjObjects[i];
		if (obj.behavior == Firefly) {
			obj.xPos = obj.xOrg + play.cameraX;
			obj.yPos = obj.yOrg + play.cameraY;
			if (!jjLowDetail && ((jjGameTicks + obj.objectID) & 15) == 0)
				screen.drawSpriteFromCurFrame(int(obj.xPos), int(obj.yPos), obj.curFrame);
			
		}
	}
	
	drawEva(screen, 17 * 32 + 17, 61 * 32 + 20, 1, play.charCurr == CHAR::FROG);
	drawEva(screen, 231 * 32 + 17, 61 * 32 + 20, -1, play.charCurr == CHAR::FROG);
}

void drawEva(jjCANVAS@ screen, int x, int y, int d, bool c) {
	screen.drawSprite(x, y, ANIM::EVA, 1, 0, -d);
	if (c && jjRenderFrame & 31 < 16) {
		screen.drawTile(x - 70, y - 74, 145);
		screen.drawTile(x - 70 + 32, y - 74, 146);
		screen.drawTile(x - 70, y - 74 + 32, 154);
		screen.drawTile(x - 70 + 32, y - 74 + 32, 155);
	}
}

const float levelWidth = 25 * 32;
const float levelHeight = 20 * 32;
void Firefly(jjOBJ@ obj) {
	if ((obj.state == STATE::START && ((obj.age = jjRandom() & 1023) >= 0) && ((obj.state = STATE::FLY) != STATE::START)) || ((jjRandom() & 63) == 0))
		obj.special = jjRandom() & 1023;
	int distance = (obj.age - obj.special) & 1023;
	if (distance < 512)
		obj.age += 2;
	else
		obj.age -= 2;
	obj.xOrg += jjSin(obj.age) * 2;
	if (obj.xOrg < 0)
		obj.xOrg += levelWidth;
	else if (obj.xOrg >= levelWidth)
		obj.xOrg -= levelWidth;
	obj.yOrg += jjCos(obj.age) * 2;
	if (obj.yOrg < 0)
		obj.yOrg += levelHeight;
	else if (obj.yOrg >= levelHeight)
		obj.yOrg -= levelHeight;
}

/*bool wasTeamRed = false;
void onPlayer(jjPLAYER@ play) {
	if (play.teamRed != wasTeamRed) {
		wasTeamRed = play.teamRed;
		for (uint i = 0; i < 32; ++i)
			jjPalette.color[144 + i].swizzle(COLOR::BLUE, COLOR::GREEN, COLOR::RED);
		jjPalette.apply();
	}
}*/
bool seenFrogText = false;
void onFunction0(jjPLAYER@ play) {
	if (!seenFrogText) {
		seenFrogText = true;
		play.showText("@@@@@@If you are turned into a frog@Eva Earlong can help!@@                                #||||||~...for a price.", STRING::MEDIUM);
	} else if (int(jjTeamScore[play.team]) > int(jjTeamScore[TEAM::Color(play.team ^ 1)]) - 25) {
		play.morphTo(CHAR::FROG);
		SetVines(false);
	} else {
		play.showText("@@@@@@@@Your team is so far behind@you have been spared from becoming a frog.");
		SetVines(true);
	}
}
void onFunction1(jjPLAYER@ play) {
	if (play.charCurr == CHAR::FROG && play.testForCoins(10)) {
		play.morphTo(play.charOrig, true);
		jjSample(play.xPos, play.yPos, SOUND::EVA_KISS2);
		SetVines(true);
	}
	if (play.coins >= 500) {
		if (!play.powerup[WEAPON::SEEKER]) {
			play.powerup[WEAPON::SEEKER] = true;
			if (jjAutoWeaponChange)
				play.currWeapon = WEAPON::SEEKER;
			jjAlert("|||||||Seeker Powerup!", false, STRING::MEDIUM);
		}
		play.ammo[WEAPON::SEEKER] = jjWeapons[WEAPON::SEEKER].maximum;
		if (play.ammo[WEAPON::SEEKER] < 0)
			play.ammo[WEAPON::SEEKER] = 25;
		jjSamplePriority(SOUND::COMMON_GLASS2);
	}
}

void onFunction2(jjPLAYER@ play) {
	if (play.charCurr != CHAR::FROG) {
		play.showText(2, 0);
	}
}
void onFunction3(jjPLAYER@ play) {
	if (play.charCurr == CHAR::FROG) {
		jjAlert("|Frogs can't use copters, d00d!");
		jjEnabledASFunctions[3] = false;
	}
}

class WitchSeeker : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (obj.state == STATE::START)
			jjSample(obj.xPos, obj.yPos, SOUND::WITCH_MAGIC);
		obj.behave(BEHAVIOR::SEEKERBULLET);
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) {
		if (bullet is null && (jjPlayers[obj.creator].team != play.team || (jjFriendlyFire && jjPlayers[obj.creator] !is play))) {
			obj.delete();
			if (play.isLocal && play.blink == 0) {
				if (play.charCurr != CHAR::FROG) {
					jjSamplePriority(SOUND::WITCH_LAUGH);
					play.morphTo(CHAR::FROG, true);
					SetVines(false);
				} else
					play.hurt(1, false, jjPlayers[obj.creator]);
			}
		}
		return true;
	}
}