Downloads containing agdlj.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Anniversary Bash 17 Levels Jazz2Online Multiple N/A Download file
JJ2+ Only: A Giant Drifting Log's...Featured Download FireSworD Capture the flag 8.6 Download file
JJ2+ Only: A Giant Drifting Log's...Featured Download FireSworD Capture the flag 8.6 Download file

File preview

class lightLayerData {
	float speed;
	uint distance, size;
	lightLayerData() {
		speed = size = 0;
		distance = ~0;
	}
	lightLayerData(float x, uint d, uint s) {
		speed = x;
		distance = d;
		size = s;
	}
}
const array<lightLayerData> lightLayer = {
	lightLayerData(0.10f, 750, 4),
	lightLayerData(0.15f, 310, 4),
	lightLayerData(0.20f, 400, 5),
	lightLayerData(0.25f, 820, 5),
	lightLayerData(0.30f, 560, 5),
	lightLayerData(0.40f, 690, 6),
	lightLayerData(0.50f, 960, 6)
};
const array<string> deathMessage = {
	"ate it? Quite the opposite",
	"would taste better with ketchup",
	"got eaten",
        "didn't see getting eaten? Beast lag!"
};
const int maxBoxTime = 20 * 70;
const int maxShieldTime = 10 * 70;
void beast(jjOBJ@ obj) {
	if (jjGameTicks % obj.animSpeed == 0) {
		if (++obj.frameID > 10) {
			switch (obj.special) {
				case 9:
					obj.xPos = obj.xOrg;
					obj.yPos = obj.yOrg;
					obj.animSpeed = 7;
				case 0:
					obj.special = 5;
					break;
				case 5:
					switch (jjRandom() & 3) {
						case 0:
							obj.special = 0;
							break;
						case 1:
							obj.special = 9;
							obj.direction *= -1;
							obj.xPos = obj.xOrg - 19 * obj.direction;
							obj.yPos = obj.yOrg - 9;
							obj.animSpeed = 4;
							break;
						case 2:
							obj.animSpeed = 6;
							break;
						case 3:
							obj.animSpeed = 7;
							break;
					}
					break;
			}
			obj.frameID = 0;
			obj.determineCurAnim(ANIM::DEVILDEVAN, obj.special);
		}
		obj.determineCurFrame();
	}
	obj.draw();
}
void cantBeBuried(jjOBJ@ obj) {
  obj.behave(BEHAVIOR::PICKUP);
  if (jjMaskedPixel(obj.xPos, obj.yPos + 8)) {
    obj.state = STATE::FLOAT;
  }
}
void deathMessageObject(jjOBJ@ obj) {
	if (obj.creatorType == CREATOR::PLAYER) {
		jjPLAYER@ player = jjPlayers[obj.creatorID];
		if (player.isActive)
			jjAlert(player.name + " " + deathMessage[jjRandom() % deathMessage.length()]);
	}
	obj.delete();
}
void komorebi(jjOBJ@ obj) {
	if (obj.counter++ != 0)
		obj.delete();
}
void drawKomorebi(const jjPLAYER@ player, float x, uint size) {
	const float left = player.cameraX - 16;
	const float top = player.cameraY - 16;
	const float right = player.cameraX + jjSubscreenWidth + 16;
	const float bottom = player.cameraY + jjSubscreenHeight + 16;
	const float y = player.cameraY - 4;
	x += player.cameraX;
	if (size > 8)
		size = 8;
	uint length = (1 << size) - 1;
	for (uint i = 0; i < length; i++) {
		if (jjRandom() & length > i) {
			float xPos = x - i;
			float yPos = y + i * 5;
			if (xPos >= left && yPos >= top && xPos < right && yPos < bottom)
				jjAddObject(OBJECT::PULZELIGHT, xPos, yPos);
		}
	}
}
bool isPointInBox(float x, float y) {
	return x >= 52 << 5 && y >= 13 << 5 && x < 61 << 5 && y < 21 << 5;
}
void onLevelLoad() {
	jjOBJ@ preset;
	@preset = jjObjectPresets[OBJECT::DEVILDEVAN];
	preset.behavior = beast;
	preset.bulletHandling = HANDLING::IGNOREBULLET;
	preset.playerHandling = HANDLING::PARTICLE;
	preset.special = 5;
	preset.animSpeed = 7;
	preset.direction = 1;
	preset.frameID = 0;
	preset.determineCurAnim(ANIM::DEVILDEVAN, preset.special);
	preset.determineCurFrame();
	@preset = jjObjectPresets[OBJECT::TNT];
	preset.behavior = deathMessageObject;
	@preset = jjObjectPresets[OBJECT::PULZELIGHT];
	preset.behavior = komorebi;
	preset.lightType = LIGHT::POINT;
	for (int i = 0; i < 256; i++) {
		@preset = jjObjectPresets[i];
		if (preset.behavior == BEHAVIOR::PICKUP)
			preset.behavior = cantBeBuried;
	}
}
void onMain() {
	if (jjLocalPlayerCount == 1) {
		const jjPLAYER@ player = jjLocalPlayers[0];
		for (uint i = 0; i < lightLayer.length(); i++) {
			const lightLayerData@ layer = lightLayer[i];
			uint instances = jjSubscreenWidth / layer.distance + 2;
			float x = layer.distance * 3.5f % jjSubscreenWidth - player.cameraX * layer.speed % layer.distance;
			for (uint j = 0; j < instances; j++) {
				drawKomorebi(player, x + j * layer.distance, layer.size);
			}
		}
	}
}
void onPlayer(jjPLAYER@ player) {
	player.ammo[WEAPON::TNT] = 0;
	if (player.shieldTime > maxShieldTime)
		player.shieldTime = maxShieldTime;
	if (isPointInBox(player.xPos, player.yPos) && player.health > 0) {
		if (jjEventGet(uint(player.xPos) >> 5, uint(player.yPos) >> 5) == AREA::WARP) {
			if (player.timerState != TIMER::PAUSED)
				player.timerPause();
		} else {
			if (player.timerState == TIMER::STOPPED)
				player.timerStart(maxBoxTime);
			else if (player.timerState == TIMER::PAUSED)
				player.timerResume();
		}
	} else {
		if (player.timerState != TIMER::STOPPED)
			player.timerStop();
	}
	if (jjEventGet(uint(player.xPos) >> 5, uint(player.yPos) >> 5) == AREA::PATH) {
		player.ballTime = 30;
		int direction = (player.flag == 0 || jjObjects[player.flag].state == STATE::SLEEP) ^^ player.teamRed ? -1 : 1;
		player.xSpeed = jjParameterGet(uint(player.xPos) >> 5, uint(player.yPos) >> 5, 0, 6) * direction;
		player.ySpeed = 0;
	}
}
void onPlayerTimerEnd(jjPLAYER@ player) {
	player.fireBullet(WEAPON::TNT, false, false);
	player.health = 0;
	if (jjIsServer)
		player.kill();
}