Downloads containing ab20ctf02.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Anniversary Bash 20 Levels Jazz2Online Multiple N/A Download file

File preview

#include "MLLE-Include-1.4.asc"
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "ab20ctf02.j2l"
#pragma require "rain.wav"
#pragma require "creak08.wav"
#pragma require "metalhit07.wav"

jjPAL rusted;
int hue, sat, light;

bool isYellow() {
	return hue > 0 && hue < 20;
}

void onLevelLoad() {
	jjUseLayer8Speeds = true;
	
	jjWaterLighting = WATERLIGHT::GLOBAL;
	jjSetWaterLevel(53*32, true);
	jjSetWaterGradient(0,0,0, 204,119,34);
	
	rusted.load("pk2.j2t");
	
	for (int n = 96; n <= 254; n++) {
		hue = jjPalette.color[n].getHue();
		sat = jjPalette.color[n].getSat();
		light = jjPalette.color[n].getLight();
		
		rusted.color[n].setHSL(hue + (isYellow()? -5:20), sat * 2 / (isYellow()? 5:3), light * 2 / 3);
	}
	rusted.apply();
	
	darkenLayer(jjLayers[6]);
			
	for (int x = 0; x < jjLayerWidth[4]; x++) {
		for (int y = 0; y < jjLayerHeight[4]; y++) {
			uint16 tile = jjTileGet(4, x, y);			
			if (jjEventGet(x, y) == 119) jjTileSet(4, x, y, tile ^ TILE::VFLIPPED);
		}
	}

    for (int i = 1; i < 255; i++) {
		if (jjObjectPresets[i].behavior == BEHAVIOR::PICKUP) {
			jjObjectPresets[i].behavior = CannotBeShotDown;
		}
	}

	jjSampleLoad(SOUND::INTRO_BLOW, "rain.wav");
	jjSampleLoad(SOUND::INTRO_BRAKE, "creak08.wav");
	jjSampleLoad(SOUND::INTRO_GRAB, "metalhit07.wav");
}

void CannotBeShotDown(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::PICKUP);
	if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT;
}

void darkenLayer(jjLAYER@ layer) {
	array<int> tileIDs, uniqueTileIDs;
	for (int i = 0; i < layer.height; i++) {
		for (int j = 0; j < layer.width; j++) {
			int tileID = layer.tileGet(j, i);
			if (tileID != 0)
				tileIDs.insertLast(tileID);
		}
	}
	int prev = 0;
	tileIDs.sortAsc();
	for (uint i = 0; i < tileIDs.length(); i++) {
		if (tileIDs[i] != prev)
			uniqueTileIDs.insertLast(prev = tileIDs[i]);
	}
	uint firstNewTile = jjTileCount;
	jjTilesFromTileset(jjTilesetFileName, 1, uniqueTileIDs.length());
	array<uint8> mapping(256);
	for (uint i = 0; i < uniqueTileIDs.length(); i++) {
		jjPIXELMAP tile(uniqueTileIDs[i]);
		for (int j = 0; j < 32; j++) {
			for (int k = 0; k < 32; k++) {
				uint8 pixel = tile[k, j];
				if (pixel != 0) {
					if (mapping[pixel] == 0) {
						jjPALCOLOR color = jjPalette.color[pixel];
						color.red = color.red / 2;
						color.green = color.green / 2;
						color.blue = color.blue / 2;
						mapping[pixel] = jjPalette.findNearestColor(color);
					}
					tile[k, j] = mapping[pixel];
				}
			}
		}
		tile.save(firstNewTile + i);
	}
	layer.generateSettableTileArea();
	for (int i = 0; i < layer.height; i++) {
		for (int j = 0; j < layer.widthReal; j++) {
			int tileID = layer.tileGet(j, i);
			if (tileID != 0)
				layer.tileSet(j, i, firstNewTile + uniqueTileIDs.find(tileID));
		}
	}
}


void onLevelBegin() {
	jjMASKMAP blank;
	for (int i = 0; i < 8; i++) {
		blank.save(340 + i);
	}
	
	jjPIXELMAP stripes(196);
	jjPIXELMAP tempStripeMap;	

	for (uint x = 0; x < tempStripeMap.width; ++x) {
		for (uint y = 0; y < tempStripeMap.height; ++y) {
			if (x > 16 && y > 16) tempStripeMap[x,y] = 0;
			else tempStripeMap[x,y] = stripes[x,y];
		}
	}
	tempStripeMap.save(340);
			
	for (uint x = 0; x < tempStripeMap.width; ++x) {
		for (uint y = 0; y < tempStripeMap.height; ++y) {
			if (y > 16) tempStripeMap[x,y] = 0;
			else tempStripeMap[x,y] = stripes[x,y];
		}
	}
	tempStripeMap.save(341);

	for (uint x = 0; x < tempStripeMap.width; ++x) {
		for (uint y = 0; y < tempStripeMap.height; ++y) {
			if (x < 16 && y > 16) tempStripeMap[x,y] = 0;
			else tempStripeMap[x,y] = stripes[x,y];
		}
	}
	tempStripeMap.save(342);
	
	for (uint x = 0; x < tempStripeMap.width; ++x) {
		for (uint y = 0; y < tempStripeMap.height; ++y) {
			
			if (x > 16) tempStripeMap[x,y] = 0;
			else tempStripeMap[x,y] = stripes[x,y];
		}
	}
	tempStripeMap.save(343);
	
	for (uint x = 0; x < tempStripeMap.width; ++x) {
		for (uint y = 0; y < tempStripeMap.height; ++y) {
			
			if (x < 16) tempStripeMap[x,y] = 0;
			else tempStripeMap[x,y] = stripes[x,y];
		}
	}
	tempStripeMap.save(344);
	
	for (uint x = 0; x < tempStripeMap.width; ++x) {
		for (uint y = 0; y < tempStripeMap.height; ++y) {
			if (x > 16 && y < 16) tempStripeMap[x,y] = 0;
			else tempStripeMap[x,y] = stripes[x,y];
		}
	}
	tempStripeMap.save(345);
			
	for (uint x = 0; x < tempStripeMap.width; ++x) {
		for (uint y = 0; y < tempStripeMap.height; ++y) {
			if (y < 16) tempStripeMap[x,y] = 0;
			else tempStripeMap[x,y] = stripes[x,y];
		}
	}
	tempStripeMap.save(346);

	for (uint x = 0; x < tempStripeMap.width; ++x) {
		for (uint y = 0; y < tempStripeMap.height; ++y) {
			if (x < 16 && y < 16) tempStripeMap[x,y] = 0;
			else tempStripeMap[x,y] = stripes[x,y];
		}
	}
	tempStripeMap.save(347);
}

void onMain() {
	jjIsSnowing = !jjLowDetail;
	
	if (!jjLowDetail) {
		if (jjGameTicks % 140 == 0) jjSample(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::INTRO_BLOW, 48, 0);
		if (jjGameTicks % 1500 == 0) jjSample(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::INTRO_BRAKE, 60, 0);
		if (jjGameTicks % 2400 == 0) jjSample(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::INTRO_GRAB, 32, 0);
	}
}