Downloads containing ab23btl13.j2as

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

File preview

#include "MLLE-Include-1.5.asc" ///@MLLE-Generated
const bool MLLESetupSuccessful = MLLE::Setup();
#pragma require "ab23btl13-MLLE-Data-3.j2l"
#pragma require "ab23btl13-MLLE-Data-2.j2l"
#pragma require "ab23btl13-MLLE-Data-1.j2l"
#pragma require "ab23btl13.j2l"
#pragma require "HauntedH1.j2t"
#pragma require "nocturne-xtra.j2t"
#pragma require "InfernoN.j2t"
#pragma require "MedvioS.j2t"
#pragma require "Medivo2.j2t"
#pragma require "Waz18.j2t"
#pragma require "Gothic 1.23.j2t"
#pragma require "syringe.j2a"
#pragma require "bell.wav"

class BackgroundBat {
	float xPos;
	float yPos;
	int direction;
	bool active;
	int offset;
	float scale;
	
	BackgroundBat(float xPos, float yPos) {
		this.xPos = xPos;
		this.yPos = yPos;
		this.direction = jjRandom() % 2 == 0 ? 1 : -1;
		this.active = true;
		this.offset = jjRandom() % 7;
		this.scale = ((jjRandom() % 15) + 25)/100.0;
	}

	void draw(jjCANVAS@ canvas) {
		canvas.drawResizedSprite(int(xPos),int(yPos),ANIM::BAT,0,jjGameTicks/7+offset,scale,scale,SPRITE::SINGLECOLOR,0);
	}
	
	void update() {
		yPos -= 0.75;
		if(jjRandom() % 100 == 0) {
			direction *= -1;
		}
		xPos += direction;
	}
}

array<BackgroundBat@> bats(200);

void makeBat(float xPos, float yPos) {
	for(uint i = 0; i < bats.length; i++) {
		if(bats[i] is null || !bats[i].active) {
			@bats[i] = @BackgroundBat(xPos,yPos);
			return;
		} else {
			continue;
		}
	}
}

float ACC_CONST = .005;
float devanSpotX = 15.5*32;
float devanSpotY = 2*32;
float devanPosX = devanSpotX+50;
float devanPosY = devanSpotY-15;
float devanSpeedX = 0;
float devanSpeedY = 0;
float devanAccX = ACC_CONST;
float devanAccY = -ACC_CONST;
float devDir = 0;
float turnTime = -1;

class HangingBat {
	private float xPos;
	private float yPos;
	private int direction;
	private int animPos = -1;
	private int tick = 0;
	private int color = 170;
	
	HangingBat(float xPos, float yPos, int direction) {
		this.xPos = xPos;
		this.yPos = yPos;
		this.direction = direction;
	}
	
	HangingBat(float xPos, float yPos, int direction, int color) {
		this.xPos = xPos;
		this.yPos = yPos;
		this.direction = direction;
		this.color = color;
	}
	
	void draw(jjCANVAS@ canvas) {
		if(animPos == -1) {
			if(jjRandom() % 700 == 0) {
				animPos = 0;
				tick = 0;
			}
		}
		canvas.drawSprite(xPos, yPos, ANIM::BAT, 2, animPos, direction, SPRITE::PALSHIFT,color);
		if(animPos != -1 && tick++ > 7) {
			tick = 0;
			animPos++;
			if(animPos > 8) {
				animPos = -1;
			}
		}
	}
}

array<HangingBat@> hangingBats4();
array<HangingBat@> hangingBats5();

void onDrawLayer4(jjPLAYER@ player, jjCANVAS@ canvas) {
	for(uint i = 0; i < hangingBats4.length; i++) {
		hangingBats4[i].draw(canvas);
	}
}

void onDrawLayer5(jjPLAYER@ player, jjCANVAS@ canvas) {
	for(uint i = 0; i < hangingBats5.length; i++) {
		hangingBats5[i].draw(canvas);
	}
}


void onDrawLayer7(jjPLAYER@ player, jjCANVAS@ canvas) {
	int oldDir = devDir;
	if(devanPosX > devanSpotX) {
		devanAccX = -ACC_CONST;
		devDir = -1;
	}
	else {
		devanAccX = ACC_CONST;
		devDir = 1;
	}
	if(devanPosY > devanSpotY) devanAccY = -ACC_CONST;
	else devanAccY = ACC_CONST;
	if(devDir != oldDir) {
		turnTime = 0;
	}
	devanSpeedX+=devanAccX;
	devanSpeedY+=devanAccY;
	devanPosX+=devanSpeedX;
	devanPosY+=devanSpeedY;
	
	if(turnTime < 0)
		canvas.drawResizedSprite(devanPosX, devanPosY, ANIM::DEVILDEVAN, 5, jjGameTicks/7, devDir*0.5, 0.5, SPRITE::SINGLECOLOR,0);
	else {
		canvas.drawResizedSprite(devanPosX, devanPosY, ANIM::DEVILDEVAN, 9, turnTime/7, devDir*0.5, 0.5, SPRITE::SINGLECOLOR,0);
		turnTime++;
		if(turnTime > 77)
			turnTime = -1;
	}
	
	for(uint i = 0; i < bats.length; i++) {
		BackgroundBat@ bat = @bats[i];
		if(bat !is null && bat.active) {
			bat.update();
			bat.draw(canvas);
			if(bat.yPos < -400) {
				bat.active = false;
			}
			
		}
	}
}

void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[0]].allocate(array<uint> = {1, 4, 3});
	jjPIXELMAP bell(0,0,140,140,4);
	bell.save(jjAnimFrames[jjAnimations[jjAnimSets[ANIM::CUSTOM[0]]]]);
	jjAnimFrames[jjAnimations[jjAnimSets[ANIM::CUSTOM[0]]]].hotSpotX = -70;
	jjAnimFrames[jjAnimations[jjAnimSets[ANIM::CUSTOM[0]]]].hotSpotY = 0;
	
	jjAnimSets[ANIM::DEVILDEVAN].load();
	for (uint i = 0; i < 11; ++i) {
		jjAnimFrames[jjAnimations[jjAnimSets[ANIM::DEVILDEVAN] + 9] + i].hotSpotX -= 19 - int(5 - i/2);
		jjAnimFrames[jjAnimations[jjAnimSets[ANIM::DEVILDEVAN] + 9] + i].hotSpotY -= 10;
	}
	jjAnimSets[ANIM::HATTER].load();
	jjAnimSets[ANIM::MONKEY].load();
	jjAnimSets[ANIM::CUSTOM[28]].load(0, "Syringe.j2a");
	
	jjAnimations[jjAnimSets[ANIM::AMMO] + 62] = jjAnimations[jjAnimSets[ANIM::CUSTOM[28]] + 0];
	jjAnimations[jjAnimSets[ANIM::AMMO] + 61] = jjAnimations[jjAnimSets[ANIM::CUSTOM[28]] + 1];
	jjAnimations[jjAnimSets[ANIM::PLUS_COMMON] + 0] = jjAnimations[jjAnimSets[ANIM::CUSTOM[28]] + 3]; //gun 8 crate

	jjObjectPresets[OBJECT::FIREBALLBULLET].behavior = jjObjectPresets[OBJECT::FIREBALLBULLETPU].behavior = BloodSpear();
	jjObjectPresets[OBJECT::FIREBALLBULLET].ySpeed = -1.5;
	jjObjectPresets[OBJECT::FIREBALLBULLET].xSpeed = 8;
	jjObjectPresets[OBJECT::FIREBALLBULLET].counterEnd = 85;
	jjObjectPresets[OBJECT::FIREBALLBULLET].var[6] = 0;
	jjObjectPresets[OBJECT::FIREBALLBULLETPU].ySpeed = -2;
	jjObjectPresets[OBJECT::FIREBALLBULLETPU].xSpeed = 8.5;
	jjObjectPresets[OBJECT::FIREBALLBULLETPU].counterEnd = 95;
	jjObjectPresets[OBJECT::FIREBALLBULLETPU].var[6] = 8;
	jjObjectPresets[OBJECT::GUN8POWERUP].determineCurAnim(ANIM::CUSTOM[28], 2, true);
	jjObjectPresets[OBJECT::GUN8POWERUP].determineCurFrame();
	//jjEnforceLighting = LIGHT::COMPLETE;
	jjWeapons[WEAPON::GUN8].gradualAim = false;
	jjWeapons[WEAPON::GUN8].defaultSample = false;
	jjWeapons[WEAPON::GUN8].replacedByBubbles = true;		
	
	hangingBats4.insertLast(HangingBat(92.3*32, int(16.5*32),-1));
	hangingBats4.insertLast(HangingBat(94.5*32, int(15.5*32),1));
	hangingBats4.insertLast(HangingBat(96.5*32, int(14.5*32),1));
	hangingBats4.insertLast(HangingBat(98.8*32, int(13.5*32),-1));
	hangingBats4.insertLast(HangingBat(102.2*32, int(11.5*32),-1));
	hangingBats4.insertLast(HangingBat(103.8*32, int(11.5*32),1));
	hangingBats4.insertLast(HangingBat(107.2*32, int(13.5*32),1));
	hangingBats4.insertLast(HangingBat(111.5*32, int(15.5*32),-1));
	hangingBats4.insertLast(HangingBat(114.5*32, int(16.5*32),1));
	hangingBats4.insertLast(HangingBat(117.8*32, int(17.5*32),1));
	hangingBats4.insertLast(HangingBat(87.6*32, int(17.5*32),1));
	hangingBats4.insertLast(HangingBat(88.4*32, int(17.5*32),-1));
	hangingBats4.insertLast(HangingBat(156*32, int(26.5*32),1));
	hangingBats4.insertLast(HangingBat(158*32, int(26.5*32),-1));
	hangingBats4.insertLast(HangingBat(166*32, int(26.5*32),1));
	hangingBats4.insertLast(HangingBat(168*32, int(26.5*32),-1,190));
	hangingBats4.insertLast(HangingBat(170*32, int(26.5*32),1));
	
	hangingBats5.insertLast(HangingBat(100.5*32, int(12.2*32),1));
	hangingBats5.insertLast(HangingBat(109*32, int(14.5*32),-1));
	hangingBats5.insertLast(HangingBat(115.3*32, int(16.7*32),-1));
	hangingBats5.insertLast(HangingBat(105.5*32, int(12.2*32),-1));
	hangingBats5.insertLast(HangingBat(97.2*32, int(14.2*32),-1));
	hangingBats5.insertLast(HangingBat(122.5*32, int(21.7*32),-1));
	hangingBats5.insertLast(HangingBat(160*32, int(26.7*32),1));
}

void onLevelReload() {
	jjEnforceLighting = LIGHT::COMPLETE;
}

void onLevelBegin() {
	jjAnimSets[ANIM::BAT].load();
	if(!jjSampleIsLoaded(SOUND::ZDOG_WAF3)) {
		jjSampleLoad(SOUND::ZDOG_WAF3,"Bell.wav");
	}
	
}


uint64 timeSec() {return jjUnixTimeSec();} 

int nextBats = 4500;
int bellTimer = -1;
void onMain() {
	for (int i = 1; i < jjObjectCount; i++) {
		jjOBJ@ obj = jjObjects[i];
		if (obj.eventID == OBJECT::RFPOWERUP || obj.eventID == OBJECT::TOASTERPOWERUP) {
			obj.xPos = obj.xOrg + 16;
		}
	}
	if(jjGameTicks == nextBats) {
		nextBats += (3500 + jjRandom() % 1000);
		uint x = uint(jjRandom() % jjResolutionWidth/3.0) + uint(jjResolutionWidth/3.0);
		for(uint i = 0; i < 40; i++) {
			makeBat(x,300 + jjRandom() % 400);
		}
	}
	if(timeSec() % 3600 == 0) {
		bellTimer = 0;
	}
	if(bellTimer > -1) {
		int angle = 0;
		bellTimer++;
		if(bellTimer == 70 || bellTimer == 280 || bellTimer == 490) {
			jjSamplePriority(SOUND::ZDOG_WAF3);
		}
		
		if(bellTimer < 70) {
			angle = -bellTimer;
		} else if(bellTimer < 280) {
			angle = -70 + (bellTimer-70)*(2.0/3.0);
		} else if(bellTimer < 490) {
			angle = 70 - (bellTimer-280)*(2.0/3.0);
		} else if(bellTimer < 600) {
			angle = -70 + (bellTimer-490)*(2.0/3.0);
		} else {
			bellTimer = -1;
		}
		jjDrawRotatedSprite(74.6*70,14.3*70,ANIM::CUSTOM[0],0,0,angle,1,1,SPRITE::BRIGHTNESS,50,5);
		
	} else {
		jjDrawRotatedSprite(74.6*70,14.3*70,ANIM::CUSTOM[0],0,0,0,1,1,SPRITE::BRIGHTNESS,50,5);
	}
	/*if(jjGameTicks == 100 || jjGameTicks == 100 + 3*70 || jjGameTicks == 100 + 6*70) {//if(timeSec() % 3600 == 0) {
		jjSamplePriority(SOUND::ZDOG_WAF3);
	}*/
	/*if(timeMs() 3600000 < 8000) {
		jjDrawRotatedSprite(
	}*/
	
	//jjDrawResizedSprite(p.xPos,p.yPos,ANIM::DEVILDEVAN,5,jjGameTicks/7,5,5);
	
	if(jjRandom() % 2 == 0) {
		makeBlood(28.35*72,11.48*72);
		makeBlood(28.34*72,11.48*72);
	} else {
		makeBlood(29.46*72,11.48*72);
		makeBlood(29.47*72,11.48*72);
	}
	//if(jjRandom() % 2 == 0) {
		makeBlood(28.9*72,11.73*72);
		makeBlood(28.91*72,11.73*72);
		makeBlood(28.92*72,11.73*72);
		makeBlood(28.93*72,11.73*72);
	//}
}

void makeBlood(float xPos, float yPos) {
	jjPARTICLE@ blood = jjAddParticle(PARTICLE::ICETRAIL);
	blood.xPos = xPos;
	blood.yPos = yPos;
	blood.xSpeed = 0;
	blood.ySpeed = 1;
	blood.icetrail.color = 24;
	blood.icetrail.colorStop = 32;
}


class BloodSpear : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::BULLET, false);
		obj.var[0] = int(atan2(-obj.ySpeed, obj.xSpeed) * (512.f * 0.318309886142228f));
		
		if (obj.counter == 1 && obj.state == STATE::FLY && jjPlayers[obj.creatorID].isLocal) {
			jjSample(jjPlayers[obj.creatorID].xPos, jjPlayers[obj.creatorID].yPos, SOUND::HATTER_PTOEI, 0, obj.eventID == OBJECT::FIREBALLBULLETPU? 19000:20000);
		}
		
		if (obj.state == STATE::FLY) {
			jjDrawRotatedSprite(obj.xPos, obj.yPos, ANIM::HATTER, 3, jjGameTicks >> 2, obj.var[0], 2, 1, SPRITE::SINGLEHUE, obj.eventID == OBJECT::FIREBALLBULLETPU? 15:24);
			switch (obj.direction) {
				case 1: obj.xSpeed -= 0.1; obj.ySpeed += 0.1; break;
				case -1: obj.xSpeed += 0.1; obj.ySpeed += 0.1; break;
			}
			if (obj.xSpeed == 0) obj.ySpeed += 0.15;
			
			jjPARTICLE@ blood = jjAddParticle(PARTICLE::ICETRAIL);
			blood.xPos = obj.xPos;
			blood.yPos = obj.yPos;
			blood.icetrail.color = obj.eventID == OBJECT::FIREBALLBULLETPU? 16:24;
			blood.icetrail.colorStop = obj.eventID == OBJECT::FIREBALLBULLETPU? 24:32;
		}
		
		if (obj.state == STATE::EXPLODE) {
			jjDrawSprite(obj.xPos, obj.yPos, ANIM::MONKEY, 1, obj.curFrame, obj.direction, SPRITE::SINGLEHUE, obj.eventID == OBJECT::FIREBALLBULLETPU? 15:24);
			if (obj.var[1] < 27) {
				if (obj.var[1] == 1) jjSample(obj.xPos, obj.yPos, SOUND::HATTER_SPLOUT, 0, 20000);
				obj.var[1] = obj.var[1] + 1;
			}
			if (obj.var[1] == 27) {
				obj.var[1] = 0;
				obj.delete();
			}
		}
		
	}
}

void onPlayer(jjPLAYER@ play) {
	float MaxHealth = jjMaxHealth + 1;
	float Health = play.health + 1;
	float healthratio = MaxHealth / Health;

	if (healthratio < 1.3) jjWeapons[WEAPON::GUN8].spread = SPREAD::NORMAL;
	if (healthratio >= 1.3 && healthratio < 2) jjWeapons[WEAPON::GUN8].spread = SPREAD::RFNORMAL;
	if (healthratio >= 2) jjWeapons[WEAPON::GUN8].spread = SPREAD::RFPU;
}