Downloads containing BossrushV9.j2as

Downloads
Name Author Game Mode Rating
JJ2 1.23 vanilla: Miscellaneous stuff Violet CLM Multiple N/A Download file

File preview

const int FOODOFFSET = -20;
const int FOODSHIELD = 75;

void onPlayer(jjPLAYER@ play) {
	play.cameraFreeze(0, 0, false, true);
	if (play.yPos < 32)
		play.yPos = 32;
	else if (play.yPos > 14*32)
		play.yPos = 14*32;
	
	if (play.keyUp)
		play.ySpeed = -8;
	else if (play.keyDown || play.fly == 0)
		play.ySpeed = 8;
	else
		play.ySpeed = 0;
	if (play.fly == FLIGHT::NONE)
		play.xSpeed = 0; //fall onto that airboard
	else if (play.keyLeft)
		play.xSpeed = -4;
	else if (play.keyRight)
		play.xSpeed = 4;
	else
		play.xSpeed = 0;
	
	if (!play.keyRun) {
		play.xSpeed /= 2; play.ySpeed /= 2;
	}
	
	if (jjGameTicks % 70 == 69)
		++play.food;
	
	jjDrawRotatedSprite(play.xPos, play.yPos, ANIM::AMMO, 5, 5 + ((jjGameTicks >> 1) & 3), jjRenderFrame << 5, 3, 3, SPRITE::PALSHIFT, 6*8);
	jjDrawRotatedSprite(play.xPos, play.yPos, ANIM::AMMO, 5, 8 - ((jjGameTicks >> 1) & 3), -(jjRenderFrame << 5), 2, 2, SPRITE::PALSHIFT, 6*8);
	jjPARTICLE@ part = jjAddParticle(PARTICLE::SPARK);
	if (part !is null) {
		part.xPos = play.xPos;
		part.yPos = play.yPos;
		part.xSpeed = (jjRandom() & 15) - 7.5;
		part.ySpeed = (jjRandom() & 15) - 7.5;
		part.spark.color += 4*8;
		part.spark.colorStop += 4*8;
	}
}

void onMain() {
	for (int i = jjObjectCount - 1; i >= 0; --i) {
		jjOBJ@ obj = jjObjects[i];
		if (obj.deactivates) {
			obj.xPos -= 1;
			obj.xOrg -= 1;
		}
		if (i < 1024) {
			jjPARTICLE@ part = jjParticles[i];
			part.xPos -= 1;
		}
	}
}

jjTEXTAPPEARANCE ShieldInstruction(STRING::NORMAL);

void onLevelLoad() {
	jjTexturedBGTexture = TEXTURE::MEDIVO;
	jjTexturedBGUsed = true;
	
	jjOBJ@ preset = jjObjectPresets[OBJECT::MILK];
	preset.behavior = Potion;
	//preset.deactivates = false; //immune to auto speed
	preset.curFrame = jjAnimations[jjAnimSets[ANIM::PICKUPS].firstAnim + 78].firstFrame;
	preset.lightType = LIGHT::LASER;
	preset.light = -10;
	preset.points = 0;
	
	@preset = jjObjectPresets[OBJECT::BLASTERBULLET];
	preset.counterEnd = 125;
	preset.determineCurAnim(ANIM::AMMO, 74);
	preset.eventID = OBJECT::FIRESHIELDBULLET; //make sparks!
	
	@preset = jjObjectPresets[OBJECT::BOLLY];
	preset.behavior = BollyBoss;
	preset.direction = -1;
	if (jjAnimSets[ANIM::FLARE].firstAnim == 0)
		jjAnimSets[ANIM::FLARE].load();
	preset.curFrame = jjAnimations[jjAnimSets[ANIM::FLARE]] + 3;
	preset.deactivates = false;
	
	jjWeapons[WEAPON::BLASTER].style = WEAPON::CAPPED;
	
	ShieldInstruction.align = STRING::CENTER;
	ShieldInstruction.section = STRING::SPECIALSIGN;
	ShieldInstruction.yAmp = 1;
	
	for (uint i = 0; i < 4; ++i) {
		jjANIMFRAME@ frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::AMMO] + 5] + 5 + i];
		frame.hotSpotX -= 3;
		frame.hotSpotY += 3;
	}
	
	for (uint i = 0; i < 6; ++i) {
		jjANIMFRAME@ frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::SONCSHIP] + 3] + i];
		jjPIXELMAP imageOld(frame);
		jjPIXELMAP imageNew(frame.width * 2, frame.height * 4);
		const uint yReverse = uint(imageNew.height*1.5);
		for (uint x = 0; x < imageNew.width; ++x)
			for (uint y = 0; y < imageNew.height; ++y) {
				uint8 oldColor = imageOld[x>>1, y>>1];
				if ((oldColor & 7) != 0 && (jjRandom()&1) != 0) --oldColor; //add some graininess to pretend it's not just 2x2 resized
				imageNew[imageNew.width - x - 1, y < imageOld.height*2 ? y : yReverse - y - 1] = oldColor;
			}
		imageNew.save(frame);
		frame.hotSpotX = -32;
		frame.hotSpotY = -frame.height / 2;
	}
}

void onLevelReload() {
	for (int i = 0; i < jjLocalPlayerCount; ++i) {
		jjPLAYER@ play = jjLocalPlayers[i];
		play.food = FOODOFFSET;
		play.fastfire = 10;
	}
}
void onLevelBegin() {
	onLevelReload();
}

class TrailPosition{
	float xPos, yPos;
	int angle;
	TrailPosition(){}
	TrailPosition(float x, float y, int a) { xPos = x; yPos = y; angle = a; }
}
array<array<TrailPosition>> TrailPositions(jjObjectMax, array<TrailPosition>(0));
const float POTIONSPEED = 0.1;
void Potion(jjOBJ@ obj) {
	if (obj.state == STATE::START) {
		obj.state = STATE::FLY;
		obj.age = jjRandom() & 1023;
		obj.xAcc = (jjRandom() & 15) - 7.5;
		obj.yAcc = (jjRandom() & 15) - 7.5;
	}
	jjPLAYER@ target = jjLocalPlayers[0];
	float dX = target.xPos - obj.xPos;
	float dY = target.yPos - obj.yPos;
	if (abs(dX) > abs(dY)) {
		if (dX > 0) obj.xAcc = POTIONSPEED;
		else obj.xAcc = -POTIONSPEED;
		obj.yAcc = (abs(dY) / abs(dX)) * POTIONSPEED;
		if (dY < 0) obj.yAcc = -obj.yAcc;
	} else {
		if (dY > 0) obj.yAcc = POTIONSPEED;
		else obj.yAcc = -POTIONSPEED;
		obj.xAcc = (abs(dX) / abs(dY)) * POTIONSPEED;
		if (dX < 0) obj.xAcc = -obj.xAcc;
	}
	obj.xSpeed += obj.xAcc;
	if (abs(obj.xSpeed) > 4) obj.xSpeed *= 0.8;
	obj.ySpeed += obj.yAcc;
	if (abs(obj.ySpeed) > 4) obj.ySpeed *= 0.8;
	
	obj.xPos += obj.xSpeed;
	obj.yPos += obj.ySpeed;
	obj.age += 16;
	
	array<TrailPosition>@ positions = @TrailPositions[obj.objectID];
	
	if (jjGameTicks & 1 == 0) {
		if (positions.length > 10) positions.removeAt(0);
		positions.insertLast(TrailPosition(obj.xPos, obj.yPos, obj.age));
	}
	for (uint i = 0; i < positions.length; ++i) {
		TrailPosition@ trail = @positions[i];
		jjDrawRotatedSpriteFromCurFrame(trail.xPos, trail.yPos, obj.curFrame, trail.angle, 1, 1, SPRITE::BLEND_NORMAL, i << 4);
	}
}

bool onDrawAmmo(jjPLAYER@ play, jjCANVAS@ screen) {
	const int scaleUnit = (jjSubscreenWidth > 400) ? 3 : 1;
	for (int i = FOODOFFSET; i < 100 + FOODOFFSET; ++i)
		screen.drawSprite(jjSubscreenWidth - 16, jjSubscreenHeight - 16 - ((i-FOODOFFSET)*scaleUnit), ANIM::AMMO, 20, 1, -1, SPRITE::PALSHIFT, i >= play.food ? 0 : + (((jjRandom() & 3) > 0) ? 24 : -16));
	screen.drawRectangle(jjSubscreenWidth, jjSubscreenHeight - 16 - FOODSHIELD*scaleUnit, -36, 2, 90);
	if (play.food - FOODOFFSET > FOODSHIELD)
		screen.drawString(jjSubscreenWidth/2, jjSubscreenHeight - 16, "Select: SHIELD", STRING::MEDIUM, ShieldInstruction, 1, SPRITE::PALSHIFT, 3*8);
	return true;
}
bool onDrawScore(jjPLAYER@ play, jjCANVAS@ screen) { return true; }

void BollyBoss(jjOBJ@ obj) {
	jjDrawRotatedSprite(obj.xPos, obj.yPos, ANIM::SONCSHIP, 3, jjGameTicks >> 3, jjSin(jjGameTicks << 2) * 10);
	//obj.draw();
}