Downloads containing ezscarlet.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Scarlet WealdFeatured Download PurpleJazz Capture the flag 9.5 Download file

File preview

const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, BubbleGun::Weapon(), null, null, null, null, null, null}); ///@MLLE-Generated
#include "MLLE-Include-1.6w.asc" ///@MLLE-Generated
#pragma require "ezscarlet-MLLE-Data-3.j2l" ///@MLLE-Generated
#pragma require "ezscarlet-MLLE-Data-2.j2l" ///@MLLE-Generated
#pragma require "ezscarlet-MLLE-Data-1.j2l" ///@MLLE-Generated
#pragma require "ezscarlet.j2l" ///@MLLE-Generated
#include "BubbleGun.asc" ///@MLLE-Generated
#pragma require "BubbleGun.asc" ///@MLLE-Generated
///@SaveAndRunArgs -server -capture ///@MLLE-Generated
#pragma require "s_web1.png"
#pragma require "s_web2.png"
#pragma require "TreeA1.png"
#pragma require "TreeA2.png"
#pragma require "TreeB1.png"
#pragma require "TreeB2.png"
#pragma require "TreeB2.png"
#pragma require "ezscarlet_wind.ogg"
#pragma require "ezscarlet_leafsound.ogg"
#pragma require "ezscarlet_raven.ogg"

class vector2i {
	int x, y;
}

array<vector2i> oneWays;

int sample, sample2;

void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[10]].load(
		jjPIXELMAP("s_web1.png"),
		frameWidth: 128,
		frameHeight: 128
	);
	
	jjAnimSets[ANIM::CUSTOM[11]].load(
		jjPIXELMAP("s_web2.png"),
		frameWidth: 96,
		frameHeight: 96
	);
	
	jjAnimSets[ANIM::CUSTOM[12]].load(
		jjPIXELMAP("TreeA1.png"),
		frameWidth: 288,
		frameHeight: 288
	);
	
	jjAnimSets[ANIM::CUSTOM[13]].load(
		jjPIXELMAP("TreeB1.png"),
		frameWidth: 288,
		frameHeight: 288
	);
	
	jjAnimSets[ANIM::CUSTOM[14]].load(
		jjPIXELMAP("TreeA2.png"),
		frameWidth: 288,
		frameHeight: 288
	);
	
	jjAnimSets[ANIM::CUSTOM[15]].load(
		jjPIXELMAP("TreeB2.png"),
		frameWidth: 288,
		frameHeight: 288
	);
	
	jjObjectPresets[OBJECT::APPLE].behavior =
	jjObjectPresets[OBJECT::ORANGE].behavior = SpiderWeb();
	jjObjectPresets[OBJECT::CHERRY].behavior =
	jjObjectPresets[OBJECT::STRAWBERRY].behavior = RedTree();
	jjObjectPresets[OBJECT::LIME].behavior = 
	jjObjectPresets[OBJECT::PEAR].behavior = GreenTree();
	
	jjObjectPresets[OBJECT::APPLE].playerHandling =
	jjObjectPresets[OBJECT::ORANGE].playerHandling =
	jjObjectPresets[OBJECT::CHERRY].playerHandling =
	jjObjectPresets[OBJECT::STRAWBERRY].playerHandling =
	jjObjectPresets[OBJECT::LIME].playerHandling = 
	jjObjectPresets[OBJECT::PEAR].playerHandling = HANDLING::PARTICLE;
	
	jjObjectPresets[OBJECT::APPLE].bulletHandling =
	jjObjectPresets[OBJECT::ORANGE].bulletHandling =
	jjObjectPresets[OBJECT::CHERRY].bulletHandling =
	jjObjectPresets[OBJECT::STRAWBERRY].bulletHandling =
	jjObjectPresets[OBJECT::LIME].bulletHandling = 
	jjObjectPresets[OBJECT::PEAR].bulletHandling = HANDLING::IGNOREBULLET;
	
	jjObjectPresets[OBJECT::APPLE].isBlastable =
	jjObjectPresets[OBJECT::ORANGE].isBlastable =
	jjObjectPresets[OBJECT::CHERRY].isBlastable =
	jjObjectPresets[OBJECT::STRAWBERRY].isBlastable =
	jjObjectPresets[OBJECT::LIME].isBlastable = 
	jjObjectPresets[OBJECT::PEAR].isBlastable = false;
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40});
	turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 18.5f, false);
	
	for (uint i = 0; i < 160; i++) {
		Leaf newLeaf;
		newLeaf.setParameters(newLeaf, jjRandom()%(jjLayerWidth[1]*32), jjRandom()%300);
		Leaves.insertLast(newLeaf);
	}
}

class SpiderWeb : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (inView(obj) && !jjLowDetail) {
			jjDrawSprite(obj.xPos, obj.yPos, obj.eventID == OBJECT::APPLE? ANIM::CUSTOM[10] : ANIM::CUSTOM[11], 0, (jjGameTicks/4) % 12, 0, SPRITE::NORMAL, 0, 5, 5);
		}
	}
}

class RedTree : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (inView(obj) && !jjLowDetail) {
			jjDrawSprite(obj.xPos, obj.yPos, obj.eventID == OBJECT::CHERRY? ANIM::CUSTOM[12] : ANIM::CUSTOM[13], 0, (jjGameTicks/4) % 12, 0, SPRITE::NORMAL, 0, 15, 15);
		}
	}
}

class GreenTree : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		if (inView(obj) && !jjLowDetail) {
			jjDrawSprite(obj.xPos, obj.yPos, obj.eventID == OBJECT::LIME? ANIM::CUSTOM[14] : ANIM::CUSTOM[15], 0, (jjGameTicks/4) % 12, 0, SPRITE::NORMAL, 0, 15, 15);
		}
	}
}

bool inView(const jjOBJ@ obj) {
	for (int i = 0; i < jjLocalPlayerCount; i++) {
		const jjPLAYER@ play = jjLocalPlayers[i];
		if (obj.xPos > play.cameraX - 144 && obj.yPos > play.cameraY - 144 && obj.xPos < play.cameraX + jjSubscreenWidth + 144 && obj.yPos < play.cameraY + jjSubscreenHeight + 144)
			return true;
	}
	return false;
}

jjANIMSET@ customSpringSprite;
array<int> fastCustomSpringSpeeds(jjLocalPlayerCount);
bool generateCustomSpringSprites(jjANIMSET@ anim, const array<uint> &in colors) {
	int length = colors.length();
	bool success = (@customSpringSprite = anim).allocate(array<uint>(length * 3, 5)) !is null;
	if (success) {
		uint srcSet = jjAnimSets[ANIM::SPRING];
		for (int i = 0; i < length; i++) {
			uint color = colors[i];
			uint destAnimOffset = anim + i * 3;
			for (int j = 0; j < 3; j++) {
				uint srcAnim = jjAnimations[srcSet + j];
				uint destAnim = jjAnimations[destAnimOffset + j];
				for (int k = 0; k < 5; k++) {
					jjPIXELMAP image(jjAnimFrames[destAnim + k] = jjAnimFrames[srcAnim + k]);
					int width = image.width;
					int height = image.height;
					for (int l = 0; l < height; l++) {
						for (int m = 0; m < width; m++) {
							int pixel = image[m, l];
							if (pixel >= 32 && pixel < 40)
								image[m, l] = color + (pixel & 7);
						}
					}
					if (!image.save(jjAnimFrames[destAnim + k]))
						return false;
				}
			}
		}
	}
	return success;
}
void initializeCustomSpring(jjOBJ@ obj) {
	int anim = obj.curAnim;
	obj.behave(obj.behavior = BEHAVIOR::SPRING, false);
	if (obj.curAnim != anim) {
		obj.curAnim = anim + 2;
		obj.determineCurFrame();
	}
	obj.draw();
}
void turnIntoCustomSpring(jjOBJ@ obj, uint color, float power, bool horizontal) {
	if (horizontal) {
		obj.xSpeed = power;
		obj.ySpeed = 0.f;
	} else {
		obj.xSpeed = 0.f;
		obj.ySpeed = -power;
		if (obj.state == STATE::START && obj.creatorType == CREATOR::LEVEL) {
			int x = int(obj.xPos) >> 5;
			int y = int(obj.yPos) >> 5;
			if (jjParameterGet(x, y, 0, 1) != 0) {
				jjParameterSet(x, y, 0, 1, 0);
				obj.yPos -= 4.f;
				obj.ySpeed = power;
			}
		}
	}
	obj.behavior = initializeCustomSpring;
	obj.curAnim = customSpringSprite + color * 3 + (horizontal ? 1 : 0);
	obj.energy = obj.frameID = obj.freeze = obj.justHit = obj.light = obj.points = 0;
	obj.isBlastable = obj.isTarget = obj.scriptedCollisions = obj.triggersTNT = false;
	obj.deactivates = obj.isFreezable = true;
	obj.bulletHandling = HANDLING::IGNOREBULLET;
	obj.playerHandling = HANDLING::SPECIAL;
	obj.lightType = LIGHT::NORMAL;
	obj.determineCurFrame();
}

void onLevelBegin() {
	MLLE::SpawnOffgrids();
	
	for (int i = 1; i < 255; i++) {
		jjOBJ@ preset = jjObjectPresets[i];
		if (preset.playerHandling == HANDLING::PICKUP) {
			preset.behavior = CannotBeBuried(preset.behavior);
		}
	}
	
	jjSampleLoad(SOUND::WIND_WIND2A, "ezscarlet_wind.ogg");
	jjSampleLoad(SOUND::SCIENCE_PLOPKAOS, "ezscarlet_leafsound.ogg");
	jjSampleLoad(SOUND::STONED_STONED, "ezscarlet_raven.ogg");
	
	jjObjectPresets[OBJECT::ICEBULLET].ySpeed = jjObjectPresets[OBJECT::ICEBULLET].ySpeed - 1;
	jjObjectPresets[OBJECT::ICEBULLET].xSpeed = jjObjectPresets[OBJECT::ICEBULLET].xSpeed + 1;
	
}

class CannotBeBuried : jjBEHAVIORINTERFACE {
	CannotBeBuried(const jjBEHAVIOR &in behavior) {
		originalBehavior = behavior;
	}
	void onBehave(jjOBJ@ obj) {
		obj.behave(originalBehavior);
		if (jjMaskedPixel(int(obj.xPos), int(obj.yPos + 8))) {
			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;
}

void onPlayer(jjPLAYER@ play) {
	for (uint i = 0; i < oneWays.length(); i++) {
		jjEventSet(oneWays[i].x, oneWays[i].y, AREA::ONEWAY);
	}
	oneWays.resize(0);
	int px = int(play.xPos), py = int(play.yPos);
	bool masked;
	for (int i = -11 + int(play.ySpeed); i <= 14; i++) {
		if (masked = jjMaskedHLine(px - 14, 28, py + i))
			break;
	}
	if (!masked) {
		for (int i = 8; i <= 16; i += 8) {
			for (int j = 12; j <= 20; j += 8) {
				int x = (px + play.direction * j) >>> 5, y = (py + i) >>> 5;
				if (x >= 0 && y >= 0 && x < jjLayerWidth[4] && y < jjLayerHeight[4] && jjEventGet(x, y) == AREA::ONEWAY) {
					vector2i point;
					jjEventSet(point.x = x, point.y = y, 0);
					oneWays.insertLast(point);
				}
			}
		}
	}
}

void onMain() {
	array<jjLAYER@> layers = jjLayerOrderGet();
	
	if (!jjLowDetail) {
		jjIsSnowing = jjGameTicks % 27 == 0? true:false;
		sample = jjSampleLooped(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::WIND_WIND2A, sample, jjLocalPlayers[0].yPos < 45*32? 32:24, 0);
		sample2 = jjSampleLooped(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::SCIENCE_PLOPKAOS, sample2, jjLocalPlayers[0].yPos < 45*32? 32:24, 0);
		
		if (jjGameTicks % 850 == 0 && jjGameTicks > 2) {
			jjSample(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::STONED_STONED, jjLocalPlayers[0].yPos < 45*32? 0:30, 0);
		}
		
		layers[20].hasTiles = jjColorDepth == 16? true:false;
		layers[25].hasTiles = false;
		
	} else {
		jjIsSnowing = false;
		layers[25].hasTiles = true;
	}
	
	layers[8].hasTiles = layers[9].hasTiles = jjColorDepth == 16? true:false;
	
	for (int i = 0; i < 1024; i++) {
		jjPARTICLE@ particle = jjParticles[i];
		if (particle.type == PARTICLE::LEAF) {
			particle.xSpeed = -1.75;
			particle.ySpeed = 0.05;
		}
	}
}

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

class Leaf {
	private float xPos, yPos, xOrg, yOrg, xSpeed, ySpeed, size;
	private int color, frame;
	
	void setParameters(Leaf@ leaf, float xOrg, float yOrg) {
        leaf.xOrg = leaf.xPos = xOrg;
		leaf.yOrg = leaf.yPos = yOrg;
		leaf.frame = frame;
		leaf.size = size;
		
		leaf.xSpeed = ((0.75 + (jjRandom()%20) * 0.05));
		leaf.ySpeed = ((0.325 + (jjRandom()%20) * 0.025));
    }
	
	void setPosition(Leaf@ leaf) {
		leaf.xPos = leaf.xPos - leaf.xSpeed;
		leaf.yPos = leaf.yPos + leaf.ySpeed;
    }
	
	float getXPosition(Leaf@ leaf) {
		return leaf.xPos;
	}
	
	void draw(Leaf@ leaf, jjCANVAS@ canvas) {
        canvas.drawResizedSprite(int(leaf.xPos), int(leaf.yPos), ANIM::PLUS_SCENERY, 0, jjGameTicks >> 2, 0.5, 0.5, SPRITE::TINTED, 179);
    }
}
array<Leaf> Leaves;

void onDrawLayer1(jjPLAYER@ play, jjCANVAS@ canvas) {
	if (!jjLowDetail) {
		for (uint i = 0; i < Leaves.length(); i++) {
			Leaf@ leaf = Leaves[i];
			
			leaf.setPosition(leaf);
			leaf.draw(leaf, canvas);
			
			if (leaf.getXPosition(leaf) < -256) {
				leaf.setParameters(leaf, jjRandom()%(jjLayerWidth[1]*32), jjRandom()%50);
			}
		}
	}
}

bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
	return MLLE::WeaponHook.drawAmmo(player, canvas);
}