Downloads containing ezlight.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Starlight Canyon 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 "ezlight-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "diamult-storm.j2t" ///@MLLE-Generated
#pragma require "Aztec2.j2t" ///@MLLE-Generated
#pragma require "Stars.j2t" ///@MLLE-Generated
#pragma require "ezlight.j2l" ///@MLLE-Generated

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

array<uint8> ids = {119, 120, 121, 122, 123, 124, 125, 126, 127};

void applyDarkening(int num) {
	jjPAL pal = jjSpriteModeGetColorMapping(0);
	for (uint i = 0; i < 254; i++) {
		int lum = (pal.color[i].getLight() - num > 0) ? pal.color[i].getLight() - num : 0;
		pal.color[i].setHSL(pal.color[i].getHue(), pal.color[i].getSat(), (lum > 0) ? lum : 0);
	}
	jjSpriteModeSetMapping(0, jjSpriteModeGetIndexMapping(0), pal);
}

void PaletteSetting(uint hue, uint sat) {
	for (uint i = 0; i < ids.length; i++) 
		jjPalette.color[ids[i]].setHSL(hue, sat, jjPalette.color[ids[i]].getLight());
    jjPalette.apply();
    jjPALCOLOR color = jjPalette.color[ids[5]];
    jjSetFadeColors(color.red, color.green, color.blue);
}

bool onLocalChat(string &in stringReceived, CHAT::Type chatType) {
    array<string> results;
	if (jjRegexMatch(stringReceived,"!palette\\s(\\d+)\\s(\\d+)",results,true)) {
		int hue = int(abs(parseInt(results[1])));
		int sat = int(abs(parseInt(results[2])));
		if (hue <= 255 && sat <= 255) {
		    PaletteSetting(hue, sat);
		} else jjAlert("|>> Both parameters must not exceed 255");
		return true;
	}
	return false;
}

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 DarkenedSpring : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::SPRING, false);
	}
	void onDraw(jjOBJ@ obj) {
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::BRIGHTNESS, 85);
	}
}

class GreyCrate : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::CRATE, false);
	}
	void onDraw(jjOBJ@ obj) {
		jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::SINGLEHUE, 72);
	}
}

void onLevelBegin() {
	for (int i = 1; i < 255; i++) {
		jjOBJ@ preset = jjObjectPresets[i];
		if (preset.playerHandling == HANDLING::PICKUP) {
			preset.behavior = CannotBeShotDown(preset.behavior);
		}
	}
}

void onLevelLoad() {
	applyDarkening(22);
	PaletteSetting(150, 65);
	jjSetWaterLevel(32*50, true);
	jjWaterLayer = 5;
	jjSetWaterGradient(0, 25, 50, 0, 90, 136);
	
	jjObjectPresets[OBJECT::GUNCRATE].behavior = GreyCrate();
	jjObjectPresets[OBJECT::GREENSPRING].behavior = jjObjectPresets[OBJECT::REDSPRING].behavior = DarkenedSpring();
}

void onMain () {
	for (uint i = 0; i < 2; i++) {
		jjPAL pal = jjSpriteModeGetColorMapping(0);
		int lum = int(125 + jjSin(jjGameTicks*2)*125);
		pal.color[254+i].setHSL(pal.color[254+i].getHue(), pal.color[254+i].getSat(), (lum > 90) ? lum : 90);
		jjSpriteModeSetMapping(0, jjSpriteModeGetIndexMapping(0), pal);
		jjLayers[8].spriteMode = SPRITE::MAPPING;
	}
}