Exemple #1
0
void deleteobject(int objectnum)
  {
  int count;

  if (objectnum<0)
    return;
  if (objectnum>=numofobjects)
    return;

  for (count=0;count<object[objectnum].numofparticles;count++)
    {
    particle[object[objectnum].particle[count]].timetolive=1;
    particle[object[objectnum].particle[count]].objectnum=-1;
    }
  for (count=0;count<numofobjects;count++)
  if (object[count].link==objectnum)
    object[count].link=-1;

  for (count=0;count<numofropes;count++)
  if (rope[count].link==objectnum)
    rope[count].link=-1;

  for (count=0;count<numofbonds;count++)
  if (bond[count].type!=4 && bond[count].type!=7)
    if (bond[count].objectnum==objectnum)
      bond[count].objectnum=-1;

  deletesound(object[objectnum].soundnum[0]);
  deletesound(object[objectnum].soundnum[1]);
  deletesound(object[objectnum].soundnum[2]);
  deletesound(object[objectnum].soundnum[3]);

  numofobjects--;

  if (objectnum==numofobjects)
    return;

  memcpy(&object[objectnum],&object[numofobjects],sizeof(object[objectnum]));

  for (count=0;count<object[objectnum].numofparticles;count++)
  if (particle[object[objectnum].particle[count]].objectnum!=-1)
    particle[object[objectnum].particle[count]].objectnum=objectnum;

  for (count=0;count<numofobjects;count++)
  if (object[count].link==numofobjects)
    object[count].link=objectnum;

  for (count=0;count<numofropes;count++)
  if (rope[count].link==numofobjects)
    rope[count].link=objectnum;

  for (count=0;count<numofbonds;count++)
  if (bond[count].type!=4 && bond[count].type!=7)
    if (bond[count].objectnum==numofobjects)
      bond[count].objectnum=objectnum;

  for (count=0;count<numofsounds;count++)
  if (sound[count].objectnum==numofobjects)
    sound[count].objectnum=objectnum;
  }
Exemple #2
0
void postgamemenu(void)
  {
  int count;
  int scoretemp;
  int scorecountdelay;
  int simtimer;
  int simcount;

  savereplay(game.levelnum+100);

  scoretemp=game.totalscore;
  scorecountdelay=0;

  simtimer=SDL_GetTicks();

  resetmenuitems();

  joymenunum=1;

  while (!menuitem[0].active && !menuitem[1].active && !windowinfo.shutdown)
    {
    glClearColor(0.0f,0.0f,0.0f,0.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    numofmenuitems=0;
    createmenuitem(TXT_BACK,0,0,16,1.0f,1.0f,1.0f,1.0f);
    setmenuitem(MO_HOTKEY,SCAN_ESC);
    if (game.levelnum!=34)
      {
      createmenuitem(TXT_NEXTLEVEL,(640|TEXT_END),0,16,1.0f,1.0f,1.0f,1.0f);
      setmenuitem(MO_HOTKEY,SCAN_N);
      }
    else
      {
      createmenuitem(TXT_ENDING,(640|TEXT_END),0,16,1.0f,1.0f,1.0f,1.0f);
      setmenuitem(MO_HOTKEY,SCAN_N);
      }

    checksystemmessages();
    checkkeyboard();
    checkmouse();
    checkjoystick();
    checkmenuitems();

    soundsimulation(view.position,view.orientation);

    setuptextdisplay();

    glColor4f(1.0f,1.0f,1.0f,1.0f);
    displaybackground(580);

    drawbackground(468,(320|TEXT_CENTER),48,384,64,640,480);
    drawbackground(469,400,160,128,128,640,480);

    if (!game.bosslevel)
      {
      count=128;
      drawtext(TXT_SMALL_AMBER" /i///i",64,count,16,1.0f,1.0f,1.0f,1.0f,game.bonus[5],game.numofbonus[5]);
      count+=16;
      drawtext(TXT_MEDIUM_AMBER" /i///i",64,count,16,1.0f,1.0f,1.0f,1.0f,game.bonus[6],game.numofbonus[6]);
      count+=16;
      drawtext(TXT_LARGE_AMBER" /i///i",64,count,16,1.0f,1.0f,1.0f,1.0f,game.bonus[7],game.numofbonus[7]);
      count+=16;
      drawtext(TXT_TARBALLS" /i///i",64,count,16,1.0f,1.0f,1.0f,1.0f,game.bonus[4],game.numofbonus[4]);
      count+=16;
      drawtext(TXT_EXTRA_LIVES" /i///i",64,count,16,1.0f,1.0f,1.0f,1.0f,game.bonus[3],game.numofbonus[3]);
      count+=16;
      drawtext(TXT_SECRETS" /i///i",64,count,16,1.0f,1.0f,1.0f,1.0f,game.bonus[8],game.numofbonus[8]);
      count+=16;

      drawtext(TXT_LIFE_BONUS":/i",64,352,16,1.0f,1.0f,1.0f,1.0f,(object[0].hitpoints/50)*10);
      drawtext(TXT_LEVEL_POINTS":/i",64,368,16,1.0f,1.0f,1.0f,1.0f,game.score[0]-(object[0].hitpoints/50)*10);
      }
    else
      {
      if (game.levelnum==34 && game.exit==GAMEEXIT_WON)
        drawtext(TXT_GF_RESCUING_BONUS,64,336,16,1.0f,1.0f,1.0f,1.0f);
      drawtext(TXT_LIFE_BONUS":/i",64,352,16,1.0f,1.0f,1.0f,1.0f,(object[0].hitpoints/50)*10);
      if (game.levelnum==34 && game.exit==GAMEEXIT_WON)
        drawtext(TXT_BOSS_POINTS":/i",64,368,16,1.0f,1.0f,1.0f,1.0f,game.score[0]-(object[0].hitpoints/50)*10-1);
      else
        drawtext(TXT_BOSS_POINTS":/i",64,368,16,1.0f,1.0f,1.0f,1.0f,game.score[0]-(object[0].hitpoints/50)*10);
      }

    drawtext(TXT_TOTAL_POINTS":/i",64,384,16,1.0f,1.0f,1.0f,1.0f,scoretemp);
    drawtext("+/i",64+19*16,384,16,1.0f,1.0f,1.0f,1.0f,game.score[0]-(scoretemp-game.totalscore));

    drawmenuitems();

    drawmousecursor(768+font.cursornum,mouse.x,mouse.y,16,1.0f,1.0f,1.0f,1.0f);

    SDL_GL_SwapBuffers();

    simcount=0;
    while (SDL_GetTicks()-simtimer>20 && simcount<5)
      {
      simcount++;
      count=SDL_GetTicks()-simtimer-20;
      simtimer=SDL_GetTicks()-count;

      scorecountdelay++;

      if (scorecountdelay>=25)
      if (scoretemp<game.totalscore+game.score[0])
        {
        if (scoretemp<=game.totalscore+game.score[0]-10)
          scoretemp+=10;
        else
          scoretemp++;
        if ((scorecountdelay&1)==1)
          playsound(15,view.position,NULL,0.2f,0,1.0f,-1,0);
        }
      }
    }

  if (menuitem[0].active) {
    game.exit=GAMEEXIT_EXITGAME;
  }
  for (count=numofsounds-1;count>=0;count--)
    deletesound(count);

  resetmenuitems();
  }
Exemple #3
0
void setupgame(void)
  {
  int count,count2;

  srand(time(NULL));
  randomnum=0;

  for (count=numofsounds-1;count>=0;count--)
    deletesound(count);

  numofreplayframes=0;

  game.score[0]=0;
  game.score[1]=0;
  game.combo=1;
  game.combodelay=0;
  game.scoredelay=0;
  game.startdelay=0;
  game.exitdelay=0;
  game.over=0;
  game.exit=0;
  game.time=level.time;
  game.pause=0;
  game.framenum=0;
  game.bosslevel=0;
  game.dialog=0;

  if (game.levelnum==6)
    {
    game.bosslevel=1;
    game.dialog=2;
    game.dialogdelay=1000;
    }
  if (game.levelnum==13)
    {
    game.bosslevel=1;
    game.dialog=3;
    game.dialogdelay=1000;
    }
  if (game.levelnum==20)
    {
    game.bosslevel=1;
    game.dialog=3;
    game.dialogdelay=1000;
    }
  if (game.levelnum==27)
    {
    game.bosslevel=1;
    game.dialog=3;
    game.dialogdelay=1000;
    }
  if (game.levelnum==33)
    {
    game.bosslevel=1;
    game.dialog=3;
    game.dialogdelay=1000;
    }
  if (game.levelnum==34)
    {
    game.bosslevel=1;
    game.dialog=8;
    game.dialogdelay=1000;
    }
  if (game.levelnum==68)
    {
    game.bosslevel=1;
    game.dialog=16;
    game.dialogdelay=1000;
    }

  if (level.gametype==10)
    game.time=6000;
  if (level.gametype==12)
    game.time=6000;
  if (level.gametype==17)
    game.time=6000;

  for (count=0;count<16;count++)
    {
    game.bonus[count]=0;
    game.numofbonus[count]=0;
    }

  for (count=0;count<256;count++)
  for (count2=0;count2<256;count2++)
    {
    if (level.grid[count][count2]>=240 && level.grid[count][count2]<=247)
      game.numofbonus[level.grid[count][count2]-240]++;
    if (level.grid[count][count2]>=248 && level.grid[count][count2]<=255)
      game.numofbonus[level.grid[count][count2]-248]++;
    }

  for (count=0;count<numofobjects;count++)
  if (object[count].type==16)
  if (object[count].idata[1]==2)
    game.numofbonus[8]++;

  if (level.gametype==1)
    game.startdelay=100;

  if ((level.gametype>=10 && level.gametype<=14) || level.gametype==17 || level.gametype==18)
    game.startdelay=100;

  if (level.gametype<10 && !editor.active)
    {
    view.position[0]=object[0].position[0];
    view.position[1]=object[0].position[1];
    view.position[2]=10.0f;
    if (game.levelnum==64)
      view.position[1]=131.5f;
    if (game.levelnum==65)
      {
      count=object[0].position[0]+16.0f;
      count/=32;
      count*=32;
      view.position[0]=count;
      view.position[1]=126.0f;
      }
    }
  if (level.gametype==10)
    {
    view.position[0]=127.5f;
    view.position[1]=127.5f;
    view.position[2]=10.0f;
    }
  if (level.gametype==11)
    {
    view.position[0]=127.0f;
    view.position[1]=124.5f;
    view.position[2]=10.0f;
    }
  if (level.gametype==12)
    {
    view.position[0]=126.5f;
    view.position[1]=130.0f;
    view.position[2]=10.0f;
    }
  if (level.gametype==13)
    {
    view.position[0]=127.0f;
    view.position[1]=124.5f;
    view.position[2]=10.0f;
    }
  if (level.gametype==14)
    {
    view.position[0]=127.5f;
    view.position[1]=127.5f;
    view.position[2]=10.0f;
    }
  if (level.gametype==17)
    {
    view.position[0]=127.5f;
    view.position[1]=127.5f;
    view.position[2]=10.0f;
    }
  if (level.gametype==18)
    {
    view.position[0]=127.0f;
    view.position[1]=127.5f;
    view.position[2]=10.0f;
    }

  resetorientation(view.orientation);
  }