// *********************************************************************************** // Program written by B. Swan - BURROWINGGERBIL@HOTMAIL.COM // *********************************************************************************** // *********************************************************************************** // Collision with level function // *********************************************************************************** u_short LevelCollision(u_short tPlayer) { u_long tX, tY; u_short tTemp1 = 0, tTemp2; tX = (Player[tPlayer].x + LevelX + 2) >> 4; tY = (Player[tPlayer].y + 2) >> 4; tTemp2 = BlockData[LevelDATA[tX][tY]][0]; if (tTemp2 == 1) {tTemp1 = 1;} else if (tTemp2 == 2) {DrawSplash(tPlayer, 7);} tX += 1; tTemp2 = BlockData[LevelDATA[tX][tY]][0]; if (tTemp2 == 1) {tTemp1 = 1;} else if (tTemp2 == 2) {DrawSplash(tPlayer, 19); Player[tPlayer].yreal += 1;} tX += 1; tTemp2 = BlockData[LevelDATA[tX][tY]][0]; if (tTemp2 == 1) {tTemp1 = 1;} else if (tTemp2 == 2) {DrawSplash(tPlayer, 32); Player[tPlayer].yreal += 1;} tX = (Player[tPlayer].x + LevelX + 37) >> 4; if (BlockData[LevelDATA[tX][tY]][0] == 1) tTemp1 = 1; tX = (Player[tPlayer].x + LevelX + 2) >> 4; tY +=1; tTemp2 = BlockData[LevelDATA[tX][tY]][0]; if (tTemp2 == 1) {tTemp1 = 1;} else if (tTemp2 == 3) {DrawSplash2(tPlayer, tY * 16);} tX += 1; if (BlockData[LevelDATA[tX][tY]][0] == 1) tTemp1 = 1; tX += 1; if (BlockData[LevelDATA[tX][tY]][0] == 1) tTemp1 = 1; tX = (Player[tPlayer].x + LevelX + 37) >> 4; if (BlockData[LevelDATA[tX][tY]][0] == 1) tTemp1 = 1; tX = (Player[tPlayer].x + LevelX + 2) >> 4; tY = (Player[tPlayer].y + 20) >> 4; if (BlockData[LevelDATA[tX][tY]][0] == 1) tTemp1 = 1; tX += 1; if (BlockData[LevelDATA[tX][tY]][0] == 1) tTemp1 = 1; tX += 1; if (BlockData[LevelDATA[tX][tY]][0] == 1) tTemp1 = 1; tX = (Player[tPlayer].x + LevelX + 37) >> 4; if (BlockData[LevelDATA[tX][tY]][0] == 1) tTemp1 = 1; // If moved down by water keep on bottom of screen if necessary if (Player[tPlayer].yreal > 828) Player[tPlayer].yreal = 828; return tTemp1; } // *********************************************************************************** // Draw player ships // *********************************************************************************** void DrawPlayers() { u_short tTemp1, tTemp2, tTemp3, tTemp4; short tTemp5, tTemp6; for (tTemp1 = 0; tTemp1<2; tTemp1++) { if (Player[tTemp1].alive == 1) { // Fire haze if (Player[tTemp1].firehaze != 0) { Glows[0].r = Glows[0].g = Player[tTemp1].firehaze * 32; Glows[0].b = Player[tTemp1].firehaze * 24; Glows[0].x = Player[tTemp1].x + 30; Glows[0].y = Player[tTemp1].y + 10; Glows[0].scalex = Glows[0].scaley = ONE; Glows[0].rotate = ONE * (Counter % 360); GsSortSprite(&Glows[0], &OTable_Header[currentBuffer], 1); Player[tTemp1].firehaze -= 1; } // Glow for invincibility if (Player[tTemp1].invincible > 0) { tTemp2 = abs(32 - (Player[tTemp1].invincible + 32) % 64) * 4; } else { tTemp2 = 0; } // Glow for powering beam up if ((Player[tTemp1].firestatus == 1) && (Player[tTemp1].firetimer > HOLDTIME)) { tTemp3 = abs(32 - (Player[tTemp1].fireglow + 32) % 64) * 4; // Draw lens flare tTemp5 = 160 - (Player[tTemp1].x + 30); tTemp6 = 120 - (Player[tTemp1].y + 10); Glows[0].r = Glows[0].g = Glows[0].b = (Player[tTemp1].firetimer - HOLDTIME) * 2; Glows[1].r = Glows[1].g = Glows[1].b = ((Player[tTemp1].firetimer - HOLDTIME) >> 1); Glows[3].r = Glows[3].g = Glows[3].b = Glows[1].r; Glows[5].r = Glows[5].g = Glows[5].b = Glows[1].r; Glows[8].r = Glows[8].g = Glows[8].b = Glows[1].r; Glows[0].scalex = Glows[0].scaley = ONE; Glows[0].x = 160 - tTemp5; Glows[0].y = 120 - tTemp6; Glows[0].rotate = ONE * Counter * 5; GsSortSprite(&Glows[0], &OTable_Header[currentBuffer], 1); Glows[5].x = 152 + tTemp5 / 3; Glows[5].y = 112 + tTemp6 / 3; GsSortFastSprite(&Glows[5], &OTable_Header[currentBuffer], 1); Glows[8].x = 152 + tTemp5 / 2; Glows[8].y = 112 + tTemp6 / 2; GsSortFastSprite(&Glows[8], &OTable_Header[currentBuffer], 1); Glows[3].x = 144 + tTemp5 * 2; Glows[3].y = 104 + tTemp6 * 2; GsSortFastSprite(&Glows[3], &OTable_Header[currentBuffer], 1); Glows[1].x = 128 + tTemp5; Glows[1].y = 88 + tTemp6; GsSortFastSprite(&Glows[1], &OTable_Header[currentBuffer], 1); } else { tTemp3 = 0; } // Make ships rotate in different directions if (tTemp1 == 0) { tTemp4 = ((Counter * Player[0].speed) >> 3) % 16; } else { tTemp4 = 15 - ((Counter * Player[1].speed) >> 3) % 16; } // Set up and register sprite in ordering table PlayerShip[tTemp4].x = Player[tTemp1].x; PlayerShip[tTemp4].y = Player[tTemp1].y; PlayerShip[tTemp4].r = MIN((Player[tTemp1].r + tTemp2 - (tTemp3 >> 1)), 255); PlayerShip[tTemp4].g = MAX((Player[tTemp1].g - (tTemp2 >> 1) - (tTemp3 >> 1)), 0); PlayerShip[tTemp4].b = MIN((Player[tTemp1].b - (tTemp2 >> 1) + tTemp3), 255); GsSortFastSprite(&PlayerShip[tTemp4], &OTable_Header[currentBuffer], 4); } } } // *********************************************************************************** // Draw splashes on ships when in waterfalls (block type = 2) // *********************************************************************************** void DrawSplash(u_short tPlayer, u_short tX) { Splash.x = Player[tPlayer].x + tX; Splash.y = Player[tPlayer].y; Splash.rotate = ONE * (rand() % 30 + 345); Splash.r = Splash.g = Splash.b = rand() % 32 + 32; GsSortSprite(&Splash, &OTable_Header[currentBuffer], 3); } // *********************************************************************************** // Draw splashes on ships when on water (block type = 3) // *********************************************************************************** void DrawSplash2(u_short tPlayer, u_short ty) { u_short tTemp; for (tTemp = 0; tTemp < 3; tTemp++) { Splash.x = Player[tPlayer].x + tTemp * 13 + 7; Splash.y = ty; Splash.rotate = ONE * (rand() % 30 + 345); Splash.r = Splash.g = Splash.b = rand() % 32 + 32; GsSortSprite(&Splash, &OTable_Header[currentBuffer], 3); } } // *********************************************************************************** // React to player input // *********************************************************************************** void UpdatePlayers() { u_long PAD; u_short tTemp1, tTemp2; // React to player input for (tTemp1 = 0; tTemp1<2; tTemp1++) { if (tTemp1 == 0) { PAD = Pad1Read(); } else { PAD = Pad2Read(); } // if (PAD &PADL1) dumpScreen(0, 240, 320, 480); // Quit checking if ((PAD & PADselect) && (PAD & PADstart)) GameRunning = 0; // Main joypad updating if (Player[tTemp1].alive == 1) { // Process button presses if (PAD & PADcross) { if (Player[tTemp1].firestatus == 0) { Player[tTemp1].firestatus = 1; CreatePlayerBullet(tTemp1, 1); } else { // Play charging sound if (Player[tTemp1].firetimer == HOLDTIME) { PlaySound(5, 127, Player[tTemp1].x); } if (Player[tTemp1].firetimer < (100 + HOLDTIME)) { Player[tTemp1].firetimer += 1; if (Player[tTemp1].firetimer == HOLDTIME) Player[tTemp1].fireglow = 64; } } } else { if (Player[tTemp1].firetimer > HOLDTIME) { CreatePlayerBullet(tTemp1, 0); } Player[tTemp1].firestatus = 0; Player[tTemp1].firetimer = 0; } // Move at normal speed or slow if (PAD & PADsquare) { tTemp2 = 2; } else { tTemp2 = Player[tTemp1].speed; } // Move ship around if (PAD & PADup) Player[tTemp1].yreal = (Player[tTemp1].yreal < 40 + tTemp2 ? 40 : Player[tTemp1].yreal - tTemp2); if (PAD & PADdown) Player[tTemp1].yreal = (Player[tTemp1].yreal > 828 - tTemp2 ? 828 : Player[tTemp1].yreal + tTemp2); if (PAD & PADleft) Player[tTemp1].xreal = (Player[tTemp1].xreal < 40 + tTemp2 ? 40 : Player[tTemp1].xreal - tTemp2); if (PAD & PADright) Player[tTemp1].xreal = (Player[tTemp1].xreal > 1080 - tTemp2 ? 1080 : Player[tTemp1].xreal + tTemp2); Player[tTemp1].x = Player[tTemp1].xreal >> 2; Player[tTemp1].y = Player[tTemp1].yreal >> 2; // Update glow if powering weapon up if (Player[tTemp1].firetimer > HOLDTIME) { Player[tTemp1].fireglow -= 1; if (Player[tTemp1].fireglow ==0) Player[tTemp1].fireglow = 64; } // Collision with scenery check tTemp2 = LevelCollision(tTemp1); // Update glow if invincible if (Player[tTemp1].invincible > 0) { Player[tTemp1].invincible -=1; } else { if (tTemp2 != 0) { KillPlayer(tTemp1); } } } else { if (Player[tTemp1].alive == 0) { if (PAD & PADstart) { Player[tTemp1].invincible = 196; Player[tTemp1].alive = 1; } } else { Player[tTemp1].alive += 1; Glows[2].x = Player[tTemp1].x + 20; Glows[2].y = Player[tTemp1].y + 10; Glows[2].r = -Player[tTemp1].alive * 2; Glows[2].g = Glows[2].b = -Player[tTemp1].alive; Glows[2].scalex = Glows[2].scaley = ONE + ONE * (100 + Player[tTemp1].alive) / 40; Glows[2].rotate = ONE * ((Counter * 6) % 360); GsSortSprite(&Glows[2], &OTable_Header[currentBuffer], 1); Glows[2].scalex = Glows[2].scaley = ONE; Glows[2].rotate = ONE * (360 - ((Counter * 2) % 360)); GsSortSprite(&Glows[2], &OTable_Header[currentBuffer], 1); Glows[0].r = Glows[0].g = Glows[0].b = -Player[tTemp1].alive; Glows[0].x = Player[tTemp1].x + 20; Glows[0].y = Player[tTemp1].y + 10; Glows[0].scalex = Glows[0].scaley = ONE * (100 + Player[tTemp1].alive) / 20; Glows[0].rotate = ONE * (360 - (Counter * 10) % 360); GsSortSprite(&Glows[0], &OTable_Header[currentBuffer], 1); if (Player[tTemp1].alive == -1) { Player[tTemp1].invincible = 196; Player[tTemp1].alive = 1; } } } } } // *********************************************************************************** // Create a new bullet if possible // *********************************************************************************** void CreatePlayerBullet(u_short tPlayer, short tType) { short tTemp1, tTemp2, tTemp3, tTemp4, tTemp5; tTemp2 = tTemp3 = tTemp4 = -1; tTemp5 = 1; for (tTemp1 = 0; tTemp1> 3) + 15; Bullets[tPlayer][tTemp2].speedx = Bullets[tPlayer][tTemp2].w - 10; // fire sound PlaySound(3, 127, Player[tPlayer].x); } } } // *********************************************************************************** // Update player bullets // *********************************************************************************** void UpdatePlayerBullets() { u_short tTemp1, tTemp2, tTemp3; for (tTemp1 = 0; tTemp1<2; tTemp1++) { for (tTemp2 = 0; tTemp2 400) { Bullets[tTemp1][tTemp2].type = -1; } break; case 1: Bullets[tTemp1][tTemp2].x += Bullets[tTemp1][tTemp2].speedx; if (Bullets[tTemp1][tTemp2].x > 340) { Bullets[tTemp1][tTemp2].type = -1; } break; case 2: Bullets[tTemp1][tTemp2].x += Bullets[tTemp1][tTemp2].speedx; Bullets[tTemp1][tTemp2].y += Bullets[tTemp1][tTemp2].speedy; if ((Bullets[tTemp1][tTemp2].x > 340) || (Bullets[tTemp1][tTemp2].y > 260) || (Bullets[tTemp1][tTemp2].y < -20)) { Bullets[tTemp1][tTemp2].type = -1; } break; default: break; } // If bullets hit scenery tTemp3 = BlockData[LevelDATA[(LevelX + Bullets[tTemp1][tTemp2].x + Bullets[tTemp1][tTemp2].w) / 16][Bullets[tTemp1][tTemp2].y / 16]][0]; if (tTemp3 == 1) { if (TotalEnemies < NUMBER_OF_ENEMIES) { CreateSmallExplosion(Bullets[tTemp1][tTemp2].x + Bullets[tTemp1][tTemp2].w - 9, Bullets[tTemp1][tTemp2].y - 9); } Bullets[tTemp1][tTemp2].type = -1; } } } } } // *********************************************************************************** // Draw player bullets // *********************************************************************************** void DrawPlayerBullets() { u_short tTemp1, tTemp2; short tTemp5, tTemp6; for (tTemp1 = 0; tTemp1<2; tTemp1++) { for (tTemp2 = 0; tTemp2