2.0
26 Feb 2013 16:53
/***Constants***/
const int cSpreadSpeed = 2; //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= 70*1.5; //How long the shards will exist
const int cGreenDensityFactor = 6; //A lower factor gives more green shards
const int cBlueDensityFactor = 4; //A lower factor gives more blue shards
/**Other functions**/
void CreateShardTrail(int bulletID, bool greentrail) {
int shardID = jjAddObject(OBJECT::SHARD, jjObjects[bulletID].xPos, jjObjects[bulletID].yPos, 0, CREATOR::PLAYER);
jjObjects[shardID].special = 12;
if (greentrail)
jjObjectPresets[OBJECT::SHARD].determineCurAnim(ANIM::PICKUPS, 6+jjRandom()%4, true);
else
jjObjectPresets[OBJECT::SHARD].determineCurAnim(ANIM::PICKUPS, 44+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;
}
}
/**Gameplay functions**/
void onMain() {
for (int i = 0; i < jjObjectCount; i++)
if (jjObjects[i].isActive && jjObjects[i].creatorType == CREATOR::PLAYER) {
//Shard Trail
if (((jjGameTicks%cBlueDensityFactor == 0 && (jjObjects[i].eventID == OBJECT::ICEBULLET || jjObjects[i].eventID == OBJECT::ICEBULLETPU)) || (jjGameTicks%cGreenDensityFactor == 0 && jjObjects[i].eventID == OBJECT::BLASTERBULLET)) && jjObjects[i].state != STATE::EXPLODE) {
CreateShardTrail(i, (jjObjects[i].eventID == OBJECT::BLASTERBULLET));
continue;
}
//Maintain shard lifetime
if (jjObjects[i].eventID == OBJECT::SHARD && jjObjects[i].special == 12) {
jjObjects[i].age++;
if (jjObjects[i].age > cTrailLifeTime)
jjDeleteObject(i);
continue;
}
}
}
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.