Downloads containing ab19btl01.j2as

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

File preview

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 / 3;
						color.green = color.green * 2 / 3;
						color.blue = color.blue * 2 / 3;
						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));
		}
	}
}

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

void onLevelLoad() {
	darkenLayer(jjLayers[6]);
	
	for (int i = 1000; i <= 4090; i++) {
		jjTileType[i] = 0;
	}
	
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::WISETYNESS;
	
	jjWaterLighting = WATERLIGHT::GLOBAL;
	jjSetWaterLevel(32*145, true);
	jjSetWaterGradient(110,20,155, 255,235,125);
	
	for (int i = 1; i < 255; i++) {
		if (jjObjectPresets[i].behavior == BEHAVIOR::PICKUP) {
			jjObjectPresets[i].behavior = CannotBeShotDown;
		}
	}
	
	jjObjectPresets[OBJECT::REDSPRING].behavior =
	jjObjectPresets[OBJECT::GREENSPRING].behavior =
	jjObjectPresets[OBJECT::BLUESPRING].behavior = OffsetSpring;
	
	jjObjectPresets[OBJECT::CAKE].behavior = UnripeFruit;
	jjObjectPresets[OBJECT::CAKE].playerHandling = HANDLING::PARTICLE;
	jjObjectPresets[OBJECT::CAKE].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::CAKE].isBlastable = false;
	
	jjObjectPresets[OBJECT::CHEESE].behavior = RipeningFruit;
	jjObjectPresets[OBJECT::CHEESE].playerHandling = HANDLING::PARTICLE;
	jjObjectPresets[OBJECT::CHEESE].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::CHEESE].isBlastable = false;
	
	jjObjectPresets[OBJECT::CHERRY].behavior = RipeningFruit2;
	jjObjectPresets[OBJECT::CHERRY].playerHandling = HANDLING::PARTICLE;
	jjObjectPresets[OBJECT::CHERRY].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::CHERRY].isBlastable = false;
	
	jjObjectPresets[OBJECT::CHICKENLEG].behavior = SmallFruit;
	jjObjectPresets[OBJECT::CHICKENLEG].playerHandling = HANDLING::PARTICLE;
	jjObjectPresets[OBJECT::CHICKENLEG].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::CHICKENLEG].isBlastable = false;
	
	jjObjectPresets[OBJECT::CHOCBAR].behavior = RipeFruit;
	jjObjectPresets[OBJECT::CHOCBAR].playerHandling = HANDLING::PARTICLE;
	jjObjectPresets[OBJECT::CHOCBAR].bulletHandling = HANDLING::IGNOREBULLET;
	jjObjectPresets[OBJECT::CHOCBAR].isBlastable = false;
	
	jjObjectPresets[OBJECT::COPTER].triggersTNT = false;
	
	for (int i = 1; i < 255; i++) {
		if (jjObjectPresets[i].behavior == BEHAVIOR::MONITOR) jjObjectPresets[i].triggersTNT = true;
	}
	
	jjAnimSets[ANIM::SPIKEBOLL].load();
	jjAnimSets[ANIM::UTERUS].load();
	
	jjAnimations[jjAnimSets[ANIM::AMMO] + 59] = jjAnimations[jjAnimSets[ANIM::UTERUS] + 6];
	
	jjANIMATION@ anim = jjAnimations[jjAnimSets[ANIM::UTERUS] + 6];
	for (uint j = 0; j < anim.frameCount; j++) {
		jjANIMFRAME@ frame = jjAnimFrames[anim + j];
		jjPIXELMAP sprite(frame);
		for (uint x = 0; x < sprite.width; ++x) {
			for (uint y = 0; y < sprite.height; ++y) {
				if (sprite[x,y] >= 80 && sprite[x,y] <= 87) sprite[x,y] -= 40;
				if (sprite[x,y] >= 16 && sprite[x,y] <= 23) sprite[x,y] += 24;
			}
		}
		sprite.save(frame);
	}
		
	jjANIMATION@ anim2 = jjAnimations[jjAnimSets[ANIM::AMMO] + 9];
	for (uint j = 0; j < anim2.frameCount; j++) {
		jjANIMFRAME@ frame = jjAnimFrames[anim2 + j];
		jjPIXELMAP sprite(frame);
		for (uint x = 0; x < sprite.width; ++x) {
			for (uint y = 0; y < sprite.height; ++y) {
				if (sprite[x,y] >= 64 && sprite[x,y] <= 71) sprite[x,y] += 6;
			}
		}
		sprite.save(frame);
	}
	
	jjObjectPresets[OBJECT::TNT].killAnim = jjObjectPresets[OBJECT::SEEKERBULLET].killAnim;
	jjObjectPresets[OBJECT::TNT].determineCurFrame();
	jjObjectPresets[OBJECT::TNT].lightType = LIGHT::NONE;
	jjObjectPresets[OBJECT::TNT].behavior = SpikeBomb;
	
}

void OffsetSpring(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::SPRING);
	obj.yPos = obj.yOrg + 16;
}

void UnripeFruit(jjOBJ@ obj) {
	if (inView(obj))
		jjDrawResizedSprite(obj.xPos, obj.yPos, ANIM::SPIKEBOLL, 0, 0, 0.85, 0.85, SPRITE::SINGLEHUE, 96);
}

void RipeningFruit(jjOBJ@ obj) {
	if (inView(obj)) {
		jjDrawResizedSprite(obj.xPos, obj.yPos, ANIM::SPIKEBOLL, 0, 0, 0.9, 0.9, SPRITE::SINGLEHUE, 96);
		jjDrawResizedSprite(obj.xPos, obj.yPos, ANIM::SPIKEBOLL, 0, 0, 0.9, 0.9, SPRITE::BLEND_COLOR, 40);
	}
}

void RipeningFruit2(jjOBJ@ obj) {
	if (inView(obj)) {
		jjDrawResizedSprite(obj.xPos, obj.yPos, ANIM::SPIKEBOLL, 0, 0, 0.95, 0.95, SPRITE::SINGLEHUE, 96);
		jjDrawResizedSprite(obj.xPos, obj.yPos, ANIM::SPIKEBOLL, 0, 0, 0.95, 0.95, SPRITE::TRANSLUCENTSINGLEHUE, 40);
	}
}

void SmallFruit(jjOBJ@ obj) {
	if (inView(obj))
		jjDrawResizedSprite(obj.xPos, obj.yPos, ANIM::SPIKEBOLL, 0, 0, 0.5, 0.5, SPRITE::SINGLEHUE, 96);
}

void RipeFruit(jjOBJ@ obj) {
	if (inView(obj))
		jjDrawResizedSprite(obj.xPos, obj.yPos, ANIM::SPIKEBOLL, 0, 0, 1, 1, SPRITE::SINGLEHUE, 40);
}

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

void SpikeBomb(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::TNT);
	
	if (obj.counter == 1 && jjPlayers[obj.creatorID].isLocal) jjSample(obj.xPos, obj.yPos, SOUND::COMMON_FOEW2, 0, 0);
	
	if (!jjMaskedHLine(int(obj.xPos - 12) , 24, int(obj.yPos + 8))) {
		obj.yPos += 5;
	}
	
	if (obj.state == STATE::EXPLODE) {
		jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PISTOL1, 0, 0);
		obj.delete();
		for (int i = -8; i <= 8; i += 8) {
			for (int j = -8; j <= 8; j += 8) {
				if (i != 0 || j != 0) {
					int id = jjAddObject(OBJECT::BULLET, obj.xPos, obj.yPos, obj.creatorID, CREATOR::PLAYER, BEHAVIOR::PEPPERBULLET);
					if (id != 0) {
						jjOBJ@ burst = jjObjects[id];
						burst.animSpeed = 1;
						burst.direction = obj.direction;
						burst.playerHandling = HANDLING::PLAYERBULLET;
						burst.var[3] = 8;
						burst.xSpeed = j;
						burst.ySpeed = i;
					}
				}
			}
		}
	}
}

void onPlayer(jjPLAYER@ play) {
	if (jjTriggers[31] && play.shieldTime <= 1) {
		play.fly = FLIGHT::NONE;
		jjTriggers[31] = false;
	}
}