2.0
26 Feb 2013 16:58
/***Constants***/
const float cBombSpeed = 8; //xSpeed of the bomb
const float cBombPlayerSpeed = 6; //xSpeed the bomb can gain by player speed (if a player is running full speed it will add 6 xSpeed)
const int cBombLifeTime = 70*2; //Time till the bomb explodes (run away! run away!!!1)
/***Other functions***/
void CreateBomb(int objectID) {
int playerID = jjObjects[objectID].creator - 32768;
int bombID = jjAddObject(OBJECT::APPLE, jjPlayers[playerID].xPos, jjPlayers[playerID].yPos, jjPlayers[playerID].playerID, CREATOR::PLAYER);
jjObjects[bombID].objType = 3;
jjObjects[bombID].determineCurAnim(ANIM::AMMO, 1, true);
jjObjects[bombID].special = 11;
jjObjects[bombID].xSpeed = cBombSpeed*jjPlayers[playerID].direction + cBombPlayerSpeed*jjPlayers[playerID].xSpeed/16;
jjObjects[bombID].ySpeed = -3;
}
void DestroyBomb(int bombID) {
int explosionID = jjAddObject(OBJECT::TNT, jjObjects[bombID].xPos, jjObjects[bombID].yPos, jjObjects[bombID].creator, CREATOR::PLAYER);
jjDeleteObject(bombID);
jjObjects[explosionID].determineCurAnim(ANIM::AMMO, 1, true);
jjObjects[explosionID].killAnim = ANIM::AMMO;
jjObjects[explosionID].state = STATE::EXPLODE;
}
/***Gameplay functions***/
void onMain() {
for (int i = 0; i < jjObjectCount; i++)
if (jjObjects[i].isActive && jjObjects[i].creatorType == CREATOR::PLAYER) {
//Create bomb
if (jjObjects[i].eventID == OBJECT::TNT && jjObjects[i].state != STATE::EXPLODE) {
jjDeleteObject(i);
CreateBomb(i);
continue;
}
//Destroy bomb
if (jjObjects[i].eventID == OBJECT::APPLE && jjObjects[i].special == 11) {
jjObjects[i].age++;
if (jjObjects[i].age > cBombLifeTime)
DestroyBomb(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.