Downloads containing ab21ctf21.j2as

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

File preview

#include "MLLE-Include-1.4.asc"
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "ab21ctf21-MLLE-Data-1.j2l"
#pragma require "ab21ctf21.j2l"

void onPlayer(jjPLAYER@ player){
	player.lightType = LIGHT::NONE;
}


void onLevelLoad() {
	jjAnimSets[ANIM::RAVEN].load();

	jjObjectPresets[OBJECT::FLICKERLIGHT].behavior = torch;

	jjPalette.gradient(0,36,16,144,174,72,99,9);
	jjPalette.gradient(48,8,8,174,114,54,120,8);
	jjPalette.gradient(144,174,72,0,11,0,16,8);
	jjPalette.gradient(102,102,8,0,0,0,107,1);
	
	//for (int i = 1; i < 255; i++) {
		//if (jjObjectPresets[i].playerHandling == HANDLING::PICKUP) {
			//jjObjectPresets[i].behavior = CannotBeBuried();
		//}
	//}
	
	generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {40});
	turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 19.f, false);
	
	jjANIMATION@ anim = jjAnimations[jjAnimSets[ANIM::BRIDGE] + 1];
	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] >= 64 && sprite[x,y] <= 71) sprite[x,y] = 112 + (sprite[x,y]&7)*2;
			}
		}
		sprite.save(frame);
	}

}

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 torch(jjOBJ@ obj) {
	jjDrawSprite(obj.xPos+10, obj.yPos-19, ANIM::AMMO, 13, jjGameTicks / 8 % 6);
}

class Raven {
    private float xPos, yPos, xOrg, yOrg, minScale, maxScale;
    private int direction, color;
    
    void setParameters(Raven@ raven, float xOrg, float yOrg, float minScale, float maxScale, int direction, int color) {
        raven.xOrg = xOrg;
        raven.yOrg = yOrg;
        raven.minScale = minScale;
        raven.maxScale = maxScale;
        raven.direction = direction;
        raven.color = color;
    }
    
    void getPosition(Raven@ raven) {
        raven.xPos = jjSin(jjGameTicks)*64*raven.direction + raven.xOrg;
        raven.yPos = jjCos(jjGameTicks)*16*raven.direction + raven.yOrg;
    }
    
    void draw(Raven@ raven, jjCANVAS@ canvas) {
        canvas.drawResizedSprite(int(raven.xPos), int(raven.yPos), ANIM::RAVEN, raven.yPos > (raven.yOrg + 0.24) && raven.yPos < (raven.yOrg + 2.8)? 2:1, jjGameTicks >> 3, raven.yPos >= (raven.yOrg + 2.8)? maxScale:-minScale, raven.yPos >= (raven.yOrg + 2.8)? maxScale:minScale, SPRITE::SINGLECOLOR, raven.color);
    }
}

void onDrawLayer6(jjPLAYER@ play, jjCANVAS@ canvas) {
    array<Raven> ravens(3);
    
    ravens[0].setParameters(ravens[0], 610, 120, 0.48, 0.55, -1, 71);
    ravens[0].getPosition(ravens[0]);
	
	ravens[0].draw(ravens[0], canvas);
	
	ravens[1].setParameters(ravens[1], 130, 320, 0.61, 0.66, 1, 71);
    ravens[1].getPosition(ravens[1]);
    
    ravens[1].draw(ravens[1], canvas);
	
	ravens[2].setParameters(ravens[2], 690, 300, 0.63, 0.68, 1, 71);
    ravens[2].getPosition(ravens[2]);
    
    ravens[2].draw(ravens[2], canvas);
}

void onDrawLayer7(jjPLAYER@ play, jjCANVAS@ canvas) {
    array<Raven> ravens(2);

    ravens[0].setParameters(ravens[0], 60, -20, 0.33, 0.38, 1, 71);
    ravens[0].getPosition(ravens[0]);
	
    ravens[0].draw(ravens[0], canvas);
	
	ravens[1].setParameters(ravens[1], 590, -0, 0.38, 0.42, 1, 71);
    ravens[1].getPosition(ravens[1]);
	
    ravens[1].draw(ravens[1], canvas);
}

void onMain(){
  jjOBJ@ obj;
  for(int i=0;i<jjObjectCount;i++)
  {
    @obj=jjObjects[i];
    if(!obj.isActive) {continue;}
    switch(obj.eventID)
    {
      case OBJECT::GREENSPRING:
        if(obj.yPos>69*32) {obj.ySpeed=-25.5;}
        if(obj.freeze>0&&jjGameTicks%2==0) {obj.freeze++;}
        break;
	}
   }
}