/* Bubble Gun 2.0, by PurpleJazz http://www.jazz2online.com/snippets/129/bubble-gun/ */ void onLevelLoad() { //formalities jjObjectPresets[OBJECT::FIREBALLBULLET].special = jjObjectPresets[OBJECT::FIREBALLBULLET].determineCurAnim(ANIM::AMMO, 8); jjObjectPresets[OBJECT::FIREBALLBULLET].behavior = BubbleGun; jjObjectPresets[OBJECT::FIREBALLBULLET].xSpeed = 1.25; jjObjectPresets[OBJECT::FIREBALLBULLET].ySpeed = 0; jjObjectPresets[OBJECT::FIREBALLBULLET].counterEnd = 105; jjObjectPresets[OBJECT::FIREBALLBULLETPU].special = jjObjectPresets[OBJECT::FIREBALLBULLETPU].determineCurAnim(ANIM::AMMO, 8); jjObjectPresets[OBJECT::FIREBALLBULLETPU].behavior = BubbleGunPU; jjObjectPresets[OBJECT::FIREBALLBULLETPU].xSpeed = 1.5; jjObjectPresets[OBJECT::FIREBALLBULLETPU].ySpeed = 0; jjObjectPresets[OBJECT::FIREBALLBULLETPU].counterEnd = 105; jjObjectPresets[OBJECT::GUN8AMMO3].determineCurAnim(ANIM::AMMO, 8, true); jjObjectPresets[OBJECT::GUN8POWERUP].behavior = BubbleMonitor; //display the gun8 powerup as a bubble powerup } void onLevelBegin() { if (jjIsServer || jjGameMode == GAME::Mode::SP) jjChat("/fireball on"); //fireball needs to be enabled for this weapon to work } void BubbleGun(jjOBJ@ bubble) { if (bubble.state == STATE::START) { bubble.state = STATE::FLY; if (jjSoundEnabled) jjSample(bubble.xPos, bubble.yPos, SOUND::COMMON_PLOP2, 0, 0); } bubble.behave(BEHAVIOR::WATERSHIELDBULLET); if (jjMaskedPixel(bubble.xPos + bubble.xSpeed, bubble.yPos) || jjMaskedPixel(bubble.xPos - bubble.xSpeed, bubble.yPos) || jjMaskedPixel(bubble.xPos, bubble.yPos + bubble.ySpeed) || jjMaskedPixel(bubble.xPos, bubble.yPos - bubble.ySpeed)) { if (jjSoundEnabled) jjSample(bubble.xPos, bubble.yPos, SOUND::P2_SPLOUT, 0, 0); } bubble.killAnim = jjObjectPresets[OBJECT::WATERSHIELDBULLET].killAnim; bubble.determineCurFrame(); bubble.animSpeed = 1; //for SP bubble.var[6] = 0; //for MP } void BubbleGunPU(jjOBJ@ bubble) { if (bubble.state == STATE::START) { bubble.state = STATE::FLY; if (jjSoundEnabled) jjSample(bubble.xPos, bubble.yPos, SOUND::COMMON_PLOP2, 0, 0); } bubble.behave(BEHAVIOR::WATERSHIELDBULLET); if (bubble.state == STATE::FLY && bubble.counter > 0) { //controls on the arc of the bullet switch (bubble.direction) { case 0: bubble.ySpeed = bubble.ySpeed - 0.08; break; case 1: bubble.xSpeed = bubble.xSpeed - 0.1; bubble.ySpeed = bubble.ySpeed - 0.08; break; case -1: bubble.xSpeed = bubble.xSpeed + 0.1; bubble.ySpeed = bubble.ySpeed - 0.08; break; } } if (jjMaskedPixel(bubble.xPos + bubble.xSpeed, bubble.yPos) || jjMaskedPixel(bubble.xPos - bubble.xSpeed, bubble.yPos) || jjMaskedPixel(bubble.xPos, bubble.yPos + bubble.ySpeed) || jjMaskedPixel(bubble.xPos, bubble.yPos - bubble.ySpeed)) { if (jjSoundEnabled) jjSample(bubble.xPos, bubble.yPos, SOUND::P2_SPLOUT, 0, 0); } bubble.killAnim = jjObjectPresets[OBJECT::WATERSHIELDBULLET].killAnim; jjDrawSpriteFromCurFrame(bubble.xPos, bubble.yPos, bubble.curFrame, bubble.direction, SPRITE::NEONGLOW, 2); bubble.determineCurFrame(); bubble.animSpeed = 2; //for SP bubble.var[6] = 8; //for MP } void BubbleMonitor(jjOBJ@ obj) { obj.behave(BEHAVIOR::MONITOR); if (obj.justHit == 0) { jjDrawSprite(obj.xPos+7, obj.yPos-1, ANIM::AMMO, 8, 3); //cheeky! } } bool onDrawAmmo(jjPLAYER@ play, jjCANVAS@ canvas) { //displays the bubble sprite on the gun icon if (play.currWeapon == WEAPON::GUN8 && !play.noFire) { canvas.drawSprite( jjSubscreenWidth - 88, jjSubscreenHeight - 14, ANIM::AMMO, 8, play.powerup[WEAPON::GUN8] == true? 4:3, SPRITE::NORMAL ); canvas.drawString( jjSubscreenWidth - 80, jjSubscreenHeight - 14, "x" + play.ammo[WEAPON::GUN8], STRING::MEDIUM, STRING::NORMAL ); return true; } else return false; }