예제 #1
0
파일: main.cpp 프로젝트: raffathamires/cg1
int main(void)
{
    int argc = 0;
    char *argv[] = { (char *)"gl", 0 };

    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(1000,700);
    glutInitWindowPosition(80,80);
    glutCreateWindow("Creepy Cat");
    glutSpecialFunc(special);
    glutKeyboardFunc(keyboard);
    glutDisplayFunc(Display);
    glViewport(0, 0, 1000, 700);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, (double)1000 / (double)700, 1, 1000.0);

    newTeaPot();
    moveCat(0);

    PlaySound("Psicose.wav", NULL, SND_ASYNC|SND_FILENAME);

    Initialize();
    glutMainLoop();
}
예제 #2
0
/*!
  Performs an update of the game state a few times a second.
  This is primarily for updating cat movement/location, but also
  handles stuff like advancing the score.
*/
bool Rodent::update() {
  bool all_frozen = true;
  
  cat_list::iterator iter;
  for (iter = the_cats.begin();
       iter != the_cats.end();
       ++iter) {
    switch (moveCat(iter->first, iter->second)) {
    case frozen:
      setBlockAt(iter->first, iter->second, frozen_cat);
      break;
    case killed_mouse:
      std::cout << "Game over!\n";
      all_frozen = false;
      return false;
      break;
    case cat_moved:
      setBlockAt(iter->first, iter->second, cat);
      all_frozen = false;
      break;
    default:
      std::cout << "I dunno! lol\n";
    }
  }

  // All cats frozen, so convert them to cheese.
  if (all_frozen) {
    for (iter = the_cats.begin();
	 iter != the_cats.end();
	 ++iter) {
      setBlockAt(iter->first, iter->second, cheese);
    }
    catsRemaining -= the_cats.size();
    the_cats.clear();

    // If there are more cats for this level, add them
    // Otherwise the level is over, so generate the next level
    if (catsRemaining) {
      addCat();
      updatesTillNextCat = updatesBetweenCats;
    } else {
      catsRemaining = catsPerLevel;
      cur_level++;
      genLevel();
    }
  }
  // Player is too slow, add a penguin
  --updatesTillNextCat;
  if (updatesTillNextCat==0) {
    updatesTillNextCat = updatesBetweenCats;
    if (catsRemaining>the_cats.size()) {
      addCat();
    }
  }
  return true;
}