1.0
23 Feb 2013 15:02
//Blaster Leave Trail Constants
const int cSpreadSpeed = 3; //The higher this value the more the shards will spread perpendicular to the blasterbullet
const float cSlowDownSpeed = 6; //How much the shards slow down compared to the bullet
const int cTrailLifeTime= 50; //How long the shards will exist
const int cDensityFactor = 6; //A lower factor gives more green shards
const int cDensityFactorPU = 4; //A lower factor gives more blue shards
//i is globally declared (if you use i in your own code you can put i in the main)
int i;
//A function that creates a trail shard
void CreateTrail(int bulletID, bool powerup) {
int shardID = jjAddObject(OBJECT::SHARD, jjObjects[bulletID].xPos, jjObjects[bulletID].yPos, 0, CREATOR::PLAYER);
jjObjects[shardID].special = 73;
if (powerup)
jjObjectPresets[OBJECT::SHARD].determineCurAnim(ANIM::PICKUPS, 44+jjRandom()%4, true);
else
jjObjectPresets[OBJECT::SHARD].determineCurAnim(ANIM::PICKUPS, 6+jjRandom()%4, true);
if (jjObjects[bulletID].direction != 0) {
jjObjects[shardID].xSpeed = jjObjects[bulletID].xSpeed - jjObjects[bulletID].direction*cSlowDownSpeed;
jjObjects[shardID].ySpeed = -cSpreadSpeed*(jjRandom()%32 - 16)/16;
} else {
jjObjects[shardID].xSpeed = -cSpreadSpeed*(jjRandom()%32 - 16)/16;
jjObjects[shardID].ySpeed = jjObjects[bulletID].ySpeed + cSlowDownSpeed;
}
}
void onMain() {
if (jjGameTicks%2 == 0)
for (i = 1; i < jjObjectCount; i++) {
if (jjObjects[i].isActive && jjObjects[i].creatorType == CREATOR::PLAYER) {
if (((jjGameTicks%cDensityFactor == 0 && jjObjects[i].eventID == OBJECT::BLASTERBULLET) || (jjGameTicks%cDensityFactorPU == 0 && jjObjects[i].eventID == OBJECT::BLASTERBULLETPU)) && jjObjects[i].state != STATE::EXPLODE)
CreateTrail(i, (jjObjects[i].eventID == OBJECT::BLASTERBULLETPU));
if (jjObjects[i].eventID == OBJECT::SHARD && jjObjects[i].special == 73) {
jjObjects[i].age++;
if (jjObjects[i].age > cTrailLifeTime)
jjDeleteObject(i);
}
}
}
}
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.