Downloads containing xlmpolaris.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: PolarisFeatured Download PurpleJazz Capture the flag 8.9 Download file
TSF with JJ2+ Only: PolarisFeatured Download PurpleJazz Capture the flag 8.9 Download file

File preview

#pragma require "LaserBlaster.j2a"
#pragma require "xlmpolaris_sounds/amb_cmdd.wav"
#pragma require "xlmpolaris_sounds/amb_puls.wav"
#pragma require "xlmpolaris_sounds/f_laser1.wav"
#pragma require "xlmpolaris_sounds/f_laser2.wav"
#pragma require "xlmpolaris_sounds/f_laser3.wav"
#pragma require "xlmpolaris_sounds/f_laser4.wav"
#pragma require "xlmpolaris_sounds/fan_sm4.wav"
#pragma require "xlmpolaris_sounds/mawaters.wav"
#pragma require "xlmpolaris_sounds/mloop2.wav"
#pragma require "xlmpolaris_sounds/splash01.wav"

void onLevelLoad() {
	jjAnimSets[ANIM::CUSTOM[0]].load(0, "LaserBlaster.j2a");
	jjAnimations[jjAnimSets[ANIM::AMMO] + 29] = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + 2];
	jjAnimations[jjAnimSets[ANIM::AMMO] + 28] = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + 3];
	jjAnimations[jjAnimSets[ANIM::PICKUPS] + 62] = jjAnimations[jjAnimSets[ANIM::CUSTOM[0]] + 4];
	
	for (int i = 1; i < 255; i++) {
		if (jjObjectPresets[i].playerHandling == HANDLING::PICKUP) {
			jjObjectPresets[i].behavior = CannotBeBuried;
		}
	}
	
	jjObjectPresets[OBJECT::ICEBULLET].behavior = LaserGun;
	jjObjectPresets[OBJECT::ICEBULLET].special = jjObjectPresets[OBJECT::ICEBULLET].determineCurAnim(ANIM::CUSTOM[0], 0);
	jjObjectPresets[OBJECT::ICEBULLET].xSpeed = 1.5;
	jjObjectPresets[OBJECT::ICEBULLET].counterEnd = 125;
	jjObjectPresets[OBJECT::ICEBULLET].freeze = 0;
	jjObjectPresets[OBJECT::ICEBULLET].eventID = OBJECT::FIREBALLBULLET;
	jjObjectPresets[OBJECT::ICEBULLET].lightType = jjObjectPresets[OBJECT::FIREBALLBULLET].lightType;

	jjObjectPresets[OBJECT::ICEBULLETPU].behavior = LaserGunPU;
	jjObjectPresets[OBJECT::ICEBULLETPU].special = jjObjectPresets[OBJECT::ICEBULLET].determineCurAnim(ANIM::CUSTOM[0], 1);
	jjObjectPresets[OBJECT::ICEBULLETPU].xSpeed = 2;
	jjObjectPresets[OBJECT::ICEBULLETPU].counterEnd = 95;
	jjObjectPresets[OBJECT::ICEBULLETPU].var[6] = 8;
	jjObjectPresets[OBJECT::ICEBULLETPU].freeze = 0;
	jjObjectPresets[OBJECT::ICEBULLETPU].eventID = OBJECT::FIREBALLBULLETPU;
	jjObjectPresets[OBJECT::ICEBULLET].lightType = jjObjectPresets[OBJECT::FIREBALLBULLET].lightType;
	
	jjObjectPresets[OBJECT::ICEPOWERUP].determineCurAnim(ANIM::CUSTOM[0], 4, true);
	jjObjectPresets[OBJECT::ICEPOWERUP].determineCurFrame();
	
	jjWeapons[WEAPON::ICE].spread = SPREAD::NORMAL;
	
	jjSampleLoad(SOUND::P2_POEP, "xlmpolaris_sounds/amb_cmdd.wav");
	jjSampleLoad(SOUND::SCIENCE_PLOPKAOS, "xlmpolaris_sounds/amb_puls.wav");
	jjSampleLoad(SOUND::WIND_WIND2A, "xlmpolaris_sounds/fan_sm4.wav");
	jjSampleLoad(SOUND::COMMON_COLLAPS, "xlmpolaris_sounds/mawaters.wav");
	jjSampleLoad(SOUND::COMMON_DRINKSPAZZ3, "xlmpolaris_sounds/mloop2.wav");
	jjSampleLoad(SOUND::COMMON_WATER, "xlmpolaris_sounds/splash01.wav");
	jjSampleLoad(SOUND::AMMO_ICEGUN, "xlmpolaris_sounds/f_laser1.wav");
	jjSampleLoad(SOUND::AMMO_ICEGUN2, "xlmpolaris_sounds/f_laser2.wav");
	jjSampleLoad(SOUND::AMMO_ICEGUNPU, "xlmpolaris_sounds/f_laser2.wav");
	jjSampleLoad(SOUND::AMMO_ICEPU1, "xlmpolaris_sounds/f_laser3.wav");
	jjSampleLoad(SOUND::AMMO_ICEPU2, "xlmpolaris_sounds/f_laser3.wav");
	jjSampleLoad(SOUND::AMMO_ICEPU3, "xlmpolaris_sounds/f_laser4.wav");
	jjSampleLoad(SOUND::AMMO_ICEPU4, "xlmpolaris_sounds/f_laser4.wav");
	
	jjANIMATION@ anim = jjAnimations[jjAnimSets[ANIM::AMMO] + 82];
	for (uint i = 0; i < anim.frameCount; ++i) {
		jjANIMFRAME@ frame = jjAnimFrames[anim + i];
		jjPIXELMAP sprite(frame);
		for (uint x = 0; x < sprite.width; ++x)
			for (uint y = 0; y < sprite.height; ++y)
			if (sprite[x,y] != 0 && sprite[x,y] != 15) sprite[x,y] += 33;
		sprite.save(frame);
	}
	
	jjPIXELMAP VFlippedSign(634);
	VFlippedSign.save(634 | TILE::VFLIPPED, true);
}

void CannotBeBuried(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::PICKUP);
	if (jjMaskedPixel(int(obj.xPos), int(obj.yPos) + 8)) {
		obj.state = STATE::FLOAT;
	}
	if (obj.eventID == OBJECT::CARROT) {
		obj.xPos = obj.xOrg - 16;
		if (obj.state == STATE::FLOATFALL) obj.state = STATE::FLOAT; //can't be shot down
	}
	else if (obj.eventID == OBJECT::FLYCARROT) {
		if (jjLocalPlayers[0].fly == FLIGHT::FLYCARROT) obj.playerHandling = HANDLING::PARTICLE;
		else obj.playerHandling = HANDLING::PICKUP;
	}
	if (obj.ySpeed < 0) obj.ySpeed = 0.25;
}

void LaserGun(jjOBJ@ obj) {
	jjPLAYER@ creator = jjPlayers[obj.creatorID];
	if (obj.state == STATE::START) {
		obj.state = STATE::FLY;
		obj.direction = creator.direction;
	}
	if (jjMaskedPixel(int(obj.xPos + obj.xSpeed + obj.var[7] / 65536.f), int(obj.yPos))) {
		obj.xSpeed = -obj.xSpeed;
		obj.var[7] = -obj.var[7];
		obj.xAcc = -obj.xAcc;
		obj.ySpeed -= 1.5;
		obj.counter -= 5;
		if (obj.state == STATE::FLY) randomSample(obj);
	}
	else if (jjMaskedPixel(int(obj.xPos), int(obj.yPos + obj.ySpeed))) {
		obj.ySpeed = -obj.ySpeed;
		obj.yAcc = -obj.yAcc;
		obj.xSpeed -= obj.direction == 1? -1.5:1.5;
		obj.counter -= 5;
		if (obj.state == STATE::FLY) randomSample(obj);
	}
	obj.var[0] = int(atan2(-obj.ySpeed, obj.xSpeed) * (512.f * 0.318309886142228f));
	if (obj.state == STATE::FLY) jjDrawRotatedSprite(obj.xPos, obj.yPos, ANIM::CUSTOM[0], 1, 0, obj.var[0], 0.9, 0.9, SPRITE::NORMAL);
	obj.behave(BEHAVIOR::BULLET, obj.state == STATE::FLY? false:true);
}

void LaserGunPU(jjOBJ@ obj) {
	jjPLAYER@ creator = jjPlayers[obj.creatorID];
	if (obj.state == STATE::START) {
		obj.state = STATE::FLY;
		obj.direction = creator.direction;
	}
	if (jjMaskedPixel(int(obj.xPos + obj.xSpeed + obj.var[7] / 65536.f), int(obj.yPos))) {
		obj.xSpeed = -obj.xSpeed;
		obj.var[7] = -obj.var[7];
		obj.xAcc = -obj.xAcc;
		obj.ySpeed -= 3;
		obj.counter -= 5;
		if (obj.state == STATE::FLY) randomSample(obj);
	}
	else if (jjMaskedPixel(int(obj.xPos), int(obj.yPos + obj.ySpeed))) {
		obj.ySpeed = -obj.ySpeed;
		obj.yAcc = -obj.yAcc;
		obj.xSpeed -= obj.direction == 1? -3:3;
		obj.counter -= 5;
		if (obj.state == STATE::FLY) randomSample(obj);
	}
	obj.var[0] = int(atan2(-obj.ySpeed, obj.xSpeed) * (512.f * 0.318309886142228f));
	
	if (obj.state == STATE::FLY) jjDrawRotatedSprite(obj.xPos, obj.yPos, ANIM::CUSTOM[0], 0, 0, obj.var[0], 1, 1, SPRITE::NORMAL);
	obj.behave(BEHAVIOR::BULLET, obj.state == STATE::FLY? false:true);
}

void randomSample(jjOBJ@ obj) {
	switch(jjRandom()%4) {
		case 0: jjSample(obj.xPos, obj.yPos, SOUND::AMMO_BUL1, 0, 0); break;
		case 1: jjSample(obj.xPos, obj.yPos, SOUND::AMMO_BULFL1, 0, 0); break;
		case 2: jjSample(obj.xPos, obj.yPos, SOUND::AMMO_BULFL2, 0, 0); break;
		case 3: jjSample(obj.xPos, obj.yPos, SOUND::AMMO_BULFL3, 0, 0); break;
	}
}

void onPlayer(jjPLAYER@ play) {
	if (play.fly == FLIGHT::FLYCARROT && play.timerState == TIMER::STOPPED) play.timerStart(7*70);
	if (play.fly == FLIGHT::NONE) play.timerStop();
  	if (play.timerState == TIMER::STARTED && play.timerTime <= 3*70 && play.timerTime > 0 && play.timerTime % 70 == 0) jjSamplePriority(SOUND::COMMON_NOCOIN);
	if (play.timerTime == 0) play.fly = FLIGHT::NONE;
	
	if (jjGameState == GAME::PAUSED) play.timerPause();
	else play.timerResume();
	
	play.lighting = 80;
	
	if (!jjLowDetail) {
		if (jjGameTicks % 410 == 0 || jjGameTicks == 1) jjSample(jjLocalPlayers[0].xPos, jjLocalPlayers[0].yPos, SOUND::P2_POEP, (jjMusicActive && jjMusicVolume > 0)? 16:48, 0);
	}
}

void onPlayerTimerEnd(jjPLAYER@ play) { play.fly = FLIGHT::NONE; }

bool onDrawPlayerTimer(jjPLAYER@ play, jjCANVAS@ canvas) {
	if (play.fly == FLIGHT::FLYCARROT) {
      		canvas.drawString(
			jjSubscreenWidth - 55,
	      		jjSubscreenHeight - 284,
	      		"" + (play.timerTime + 70) / 70,
	      		STRING::LARGE,
	      		STRING::PALSHIFT,
	      		play.timerTime > 3*70?
	      			0 :
	      			jjGameTicks % 28 > 14?
	      				-40 :
	      				-24
		);
		
		canvas.drawSprite(
			jjSubscreenWidth - 72,
			jjSubscreenHeight - 270,
			ANIM::PICKUPS,
			40, 
			jjGameTicks >> 2
		);
	}
	return true;
}

void onFunction0(jjPLAYER@ play) {
	play.showText("@@@@@Polaris@Created by PurpleJazz of XLM (2007-2017)@Tileset by cooba, edited by PurpleJazz@Space background texture by Vurt@Ambient sound effects by Eric Brosius@np: Michiel van den Bos - Far Under [4:14]");
}

void onFunction1(jjPLAYER@ play) {
	play.showText("@@@@Spawn Times@Ammo: 15@+1 Carrots: 20@Full NRG: 25@Bouncer/Laser Powerups: 25@RF Powerup: 30");
}