View Single Post
DennisKainz DennisKainz's Avatar

JCF Member

Joined: Dec 2005

Posts: 416

DennisKainz is notorious for his worthless posts

Dec 14, 2015, 09:04 AM
DennisKainz is offline
Reply With Quote
There's a new problem ... (Warn me if double posting is not authorized. I don't know all the rules)
I wrote a script. It works flawlessly on my computer, but Blaze the Movie Fan says it's extremely laggy on his computer, so I'll post it and see if you can help me.
Hopefully I'll learn something new and useful!

Code:
uint shownText = 0;
bool textShift = false;
uint textShiftTotal = 0;
uint thunderCounter = 0;
uint debugger = 0;
uint killedDemons = 0;
uint wallFall = 0;
uint wallFall1 = 0;
uint wallFall2 = 0;
uint isSugarRush = 0;
bool justMorphed = false;

void onLevelLoad()
	{
	jjPalette.gradient(224, 192, 255, 0, 0, 0, 16, 8, 1);
	jjPalette.gradient(192, 255, 224, 0, 0, 0, 24, 8, 1);
	jjPalette.gradient(255, 255, 192, 0, 0, 0, 32, 8, 1);
	jjPalette.gradient(255, 192, 255, 0, 0, 0, 40, 8, 1);
	jjPalette.gradient(192, 255, 192, 0, 0, 0, 48, 8, 1);
	jjPalette.gradient(255, 192, 224, 0, 0, 0, 58, 6, 1);
	jjPalette.gradient(224, 224, 255, 0, 0, 0, 64, 8, 1);
	jjPalette.gradient(255, 192, 192, 0, 0, 0, 72, 8, 1);
	jjPalette.gradient(255, 224, 224, 0, 0, 0, 80, 8, 1);
	jjPalette.gradient(192, 255, 224, 0, 0, 0, 88, 8, 1);
	jjPalette.gradient(224, 192, 160, 0, 0, 0, 104, 12, 1);
	jjPalette.gradient(16, 0, 16, 32, 0, 0, 176, 32, 1);
	jjPalette.gradient(0, 0, 0, 0, 0, 0, 10, 1, 1);
	jjPalette.apply();
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::NORMAL;
	p.lives = 5;
	jjObjectPresets[OBJECT::BAT].energy = 5;
	jjObjectPresets[OBJECT::DEMON].energy = 25;
	jjObjectPresets[OBJECT::DOGGYDOGG].energy = 15;
	jjObjectPresets[OBJECT::DRAGON].energy = 10;
	jjObjectPresets[OBJECT::HELMUT].energy = 15;
	jjObjectPresets[OBJECT::MONKEY].energy = 20;
	jjObjectPresets[OBJECT::RAPIER].energy = 25;
	jjObjectPresets[OBJECT::RAVEN].energy = 10;
	jjObjectPresets[OBJECT::STANDMONKEY].energy = 25;
	jjObjectPresets[OBJECT::BOLLPLATFORM].behavior = myPlatform;
	jjObjectPresets[OBJECT::BOLLPLATFORM].deactivates = false;
	jjObjectPresets[OBJECT::SPIKEBOLL].energy = 0;
	jjObjectPresets[OBJECT::SPIKEPLATFORM].behavior = bruiser;
	}
	
void onLevelReload()
	{
	jjPalette.gradient(224, 192, 255, 0, 0, 0, 16, 8, 1);
	jjPalette.gradient(192, 255, 224, 0, 0, 0, 24, 8, 1);
	jjPalette.gradient(255, 255, 192, 0, 0, 0, 32, 8, 1);
	jjPalette.gradient(255, 192, 255, 0, 0, 0, 40, 8, 1);
	jjPalette.gradient(192, 255, 192, 0, 0, 0, 48, 8, 1);
	jjPalette.gradient(255, 192, 224, 0, 0, 0, 58, 6, 1);
	jjPalette.gradient(224, 224, 255, 0, 0, 0, 64, 8, 1);
	jjPalette.gradient(255, 192, 192, 0, 0, 0, 72, 8, 1);
	jjPalette.gradient(255, 224, 224, 0, 0, 0, 80, 8, 1);
	jjPalette.gradient(192, 255, 224, 0, 0, 0, 88, 8, 1);
	jjPalette.gradient(224, 192, 160, 0, 0, 0, 104, 12, 1);
	jjPalette.gradient(16, 0, 16, 32, 0, 0, 176, 32, 1);
	jjPalette.gradient(0, 0, 0, 0, 0, 0, 10, 1, 1);
	jjPalette.apply();
	jjUseLayer8Speeds = true;
	jjTexturedBGTexture = TEXTURE::NORMAL;
	wallFall = 0;
	wallFall1 = 0;
	wallFall2 = 0;
	}
	
void onLevelBegin()
	{
	p.xPos = 5.5 * 32;
	p.yPos = 0;
	p.xOrg = 5.5 * 32;
	p.yOrg = 0;
	ActivateEventAt(27, 6);
	ActivateEventAt(32, 9);
	}
	
jjOBJ@ ActivateEventAt(int xTile, int yTile) {
	if (jjParameterGet(xTile, yTile, -1, 1) == 1)
		return null;
	jjParameterSet(xTile, yTile, -1, 1, 1);
	return jjObjects[jjAddObject(jjEventGet(xTile, yTile), xTile * 32 + 15, yTile * 32 + 15, 0, CREATOR::LEVEL)];
	}
	
void onMain()
	{
	if (textShift == true && textShiftTotal < 70)
		textShiftTotal = textShiftTotal + 1;
	if (textShift == false && textShiftTotal > 0)
		textShiftTotal = textShiftTotal - 1;
	if (jjRandom() & 3500 == 0)
		thunderCounter = 16;
	if (thunderCounter > 0)
		thunderCounter = thunderCounter - 1;
	jjPalette.gradient(16 - thunderCounter + (thunderCounter * 16), 0 + (thunderCounter * 16), 16 - thunderCounter + (thunderCounter * 16), 32, 0, 0, 176, 32, 1);
	jjPalette.apply();
	jjSetFadeColors(16 - thunderCounter + (thunderCounter * 16), 0 + (thunderCounter * 16), 16 - thunderCounter + (thunderCounter * 16));
	if (killedDemons >= 1 && jjTriggers[0] == false)
		jjSwitchTrigger(0);
	if (wallFall > 0 && wallFall1 < 256)
		wallFall1 = wallFall1 + 8;
	if (wallFall1 == 256 && jjTriggers[30] == false)
		jjSwitchTrigger(30);
	if (wallFall > 1 && wallFall2 < 256)
		wallFall2 = wallFall2 + 8;
	if (wallFall2 == 256 && jjTriggers[31] == false)
		jjSwitchTrigger(31);
	if (killedDemons >= 5 && jjTriggers[5] == false)
		jjSwitchTrigger(5);
	if (p.health < 1)
		{
		textShift = false;
		textShiftTotal = 0;
		}
	if (isSugarRush > 0)
		isSugarRush = isSugarRush - 1;
	}

void onPlayer()
	{
	if (p.yPos < 32 && p.ySpeed < 0)
		p.yPos = 32;
	if (p.food >= 1)
		{
		p.startSugarRush(1400);
		isSugarRush = 1400;
		p.food = 0;
		}
	if (p.health < 1)
		isSugarRush = 0;
	if (p.blink != 0 && isSugarRush < 1)
		{
		p.blink = 0;
		p.invincibility = 0;
		}
	p.fastfire = 6;
	if (isSugarRush == 0)
		p.jumpStrength = -8.5;
	if (isSugarRush > 0)
		p.jumpStrength = -11.5;
	if (p.yPos > 16 * 32 && p.health > 0)
		{
		p.health = 0;
		p.kill();
		}
	for (int i = 1; i < jjObjectCount; i++)
		{
		jjOBJ@ o = jjObjects[i];
		if (o.eventID == OBJECT::DEMON && o.state == STATE::KILL && o.justHit == 1)
			killedDemons = killedDemons + 1;
		}
	p.cameraFreeze(p.xPos, 272, true, true);
	}
	
void onPlayerInput(jjPLAYER@ p)
	{
	if (isSugarRush == 0)
		p.keyRun = false;
	if (p.health < 1)
		{
		p.keyDown = false;
		p.keyFire = false;
		p.keyJump = false;
		p.keyLeft = false;
		p.keyRight = false;
		p.keySelect = false;
		p.keyUp = false;
		}
	if (jjKey[0x4A] == true && p.charCurr == CHAR::SPAZ)
		p.morphTo(CHAR::JAZZ, true);
	if (jjKey[0x53] == true && p.charCurr == CHAR::JAZZ)
		p.morphTo(CHAR::SPAZ, true);
	}
	
void onFunction0()
	{
	textShift = false;
	}
	
void onFunction1()
	{
	textShift = true;
	shownText = 1;
	}
	
void onFunction2()
	{
	textShift = true;
	shownText = 2;
	}
	
void onFunction5()
	{
	textShift = true;
	shownText = 5;
	}
	
void onFunction20()
	{
	if (wallFall < 1)
		wallFall = 1;
	textShift = true;
	shownText = 10;
	}
	
void onFunction21()
	{
	if (wallFall < 2)
		wallFall = 2;
	}
	
void bruiser(jjOBJ@ bruise)
	{
	bruise.behave(BEHAVIOR::PLATFORM, true);
	bruise.playerHandling = HANDLING::ENEMYBULLET;
	bruise.animSpeed = 1;
	if (bruise.xOrg % 32 == 15)
		bruise.xOrg = bruise.xOrg - 16;
	if (p.health < 1)
		bruise.state = STATE::KILL;
	if (p.yPos < bruise.yPos + 32 && wallFall > 0)
		p.yPos = bruise.yPos + 32;
	if (wallFall > 0 && bruise.yOrg < 14 * 32)
		bruise.yOrg = bruise.yOrg + 0.5;
	debugger = jjParameterGet(27, 6, -1, 1);
	}
	
void myPlatform(jjOBJ@ myPlat)
	{
	myPlat.behave(BEHAVIOR::PLATFORM, true);
	if (p.health < 1)
		myPlat.state = STATE::KILL;
	if (myPlat.yOrg % 32 == 15)
		myPlat.yOrg = myPlat.yOrg - 12;
	if (myPlat.var[0] == -35)
		myPlat.xOrg = myPlat.xOrg + myPlat.var[1];
	if (myPlat.var[0] == 35)
		myPlat.xOrg = myPlat.xOrg - myPlat.var[1];
	if (jjEventGet((myPlat.xOrg + 18) / 32, (myPlat.yOrg) / 32) == AREA::SLIDE && myPlat.var[0] < 35)
		{
		myPlat.var[0] = myPlat.var[0] + 1;
		}
	if (jjEventGet((myPlat.xOrg - 18) / 32, (myPlat.yOrg) / 32) == AREA::SLIDE && myPlat.var[0] > -35)
		{
		myPlat.var[0] = myPlat.var[0] - 1;
		}
	}
	
void onDrawLayer4(jjPLAYER@ p, jjCANVAS@ screen)
	{
	jjDrawTile(233 * 32, (7 * 32) + (jjSin(wallFall1 - 256) * 64), 268, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (8 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (9 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (10 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (11 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (12 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (13 * 32) + (jjSin(wallFall1 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(233 * 32, (14 * 32) + (jjSin(wallFall1 - 256) * 64), 268, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (7 * 32) + (jjSin(wallFall2 - 256) * 64), 268, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (8 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (9 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (10 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (11 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (12 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (13 * 32) + (jjSin(wallFall2 - 256) * 64), 216, TILE::ALLQUADRANTS, 4, 4, -1);
	jjDrawTile(252 * 32, (14 * 32) + (jjSin(wallFall2 - 256) * 64), 268, TILE::ALLQUADRANTS, 4, 4, -1);
	}
	
void onDrawLayer1(jjPLAYER@ p, jjCANVAS@ screen)
	{
	jjTEXTAPPEARANCE mytext;
	mytext.at = STRING::SPECIALSIGN;
	mytext.pipe = STRING::SPECIALSIGN;
	mytext.align = STRING::CENTER;
	if (shownText == 1)
		screen.drawString(p.cameraX + 320, -20 + textShiftTotal, "'Welcome' to Hell!@If you complete the test,@you'll obtain a reward!", STRING::SMALL, mytext, 0);
	if (shownText == 2)
		screen.drawString(p.cameraX + 320, -20 + textShiftTotal, "Press J to turn into Jazz.@Press S to turn into Spaz.", STRING::SMALL, mytext, 0);
	if (shownText == 5)
		screen.drawString(p.cameraX + 320, -20 + textShiftTotal, "Kill 5 demons@to open this door.", STRING::SMALL, mytext, 0);
	if (shownText == 10)
		screen.drawString(p.cameraX + 320, -20 + textShiftTotal, "I lied!@No reward for you!@Just pain!", STRING::SMALL, mytext, 0);
	screen.drawString(p.xPos, 64, "", STRING::SMALL, mytext, 0);
	}
HERE'S THE LEVEL
__________________
Free will was a mistake.
- God