Пример #1
0
// Initialize the OpenGL, camera, shader and calls
// geometry-related init-functions.
bool init()
{
  // Activate depth test to discard fragment that are hidden
  glEnable(GL_DEPTH_TEST);

  // Activate anti-aliasing
  glEnable(GL_MULTISAMPLE);

  // Create camera
  gCamera = std::make_shared<ogl::Camera>(gWidth,gHeight);
  gCamera->setPosition(ogl::Vec3f(16,-9,6));
  gCamera->setTarget(ogl::Vec3f(3,3,2));

  // Create Phong shader
  gShaderProgram   = std::make_shared<ogl::ShaderProgram>();
    if(!gShaderProgram->init(
      gDataPath+"assets/SolidWirePhong.vs",
      gDataPath+"assets/SolidWirePhong.gs",
      gDataPath+"assets/SolidWirePhong.fs"))
      return false;

  //Call geometry-related init-functions
  if(!initLightSpheres())
    return false;

  if(!initAxisArrows())
    return false;

  if(!initGroundPlane())
    return false;

  if(!initDice())
    return false;


  return true;
}
Пример #2
0
void gameLoop(struct player players[]){
  int activePlayer = 0;
  int dices[5];
  int selectedSlot, rerollCount;

  initDice();

  do{
    clearScreen();

    rollAllDices(dices);
    rerollCount=0;

    while(rerollCount < 2){
      clearScreen();
      printBoard(players[activePlayer]);

      setColor(GREEN, BLACK);
      printf("\nNumber of re rolls: %i\n\n", rerollCount);
      printDices(dices);

      //User wants to bail early, not using all rerolls
      if(!selectReroll(dices)) break;
      
      rerollCount++;
    }

    clearScreen();
    printDices(dices);

    //The user gets to select a possible slot for his score
    selectedSlot = selectWhereToSave(dices, players[activePlayer]);

    if(selectedSlot != -1){
      //Assign score to the selected slot
      assignScore(&players[activePlayer], dices, selectedSlot);
    }else{
      //If no slots are valid, one has to be elminated
      clearScreen();
      printDices(dices);
      eliminateSlot(&players[activePlayer]);
    }
	
    clearScreen();
    printBoard(players[activePlayer]);

    //Advance to the next player, if all players are done the loop will end
    if(!allPlayersDone(players)){
      do{
	nextPlayersTurn(players, &activePlayer);
      }while(playerDone(players[activePlayer]));

      printf("\n%s it is your turn, press ENTER to play..", players[activePlayer].playername);
      getchar();
    }else{
      break;
    }

  }while(1);

}