Beispiel #1
0
/*
  Interacts with the tile at players feet. This will usually change
  the tile to an identical-looking but functionally inert tile.
*/
int interact()
{
  int tile;
  char line[DEFLEN];

  tile = gtile(player->y, player->x);

  if (tile == TL_P_CHEST || tile == TL_P_UWCHEST)
  {
    loot_chest(player->y, player->x);
  }
  else if (tile == TL_P_NPC1)
  {
    shop_chef();
  }
  else if (tile == TL_P_NPC3)
  {
    shop_train();
  }
  else if (tile == TL_P_NPC4)
  {
    shop_map();
  }
  else if (tile == TL_P_NPC_ARMOR)
  {
    shop_armor();
  }
  else if (tile == TL_P_NPC_RANGED)
  {
    shop_weapons(1);
  }
  else if (tile == TL_P_NPC_WEAPONS)
  {
    shop_weapons(0);
  }
  else if (tile == TL_P_NPC_CLOSED)
  {
    pwait("SORRY WE ARE CLOSED FOR RENOVATION");
  }
  else if (tile == TL_P_NPC_SCUBA)
  {
    shop_scuba();
  }
  else if (tile == TL_P_NPC_BAR)
  {
    ye_olde_bar();
  }
  else if (tile == TL_P_NPC_SUSHI)
  {
    shop_sushi();
  }
  else if (tile == TL_P_COFFIN)
  {
    stile(player->y, player->x, TL_COFFIN_HL);
    stile(player->y - 1, player->x, TL_VOID);
    stile(player->y - 1, player->x - 1, TL_VOID);
    stile(player->y - 1, player->x + 1, TL_VOID);
    stile(player->y - 2, player->x, TL_VOID);

    if (player->flip)
    {
      stile(player->y, player->x + 4, TL_COFFIN_LID_R);
      stile(player->y - 1, player->x + 3, TL_COFFIN_LID_R);
      stile(player->y - 2, player->x + 2, TL_COFFIN_LID_R);
    }
    else
    {
      stile(player->y, player->x - 4, TL_COFFIN_LID_L);
      stile(player->y - 1, player->x - 3, TL_COFFIN_LID_L);
      stile(player->y - 2, player->x - 2, TL_COFFIN_LID_L);
    }

    strcpy(line, "YOU OPEN THE COFFIN\n\n");

    if (rand() % 5 == 0)
    {
      strcat(line, "A GHOUL ESCAPES!");

      if (rand() % 2 == 0)
	make_monster(player->y, player->x - 5, MOB_GHOUL);
      else
	make_monster(player->y, player->x + 5, MOB_GHOUL);

      draw_board();

      pwait(line);
    }
    else if (rand() % 5 == 0)
    {
      draw_board();
      find_random_armor(line);
    }
    else
    {
      draw_board_norefresh();
      give_item(line, 10 + rand() % COFFIN_GOLD, LOOT_NORMAL);
    }
  }
  else if (tile == TL_P_FOUNTAIN || tile == TL_P_BLOOD_FOUNTAIN)
  {
    fountain();
  }
  else if (tile == TL_P_SWSTONE)
  {
    sword_in_stone();
  }
  else if (tile == TL_P_ORB)
  {
    gaze_orb();
  }
  else if (tile == TL_P_TABLET)
  {
    stone_tablet();
  }
  else if (tile == TL_P_HELL)
  {
    stile(player->y, player->x, TL_VOID);
    pwait("YOU ARE IN HELL");
    draw_board();
  }
  else if (tile == TL_P_PORTAL)
  {
    portal_travel();
  }
  else if (tile == TL_P_IDOL)
  {
    idol();
  }
  else if (tile == TL_P_MUSHROOMS)
  {
    mushrooms();
  }
  else if (tile == TL_P_BOOKSHELF)
  {
    bookshelf();
  }
  else if (tile == TL_P_CAMP)
  {
    if (anything_near())
    {
      pwait("YOU CANNOT REST NOW!\nENEMIES ARE NEAR");
      return false;
    }

    camp();
  }
  else if (tile == TL_P_DISCO)
  {
    if (anything_near())
    {
      pwait("YOU CANNOT DANCE WHILE\nSOMEONE IS WATCHING");
      return false;
    }

    disco();
  }
  else if (tile == TL_P_ALTAR)
  {
    altar();
  }
  else if (tile == TL_P_CORPSE || tile == TL_P_SKELETON)
  {
    if (tile == TL_P_CORPSE)
    {
      stile(player->y, player->x, TL_VOID);
      strcpy(line, "YOU FIND A DECAYING CORPSE\n\n");
    }
    else
    {
      stile(player->y, player->x, TL_VOID);
      strcpy(line, "YOU FIND A LONG-DEAD SKELETON\n\n");
    }

    switch(rand() % 10)
    {
    case 0:
    case 1:
    case 2:
      find_random_armor(line);
      break;

    case 3:
    case 4:
    case 5:
      find_random_weapon(line);
      break;

    default:
      if (tile == TL_P_SKELETON)
	give_item(line, 5 + rand() % 25, LOOT_BONES);
      else
	give_item(line, 5 + rand() % 25, LOOT_NORMAL);
      break;
    }

    //pwait(line);

    return true;
  }

  return true;
}
int main(int argc, char **argv) {
    
    // inicializaçao
	dragging = false;
	dragx = 0; dragy = 0;
	camx = 1;
	camy = 5;
	
	glutInit(&argc, argv);
	ilInit();
	
	glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA);
	glutInitWindowPosition(0,100);
	glutInitWindowSize(1280,800);
	glutCreateWindow("Rock Bar UM");
    
    // registo de funçoes
	glutDisplayFunc(renderScene);
	glutIdleFunc(renderScene);
	glutReshapeFunc(changeSize);
    
    // por aqui registo da funções do teclado e rato
    glutIgnoreKeyRepeat(1);
	glutKeyboardFunc(processNormalKeys);
	glutSpecialFunc(pressKeySpecial);
	glutSpecialUpFunc(releaseKeySpecial);
	glutKeyboardUpFunc(releaseKeyNormal);
    
    // por aqui a criaçao do menu    
    
	
    glewInit();
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
    glEnable(GL_TEXTURE_2D);
    glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    
	//Texturas
	genTextureMadeira();
    genTextureMadeira2();
	genTextureMesa();
	genTextureMetal();
	genTextureVidro();
    genTextureChao();
    genTextureParede();
    genTextureTeto();
    genPoster1();
    genPoster2();
    genPoster3();
    genPoster4();
    genPoster5();
    genPoster6();
    genTextureBook();
    genPoster7();
    genSink();
    
    //Objectos
    mesa();
	cadeira();
	candeeirodemesa();
	candeeirodetecto();
	candeeirodeparede();
	mesalta();
	cadeiralta();
	cup();
	copoalto();
    chao();
    paredes();
    palco();
    balcao();
    armario();
    posters();
    bookshelf();
    
    
    // entrar no ciclo do GLUT
	glutMainLoop();
	
	return 1;
}