Downloads containing saldr.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Devan's Revenge (Intro)Featured Download sAlAmAnDeR Single player 9.6 Download file

File preview

#include "SaLLiB-v2.0.asc"

void blackbg() {
	for(uint i = 0; i < 8; i++)
		for(uint j = 0; j < 8; j++) 
			jjTileSet(8,i,j,242);
}

void normalbg() {
	for(uint i = 0; i < 8; i++) 
		for(uint j = 0; j < 8; j++) 
			jjTileSet(8,i,j,821+10*j+i);
}

void dark(bool layer1 = true) {
	blackbg();
	for(uint i = 1; i < 8; i++) {
		jjLayerHasTiles[i] = false;
	}
	jjLayerHasTiles[8] = true;
	if(layer1)
		jjLayerHasTiles[1] = true;
}

void warp() {
	normalbg();
	jjLayerYAutoSpeed[8] = -2;
	jjPalette.gradient(0,0,0,160,0,200);
	jjPalette.apply();
	jjTexturedBGStyle = TEXTURE::TUNNEL;
	jjTexturedBGUsed = true;
	for(uint i = 0; i < 7; i++)
		jjLayerHasTiles[i] = false;
	jjLayerHasTiles[8] = true;
}

void hell() {
	normalbg();
	for(uint i = 0; i < 8; i++) {
		jjLayerHasTiles[i] = true;
	}
}

class Particle {
  private float xPos, yPos, xSpeed, ySpeed;
  private uint size, counter;
  
  Particle(float xPos, float yPos, float xSpeed, float ySpeed, uint size) {
	this.counter = 0;
    this.size = size + jjRandom() % 5;
    this.xPos = xPos - size / 2;
    this.yPos = yPos - size / 2;
    this.xSpeed = xSpeed - 0.5f + jjRandom() % 100 / 100.f;
    this.ySpeed = ySpeed - 1.f + jjRandom() % 200 / 100.f;
  }
  
  void behavior() {
    counter++;
    xPos += xSpeed;
    yPos += ySpeed;
    if (counter > 120)
      size /= 2;
	uint color = 40 + (counter / 15);
    if (color > 47)
      color = 47;
    jjDrawRectangle(xPos, yPos, size, size, color, SPRITE::TRANSLUCENT,0,2);
  }
  
  bool exists() const {
    return size > 1;
  }
}

class SpookyString : GAME::String {
	private float xOsc, yOsc, xInit, yInit;
	
	SpookyString(float xPos, float yPos, string text, STRING::Size stringSize = STRING::MEDIUM, STRING::Mode stringMode = STRING::NORMAL, SPRITE::Mode spriteMode = SPRITE::NORMAL, int param = 0, float xOscillate = 32, float yOscillate = 32) {
		super(xPos, yPos, text, stringSize, stringMode, spriteMode, param);
		this.xOsc = xOscillate;
		this.yOsc = yOscillate;
		this.xInit = xPos;
		this.yInit = yPos;
	}

	void behavior() {
		if(jjRandom() % 70 > 55) {
			float xRand = (jjRandom() % (xOsc*2)) - xOsc;
			float yRand = (jjRandom() % (yOsc*2)) - yOsc;
			xPos = xInit+xRand;
			yPos = yInit+yRand;
		}
		if(jjRandom() % 70 > 2) {
			draw();
		}
	}
}

string text1 = "For 16 years I`ve waited";
string text2 = "They thought I was beaten";

int xCenter = (20*32)/2;
int yCenter = (15*32)/2;

int warpDuration = 500;

array<int> lightning = {40,80,90,100,140,150,200,250};

GAME::Camera@ camera;
array<CUSTOM::Object@> scene;
array<Particle@> particles;
SPRITE::Mode mode = SPRITE::NORMAL;
int param = 0;

void updateParticles() {
	for(uint i = 0; i < particles.length; i++) {
		particles[i].behavior();
		if(!particles[i].exists())
			particles.removeAt(i--);
	}
}

void clearObjects(array<CUSTOM::Object@> objects) {
	for(int i = objects.length()-1; i >= 0; i--) {
		if(objects[i].isActive) objects[i].delete();
		objects.removeAt(i);
	}
}

void onLevelBegin() {
	if(jjIsServer) jjChat("/allowmouseaim off");
	jjChat("/mouseaim off");
	if(jjGameMode != GAME::COOP && jjGameMode != GAME::SP) {
		jjChat("/gamemode coop");
		jjChat("/r");
		return;
	}

	@camera = @GAME::Camera(jjLocalPlayers[0]);
	CUSTOM::UI.drawAmmo = false;
	CUSTOM::UI.drawLives = false;
	CUSTOM::UI.drawScore = false;
	CUSTOM::UI.drawHealth = false;
	CUSTOM::UI.drawPlayerTimer = false;
	jjLocalPlayers[0].xPos = -32;
	jjLocalPlayers[0].yPos = -32;
	jjLocalPlayers[0].xSpeed = -1;
	jjLocalPlayers[0].ySpeed = -1;
	jjLocalPlayers[0].spriteMode = SPRITE::Mode::INVISIBLE;//10;
	dark();
}

void onMain() {
	p.ballTime = 1;
	int ticks = jjGameTicks;// + 3000; // + 2119; //+ 1349; //Add ticks for testing
	if(ticks < 280) { 
		//Do Nothing
	} else if(ticks == 280) {
		jjMusicLoad("scary1.mp3");
		SpookyString s1(xCenter/2,     yCenter,     text1,STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0);
		s1.moveLinear(-10*32,yCenter,xCenter/2,yCenter,210);
		SpookyString s2(xCenter/2-4*32,yCenter,     text1,STRING::LARGE, STRING::NORMAL,SPRITE::NEONGLOW,0);
		SpookyString s3(xCenter/2,     yCenter+5*32,text1,STRING::SMALL, STRING::NORMAL,SPRITE::NEONGLOW,0);
		SpookyString s4(xCenter/2,     yCenter-5*32,text1,STRING::SMALL, STRING::NORMAL,SPRITE::NEONGLOW,0);
		SpookyString s5(xCenter/2,     yCenter,     text1,STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0);
		scene.insertLast(s1);
		scene.insertLast(s2);
		scene.insertLast(s3);
		scene.insertLast(s4);
		scene.insertLast(s5);
	} else if(ticks < 490) {
		//Do Nothing
	} else if(ticks == 490) {
		jjMusicStop();
		clearObjects(scene);
	} else if(ticks < 630) {
		//Do Nothing
	} else if(ticks == 630) {
		jjMusicPlay();
		scene.insertLast(SpookyString(xCenter/2,     yCenter,     text2,  STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0));
		scene.insertLast(SpookyString(xCenter/2-4*32,yCenter-5*32,text2,  STRING::LARGE, STRING::NORMAL,SPRITE::NEONGLOW,0));
		scene.insertLast(SpookyString(xCenter/2,     yCenter,	  text2,STRING::SMALL, STRING::NORMAL,SPRITE::NEONGLOW,0));
		scene.insertLast(SpookyString(xCenter/2,     yCenter-5*32,text2,  STRING::SMALL, STRING::NORMAL,SPRITE::NEONGLOW,0));
		scene.insertLast(SpookyString(xCenter/2,     yCenter,     text2,  STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0));
		scene.insertLast(SpookyString(xCenter/2-4*32,yCenter+5*32,text2, STRING::LARGE, STRING::NORMAL,SPRITE::NEONGLOW,0));
		scene.insertLast(SpookyString(xCenter/2-4*32,yCenter+3*32,text2, STRING::MEDIUM, STRING::NORMAL,SPRITE::NEONGLOW,0));
	} else if(ticks > 630 && ticks < 840) {
		//Do Nothing
	} else if(ticks == 840) { 
		jjMusicStop();
		clearObjects(scene);
	} else if(ticks < 990) {
		jjDrawResizedSprite(xCenter/2+32,yCenter,ANIM::DEVILDEVAN,9,5,8,8,SPRITE::NEONGLOW,0);
	} else if(ticks >= 990 && ticks < 1350) {
		jjMusicPlay();
		if(ticks == 990) 	  {scene.insertLast(SpookyString(xCenter/2,	 yCenter-5*32, "They", STRING::SMALL, STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 1060) scene.insertLast(SpookyString(xCenter/2,	 yCenter,      "were", STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0));
		else if(ticks == 1130) scene.insertLast(SpookyString(xCenter/2,	 yCenter+5*32, "WRONG",STRING::LARGE, STRING::NORMAL,SPRITE::NEONGLOW,0));
		else if(ticks > 1200) {
			for(uint i = 0; i < 2; i++)
				scene.insertLast(SpookyString(jjRandom() % 20*32,jjRandom() % 15*32,"WRONG",STRING::LARGE,STRING::NORMAL,SPRITE::NEONGLOW,0));
		}
	} else if(ticks == 1350) {
		clearObjects(scene);
		jjMusicLoad("storm.xm");
	} else if(ticks < 1500) {
		float frame = 1400 - ticks;
		float yOff  = frame/80 * 40*32;
		if(ticks - 1350 > 40) { hell(); }
		if(yOff > 0)
			for(uint i = 0; i < 40; i++)
				particles.insertLast(Particle(i*16,yOff-6*32-5,0,-3.1,28));
		jjDrawResizedSprite(xCenter/2+32,int(yOff),ANIM::DEVILDEVAN,9,5,10,10,SPRITE::NORMAL,0,1);
	} else if(ticks == 1500) {
		//p.cameraFreeze(xCenter,yCenter,true,true);
		camera.moveLinear(xCenter,yCenter,xCenter,yCenter+85*32,650);
	} else if(ticks < 2150) {
		//Do Nothing
	} else if(ticks == 2150) {
		dark(false);
		p.cameraFreeze(0,0,false,true);
		jjMusicLoad("scary1.mp3");
	} else if(ticks < 2870) {
		if(ticks == 2190) 	   {scene.insertLast(SpookyString(xCenter/2,	  yCenter-5*32,   "Did",    STRING::SMALL, STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 2250) {scene.insertLast(SpookyString(xCenter/2-3*32,yCenter,        "they",   STRING::SMALL,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 2300) {scene.insertLast(SpookyString(xCenter/2,	  yCenter+5*32,   "really", STRING::SMALL,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 2350) {scene.insertLast(SpookyString(xCenter/2+8*32,yCenter,        "THINK",  STRING::SMALL,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 2400) {scene.insertLast(SpookyString(xCenter/2+1*32,yCenter+3*32,   "it",     STRING::SMALL,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 2450) {scene.insertLast(SpookyString(xCenter/2+8*32,yCenter+4*32,   "would",  STRING::SMALL,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 2500) {scene.insertLast(SpookyString(xCenter/2+4*32,yCenter+5*32,   "BE",     STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 2650) {scene.insertLast(SpookyString(xCenter/2+5*32,yCenter-4*32,   "SO",     STRING::LARGE,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks > 2800 && ticks % 4 == 0) {scene.insertLast(SpookyString(xCenter/2,     yCenter,        "EASY",   STRING::LARGE,STRING::NORMAL,SPRITE::NEONGLOW,0));}
	} else if(ticks == 2870) {
		clearObjects(scene);
	} else if(ticks < 3300) {
		if(ticks == 3000) 	   {scene.insertLast(SpookyString(xCenter/2,     yCenter+5*32, "I",    		 STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 3050) {scene.insertLast(SpookyString(xCenter/2+4*32,yCenter+3*32, "had",    		 STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks == 3100) {scene.insertLast(SpookyString(xCenter/2+4*32,yCenter,      "a",  			 STRING::MEDIUM,STRING::NORMAL,SPRITE::NEONGLOW,0));}
		else if(ticks > 3200 && ticks % 4 == 0) {scene.insertLast(SpookyString(xCenter/2-3*32,yCenter-2*32, "TIME MACHINE",  STRING::LARGE, STRING::BOUNCE,SPRITE::NEONGLOW,0));}
	} else if(ticks == 3300) {
		clearObjects(scene);
		warp();
		CUSTOM::Palette().shiftHueLinear(jjBackupPalette,0,255,500,88,255,true);
		jjMusicStop();
	} else if(ticks < 3300+warpDuration) {
		int frame = warpDuration-ticks+3300;
		int radius = 32*15*frame/warpDuration;
		float angle = 3*2*PI*frame/warpDuration;
		int xPos = int(radius*sin(angle)+(20*32)/2);
		int yPos = int(radius*cos(angle)+(15*32)/2);
		float size = 8*float(frame)/warpDuration;
		
		if(lightning.find(frame) > 0) { mode = SPRITE::SINGLECOLOR; param = 255; }
		else if(lightning.find(frame+5) > 0) { mode = SPRITE::NORMAL; param = 0; }
		
		jjDrawResizedSprite(xPos,yPos,ANIM::DEVAN,4,jjGameTicks/7,size,size,mode,param);
	} else if(ticks == 3300+warpDuration) {
		GAME::String(2*32,-5*32,"DEVAN`S   REVENGE",STRING::LARGE).moveLinear(2*32,7*32,210);
	} else if(ticks == 3300+warpDuration+210+140) {
		jjNxt("saldr2",false,true);
	}
	
	updateParticles();
	if(ticks > 3300) {
		jjTexturedBGFadePositionX = ((jjSin(jjGameTicks << 1) / 2)*0.2 + .5);
		jjTexturedBGFadePositionY = ((jjCos(jjGameTicks << 1) / 2)*0.2 + .5);
	}
}