/** * * \name Died() * * Died * This function perfoms the process of animation the character's death and restart the level * if you still have lives. * */ void Died (void) { float fangle; long dx,dy; int iangle,curangle,clockwise,counter,change; /* -1 means the player has no weapon */ gamestate.weapon = -1; // take away weapon /* We need another way to play sounds */ SD_PlaySound (PLAYERDEATHSND); // // swing around to face attacker // /* could be a function for this animation like: died_animation() or died_rotated_animation() */ dx = killerobj->x - player->x; dy = player->y - killerobj->y; fangle = atan2(dy,dx); // returns -pi to pi if (fangle<0) fangle = M_PI*2+fangle; iangle = fangle/(M_PI*2)*ANGLES; if (player->angle > iangle) { counter = player->angle - iangle; clockwise = ANGLES-player->angle + iangle; } else { clockwise = iangle - player->angle; counter = player->angle + ANGLES-iangle; } curangle = player->angle; if (clockwise<counter) { // // rotate clockwise // if (curangle>iangle) curangle -= ANGLES; do { change = tics*DEATHROTATE; if (curangle + change > iangle) change = iangle-curangle; curangle += change; player->angle += change; if (player->angle >= ANGLES) player->angle -= ANGLES; ThreeDRefresh (); CalcTics (); } while (curangle != iangle); } else { // // rotate counterclockwise // if (curangle<iangle) curangle += ANGLES; do { change = -tics*DEATHROTATE; if (curangle + change < iangle) change = iangle-curangle; curangle += change; player->angle += change; if (player->angle < 0) player->angle += ANGLES; ThreeDRefresh (); CalcTics (); } while (curangle != iangle); } /* FINISH of rotation animation */ // // fade to red // FinishPaletteShifts (); bufferofs += screenofs; VW_Bar (0,0,viewwidth,viewheight,4); IN_ClearKeysDown (); FizzleFade(bufferofs,displayofs+screenofs,viewwidth,viewheight,70,false); bufferofs -= screenofs; IN_UserInput(100); SD_WaitSoundDone (); if (tedlevel == false) // SO'S YA DON'T GET KILLED WHILE LAUNCHING! gamestate.lives--; if (gamestate.lives > -1) //if the character has lives, set a new level { gamestate.health = 100; gamestate.weapon = gamestate.bestweapon = gamestate.chosenweapon = wp_pistol; gamestate.ammo = STARTAMMO; gamestate.keys = 0; gamestate.attackframe = gamestate.attackcount = gamestate.weaponframe = 0; /* We need to change those Draw function to Draw3D functions. */ DrawKeys (); DrawWeapon (); DrawAmmo (); DrawHealth (); DrawFace (); DrawLives (); } }
void DemoLoop (void) { id0_int_t i,level; // // check for launch from ted // if (tedlevel) { NewGame(); gamestate.mapon = tedlevelnum; restartgame = gd_Normal; for (i = 1;i < id0_argc;i++) { if ( (level = US_CheckParm(id0_argv[i],ParmStrings)) == -1) continue; // REFKEEN - Cast for C++ restartgame = (GameDiff)(gd_Easy+level); break; } GameLoop(); TEDDeath(); } // // main game cycle // displayofs = bufferofs = 0; VW_Bar (0,0,320,200,0); while (1) { CA_CacheGrChunk (TITLEPIC); bufferofs = SCREEN2START; displayofs = SCREEN1START; VWB_DrawPic (0,0,TITLEPIC); MM_SetPurge (&grsegs[TITLEPIC],3); UNMARKGRCHUNK(TITLEPIC); FizzleFade (bufferofs,displayofs,320,200,true); if (!IN_UserInput(TickBase*3,false)) { CA_CacheGrChunk (CREDITSPIC); VWB_DrawPic (0,0,CREDITSPIC); MM_SetPurge (&grsegs[CREDITSPIC],3); UNMARKGRCHUNK(CREDITSPIC); FizzleFade (bufferofs,displayofs,320,200,true); } if (!IN_UserInput(TickBase*3,false)) { highscores: DrawHighScores (); FizzleFade (bufferofs,displayofs,320,200,true); IN_UserInput(TickBase*3,false); } if (IN_IsUserInput()) { US_ControlPanel (); if (restartgame || loadedgame) { GameLoop (); goto highscores; } } } }
void Died (void) { float fangle; long dx,dy; int iangle,curangle,clockwise,counter,change; gamestate.weapon = (weapontype)-1; // take away weapon SD_PlaySound (PLAYERDEATHSND); // // swing around to face attacker // dx = killerobj->x - player->x; dy = player->y - killerobj->y; fangle = atan2((float)dy,(float)dx); // returns -pi to pi // PORT add float cast if (fangle<0) fangle = M_PI*2+fangle; iangle = fangle/(M_PI*2)*ANGLES; if (player->angle > iangle) { counter = player->angle - iangle; clockwise = ANGLES-player->angle + iangle; } else { clockwise = iangle - player->angle; counter = player->angle + ANGLES-iangle; } curangle = player->angle; if (clockwise<counter) { // // rotate clockwise // if (curangle>iangle) curangle -= ANGLES; do { change = tics*DEATHROTATE; if (curangle + change > iangle) change = iangle-curangle; curangle += change; player->angle += change; if (player->angle >= ANGLES) player->angle -= ANGLES; ThreeDRefresh (); CalcTics (); } while (curangle != iangle); } else { // // rotate counterclockwise // if (curangle<iangle) curangle += ANGLES; do { change = -tics*DEATHROTATE; if (curangle + change < iangle) change = iangle-curangle; curangle += change; player->angle += change; if (player->angle < 0) player->angle += ANGLES; ThreeDRefresh (); CalcTics (); } while (curangle != iangle); } // // fade to red // FinishPaletteShifts (); bufferofs += screenofs; VW_Bar (0,0,viewwidth,viewheight,4); IN_ClearKeysDown (); FizzleFade(bufferofs,displayofs+screenofs,viewwidth,viewheight,70,False); bufferofs -= screenofs; IN_UserInput(100); SD_WaitSoundDone (); if (tedlevel == False) // SO'S YA DON'T GET KILLED WHILE LAUNCHING! gamestate.lives--; if (gamestate.lives > -1) { gamestate.health = 100; gamestate.weapon = gamestate.bestweapon = gamestate.chosenweapon = wp_pistol; gamestate.ammo = STARTAMMO; gamestate.keys = 0; gamestate.attackframe = gamestate.attackcount = gamestate.weaponframe = 0; DrawKeys (); DrawWeapon (); DrawAmmo (); DrawHealth (); DrawFace (); DrawLives (); } }