Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
![]() |
Spherical Coalesence![]() |
ThunDerDraGon | Capture the flag | 10 | ![]() |
//** Necessary for Advanced Arsenal weapons to function **//
namespace AATools {
array<afterImage@> afterImages;
array<floatingText@> floatingTexts;
float pi = 3.1415926f;
class afterImage {
private array<array<float>> frameData;
jjOBJ@ obj;
void draw() {
if (jjGameTicks%2 == 1) {
array<float> a;
a = {obj.xPos, obj.yPos, obj.curFrame, obj.direction};
frameData.insertAt(0, a);
}
if (frameData.length > 4)
frameData.removeAt(frameData.length-1);
for (uint i = 0; i < frameData.length; i++) {
jjDrawSpriteFromCurFrame(frameData[i][0], frameData[i][1], int(frameData[i][2]), int(frameData[i][3]), SPRITE::BLEND_NORMAL, 100, 4);
}
}
}
void addAfterImage(jjOBJ@ obj) {
afterImage image;
@image.obj = obj;
afterImages.insertLast(image);
}
class floatingText {
string text;
uint duration;
uint counter;
float xPos;
float yPos;
STRING::Size size;
STRING::Mode mode;
void draw() {
jjTEXTAPPEARANCE appearance;
appearance = mode;
appearance.align = STRING::CENTER;
appearance.monospace = true;
appearance.pipe = STRING::SPECIALSIGN;
appearance.hash = STRING::SPECIALSIGN;
appearance.spacing = 0;
float vPos;
if (counter < 17) {
appearance.spacing = int(counter/1.75);
vPos = yPos - counter*2.2f;
}
else {
appearance.spacing = 10;
vPos = yPos - 17*2.2f;
}
if (counter > duration-17) {
appearance.spacing = int(10-(counter-(duration-17))/1.75);
vPos += (counter-(duration-17))*2.2f;
}
//jjDrawString(xPos, float(yPos - 20 - (counter%125)/1.3f), text, size, appearance, 0, SPRITE::BLEND_NORMAL, 250 - (counter%125)*2);
jjDrawString(xPos, vPos, text, size, appearance, 0, SPRITE::PALSHIFT, 0, 1);
counter++;
}
}
void addFloatingText(string text, float xPos, float yPos, uint duration, STRING::Size size, STRING::Mode mode) {
floatingText ftext;
ftext.text = text;
ftext.xPos = xPos;
ftext.yPos = yPos;
ftext.duration = duration;
ftext.size = size;
ftext.mode = mode;
floatingTexts.insertLast(ftext);
}
void classProcessing() {
for (uint i=0; i < afterImages.length; i++) {
afterImages[i].draw();
if (!afterImages[i].obj.isActive)
afterImages.removeAt(i);
}
for (uint i=0; i < floatingTexts.length; i++) {
floatingTexts[i].draw();
if (floatingTexts[i].counter == floatingTexts[i].duration)
floatingTexts.removeAt(i);
}
}
int playerDistanceToObject(jjPLAYER@ play, jjOBJ@ obj) {
int distance;
if (obj.isActive)
distance = int(sqrt(pow(play.xPos - obj.xPos, 2) + pow(play.yPos - obj.yPos, 2)));
return distance;
};
int findNearestHostilePlayer(jjOBJ@ bullet, int maxDistance) {
int8 playerID = -1;
int distance1 = 0, distance2 = 0;
jjPLAYER@ play = jjPlayers[bullet.creatorID];
for (int i=0; i < 32; i++) {
jjPLAYER@ target = jjPlayers[i];
if (target.isEnemy(play) && target.isInGame && target.health > 0) {
distance1 = int(sqrt(pow(target.xPos - bullet.xPos, 2) + pow(target.yPos - bullet.yPos, 2)));
if ((distance1 < distance2 || distance2 == 0) && distance1 <= maxDistance) {
distance2 = distance1;
playerID = i;
}
}
}
return playerID;
};
void loadAssets(string filename, uint index, uint width, uint height) {
jjPIXELMAP asset(filename);
jjAnimSets[ANIM::CUSTOM[index]].load(
asset,
frameWidth: width,
frameHeight: height
);
}
void loadParticlePresets() {
jjOBJ@ preset = jjObjectPresets[OBJECT::ORANGE];
preset.playerHandling = HANDLING::PLAYERBULLET;
preset.bulletHandling = HANDLING::IGNOREBULLET;
preset.isBlastable = preset.isFreezable = preset.isTarget = false;
preset.animSpeed = 3;
preset.behavior = particle;
}
void particle(jjOBJ@ obj) {
if (obj.state == STATE::START)
obj.state = STATE::FLY;
else if (obj.state == STATE::FLY) {
obj.frameID = int((jjGameTicks%(4*7))/7);
obj.determineCurFrame();
obj.xPos += obj.xSpeed;
obj.yPos += obj.ySpeed;
obj.counterEnd++;
obj.var[0] = int(atan2(-(obj.xSpeed), -(obj.ySpeed))*512/3.1415926f);
if (obj.counterEnd == 255 || (jjMaskedPixel(int(obj.xPos), int(obj.yPos)) && obj.doesHurt == 0)) {
obj.state = STATE::EXPLODE;
if (obj.doesHurt == 0)
jjAddParticlePixelExplosion(obj.xPos, obj.yPos, obj.curFrame, obj.direction, 1);
}
} else obj.delete();
if (obj.counterEnd > 1) {
if (obj.doesHurt == 0)
jjDrawRotatedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, (obj.var[0] + (1023/4)), 1, 1, SPRITE::NORMAL, 4);
else
for (uint i=0; i < jjRandom()%6 + 1; i++) {
float size = 0.3 + 0.1*i;
jjDrawRotatedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 0,
size, size, SPRITE::NEONGLOW, i, 4);
}
}
}
string ammoMax(uint a) {
jjWEAPON@ weap = jjWeapons[a];
if (weap.infinite)
return "inf";
else if (weap.maximum == -1)
return (jjGameMode == GAME::SP) ? "99" : "50";
else return "" + weap.maximum;
};
int weaponToObject(uint a) {
if (a < OBJECT::FIREBALLBULLET)
return int(OBJECT::BLASTERBULLET) + (a-1);
else if (a == (OBJECT::TOASTERBULLET) + 1)
return int(OBJECT::TNT);
else return int(OBJECT::BLASTERBULLET) + (a-2);
};
int ammoType(uint a) {
if (a == 2)
return OBJECT::BOUNCERAMMO3;
else if (a == 3)
return OBJECT::ICEAMMO3;
else if (a > 3 && a < 10)
return (OBJECT::SEEKERAMMO3) + (a-4);
else return -1;
};
}
Jazz2Online © 1999-INFINITY (Site Credits). We have a Privacy Policy. Jazz Jackrabbit, Jazz Jackrabbit 2, Jazz Jackrabbit Advance and all related trademarks and media are ™ and © Epic Games. Lori Jackrabbit is © Dean Dodrill. J2O development powered by Loops of Fury and Chemical Beats.
Eat your lima beans, Johnny.