Downloads containing ezSphere.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Spherical Coalesence ThunDerDraGon Capture the flag N/A Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
#include "MLLE-Include-1.6.asc" ///@MLLE-Generated
#pragma require "ezSphere-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "ezSphere-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "Stardust.j2t" ///@MLLE-Generated
#pragma require "Solar.j2t" ///@MLLE-Generated
#pragma require "Nebula.j2t" ///@MLLE-Generated
#pragma require "Vortex.j2t" ///@MLLE-Generated
#pragma require "ezSphere.j2l" ///@MLLE-Generated
#pragma require "halo.png"
#pragma require "star.png"
#pragma require "AA-Functions.asc"
#pragma require "starboard.asc"
#pragma require "starmageddon.asc"
#pragma require "exoskeleton.asc"
#pragma require "doom_spring.wav"
#include "starboard.asc"
#include "starmageddon.asc"
#include "exoskeleton.asc"
#include "AA-Functions.asc"

void onLevelReload() {
	MLLE::ReapplyPalette();
}

int duration;
uint theme;
uint8 oldSat, targetSat, targetHue;
uint8 neonIndex = 7;

enum Themes {Stardust, Vortex, Solar, Nebula};
array<jjLAYER@> layerOrder = jjLayerOrderGet();
array<uint8> ids = 
	{14, 58, 80, 81, 82, 83, 84, 85, 86, 87, 96, 97, 134, 144, 145,
	 146, 147, 148, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 160, 161 ,162, 164, 165, 167,
	 171, 172, 173, 175, 182, 185, 196, 235, 166, 22,
	 124, 241, 126, 236, 126, 125, 127, 245, 39, 242, 121, 122, 123, 119, 118
	};
	
class ForcedPUDirection : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::MONITOR, true);
		obj.direction = -1;
	}
}
	
class PotCrate : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::CRATE, false);
		obj.lightType = LIGHT::BRIGHT;
		obj.light = 10;
	}
	void onDraw(jjOBJ@ obj) {
		jjDrawTile(int(obj.xPos) - 12, int(obj.yPos) - 18, 572);
	}
}

class CannotBeShotDown : jjBEHAVIORINTERFACE {
	CannotBeShotDown(const jjBEHAVIOR &in behavior) {
		originalBehavior = behavior;
	}
	void onBehave(jjOBJ@ obj) {
		obj.behave(originalBehavior);
		if (obj.state == STATE::FLOATFALL)
			obj.state = STATE::FLOAT;
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
		if (bullet is null) {
			obj.behavior = originalBehavior;
			if (player.objectHit(obj, force, obj.playerHandling))
				return true;
			obj.behavior = this;
		}
		return false;
	}
	private jjBEHAVIOR originalBehavior;
}

class TechSpring : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::SPRING, false);
		if (obj.state == STATE::SPRING) {
			jjAddParticlePixelExplosion(obj.xPos, obj.yPos, obj.curFrame, obj.direction, 1);
		}
	}
}

void cycleTheme() {
	if (!jjLowDetail)
		jjDrawRectangle(p.cameraX, p.cameraY, 800, 600, 0, SPRITE::BLEND_NORMAL, int(125 + 125*jjSin(duration*2 - 256)), 8);
	jjPALCOLOR color = jjPalette.color[ids[15]];
	if (duration == 512) oldSat = color.getSat();
	PaletteSetting((duration > 256) ? color.getHue() : targetHue, (duration > 256) ? int(oldSat*jjSin(duration-256)) : int(targetSat*jjSin(-768+duration)), 0);
	if (duration == 256) {
		theme++;
		switch (theme%4) {
			case Stardust:
				layerOrder[12].hasTiles = true;
				layerOrder[14].hasTiles = false;
				applyGradientMapping(140,185, 4);
				layerOrder[11].spriteMode = SPRITE::TRANSLUCENTMAPPING;
				jjLayerOrderSet(layerOrder);
				jjSetFadeColors(26, 119, 158);
				neonIndex = 7;
				targetSat = 185;
				targetHue = 140;
				break;
			case Vortex:
				layerOrder[13].hasTiles = true;
				layerOrder[12].hasTiles = false;
				applyGradientMapping(125,120, 4);
				layerOrder[11].spriteMode = SPRITE::TRANSLUCENTMAPPING;
				jjLayerOrderSet(layerOrder);
				jjSetFadeColors(50, 134, 129);
				neonIndex = 5;
				targetSat = 120;
				targetHue = 125;
				break;
			case Solar:
				layerOrder[14].hasTiles = true;
				layerOrder[13].hasTiles = false;
				applyGradientMapping(17,255, 4);
				layerOrder[11].spriteMode = SPRITE::TRANSLUCENTMAPPING;
				jjLayerOrderSet(layerOrder);
				jjSetFadeColors(183, 74, 1);
				neonIndex = 7;
				targetSat = 255;
				targetHue = 17;
				break;
			case Nebula:
				layerOrder[15].hasTiles = true;
				layerOrder[14].hasTiles = false;
				applyGradientMapping(215,140, 4);
				layerOrder[11].spriteMode = SPRITE::TRANSLUCENTMAPPING;
				jjLayerOrderSet(layerOrder);
				jjSetFadeColors(142, 42, 136);
				neonIndex = 3;
				targetSat = 140;
				targetHue = 215;
				break;
		}
	}
}

void applyGradientMapping(uint8 hue, uint8 sat, uint8 index) {
	jjPAL pal = jjSpriteModeGetColorMapping(index);
	for (uint i = 10; i < 246; i++)
		pal.color[i].setHSL(hue, sat, pal.color[i].getLight());
	jjSpriteModeSetMapping(index, jjSpriteModeGetIndexMapping(index), pal);
}

void PaletteSetting(uint hue, uint sat, uint lum) {
	for (uint i = 0; i < ids.length; i++) {
		if (jjGameTicks < 10)
			lum = (i < 43) ? 4 : -4;
		jjPalette.color[ids[i]].setHSL(hue, sat, jjPalette.color[ids[i]].getLight() + lum);
	}
	jjPalette.apply();
}

void onLevelLoad() {
	jjSampleLoad(SOUND::COMMON_SPRING1, "doom_spring.wav");
	
	AATools::loadAssets("halo.png", 4, 800, 800);
	AATools::loadAssets("star.png", 5, 18, 42);
	Starboard::handlePresets();
	Starmageddon::handlePresets();
	Exoskeleton::handlePresets();
	
	jjObjectPresets[OBJECT::TOASTERPOWERUP].behavior = ForcedPUDirection();
	jjObjectPresets[OBJECT::GUNCRATE].behavior = PotCrate();
	jjObjectPresets[OBJECT::ELECTROBULLETPU].eventID = OBJECT::ELECTROBULLET;
	jjObjectPresets[OBJECT::GREENSPRING].behavior = jjObjectPresets[OBJECT::REDSPRING].behavior = 
	jjObjectPresets[OBJECT::BLUESPRING].behavior = TechSpring();
	jjEnforceLighting = LIGHT::COMPLETE;
	
	applyGradientMapping(125, 120, 0);
	applyGradientMapping(215, 140, 1);
	applyGradientMapping(17, 255, 2);
	applyGradientMapping(140, 185, 3);
	applyGradientMapping(140, 185, 4);
}

void onPlayerInput(jjPLAYER@ player) {
	Starmageddon::handleInput(player);
	Starboard::handleInput(player);
}

void onLevelBegin() {
	jjSetFadeColors(26, 119, 158);
	PaletteSetting(140, 185, 0);
	for (int i = 1; i < 255; i++) {
		jjOBJ@ preset = jjObjectPresets[i];
		if (preset.playerHandling == HANDLING::PICKUP) {
			preset.behavior = CannotBeShotDown(preset.behavior);
		}
	}
}

void onMain() {
	if (duration > 0) { 
		cycleTheme();
		duration--;
	}
	if (jjGameTicks%4401 == 4400) duration = 512;
	if (!jjLowDetail) {
		int speed = (jjGameTicks%(250))*6;
		for (int i=0; i < 3; i++)
		jjDrawRotatedSprite(p.cameraX + (550 + 2*i) - speed*jjSin(400), p.cameraY - (20 + 300*i) - speed*jjCos(400),
		ANIM::CUSTOM[5], 0, 0, 400, 0.1, 0.9, SPRITE::BLEND_NORMAL, 20, 17);
		
		for (int i=0; i < 3; i++)
		jjDrawRotatedSprite(p.cameraX + (750 + 2*i) - speed*jjSin(400), p.cameraY - (280 + 240*i) - speed*jjCos(400),
		ANIM::CUSTOM[5], 0, 0, 400, 0.3, 1.5, SPRITE::BLEND_NORMAL, 30, 17);
		
		for (int i=0; i < 3; i++)
		jjDrawRotatedSprite(p.cameraX + (950 + 2*i) - speed*jjSin(400), p.cameraY - (480 + 150*i) - speed*jjCos(400),
		ANIM::CUSTOM[5], 0, 0, 400, 0.2, 0.6, SPRITE::BLEND_NORMAL, 40, 17);
	
		jjDrawResizedSprite(p.cameraX + 622, p.cameraY + 200, ANIM::CUSTOM[4], 0, 0, 0.58, 0.58, SPRITE::NEONGLOW, neonIndex, 17, 4);
		jjDrawResizedSprite(p.cameraX + 622, p.cameraY + 200, ANIM::CUSTOM[4], 0, 0, 0.575, 0.575, SPRITE::NEONGLOW, neonIndex, 17, 4);
	}
	AATools::classProcessing();
	Starmageddon::handleCooldown();
}

void onReceive(jjSTREAM &in packet, int clientID) {
	Starmageddon::handlePacket(packet, clientID);
	Starboard::handlePacket(packet, clientID);
	Exoskeleton::handlePacket(packet, clientID);
}

bool onDrawAmmo(jjPLAYER@ play, jjCANVAS@ hud) {
	if (play.currWeapon == Starmageddon::weaponID) {
		Starmageddon::drawAmmo(play, hud);
		return true;
	}
	return false;
}

void onPlayerDraw(jjPLAYERDRAW& draw) {
	draw.trail = false;
}