Ejemplo n.º 1
0
void MartianEngine::doCredits() {
	_midi->_byte1F781 = false;
	_midi->loadMusic(47, 3);
	_midi->midiPlay();
	_screen->setDisplayScan();
	_events->hideCursor();
	_screen->forceFadeOut();
	Resource *data = _files->loadFile(41, 1);
	_introObjects = new SpriteResource(this, data);
	delete data;

	_files->loadScreen(41, 0);
	_buffer2.copyFrom(*_screen);
	_buffer1.copyFrom(*_screen);
	_events->showCursor();
	_creditsStream = new Common::MemoryReadStream(CREDIT_DATA, 180);

	if (!showCredits()) {
		_screen->copyFrom(_buffer2);
		_screen->forceFadeIn();

		_events->_vbCount = 550;
		while (!shouldQuit() && !_events->isKeyMousePressed() && _events->_vbCount > 0)
			_events->pollEventsAndWait();

		_screen->forceFadeOut();
		while (!shouldQuit() && !_events->isKeyMousePressed()&& !showCredits())
			_events->pollEventsAndWait();

		warning("TODO: Free word_21E2B");
		_midi->freeMusic();
	}
}
Ejemplo n.º 2
0
void MainLoop::start(bool tilesPresent) {
  if (options->getBoolValue(OptionId::MUSIC))
    jukebox->toggle(true);
  splashScreen();
  view->reset();
  if (!tilesPresent)
    view->presentText("", "You are playing a version of KeeperRL without graphical tiles. "
        "Besides lack of graphics and music, this "
        "is the same exact game as the full version. If you'd like to buy the full version, "
        "please visit keeperrl.com.\n \nYou can also get it by donating to any wildlife charity. "
        "More information on the website.");
  int lastIndex = 0;
  while (1) {
    jukebox->setType(MusicType::MAIN, true);
    auto choice = view->chooseFromList("", {
        "Play game", "Change settings", "View high scores", "View credits", "Quit"}, lastIndex, View::MAIN_MENU);
    if (!choice)
      continue;
    lastIndex = *choice;
    switch (*choice) {
      case 0: playGameChoice(); break;
      case 1: options->handle(view, OptionSet::GENERAL); break;
      case 2: highscores->present(view); break;
      case 3: showCredits(dataFreePath + "/credits.txt", view); break;
      case 4: finished = true; break;
    }
    if (finished)
      break;
  }
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
	clrscr();
	showCredits();
	checkUsages(argc);
	openFile2Write(argv[1]);
	readFromFile(argv[1]);
	genCode();
	readData();
	printStatus("DONE",8);
	return 0;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
	clrscr();
	showCredits();
	checkUsages(argc);
	readFromFile(argv[1]);
	genTree();
	openFile2Write(argv[1]);
	genCode();
	closeFile2Write();
	printProc("Closing destination file... ");
	printStatus("DONE",1);
	printf("\n");
	return 0;
}
Ejemplo n.º 5
0
int main(int argc, char** argv) {

  sf::RenderWindow App(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32),
      "Olivier in zombie land");

  App.SetFramerateLimit(60);
  bool game_over = false;

  sf::Image BackgroundImage;
  sf::Sprite BackgroundSprite;

  if(!BackgroundImage.LoadFromFile("../resources/backgrounds/Floor.png")) {
    return EXIT_FAILURE;
  }
  BackgroundSprite.SetImage(BackgroundImage);

  sf::Image predDeathImg;
  sf::Sprite predDeathSprite;
  if(!predDeathImg.LoadFromFile("../resources/sprites/predDeath.png")) {
    return EXIT_FAILURE;
  }
  predDeathSprite.SetImage(predDeathImg);
  predDeathSprite.Resize(predDeathImg.GetWidth() * 2, predDeathImg.GetHeight() * 2);
  predDeathSprite.SetPosition(50, 300);

  std::vector<Object*> objects;

  Player *player = new Player; 
  objects.push_back(player);


  SpatialHash grid;

  sf::Font MyFont;
  if (!MyFont.LoadFromFile("../resources/fonts/comics.ttf", 50)) {
    std::cout << "Fail" << std::endl;
    return EXIT_FAILURE;
  }

  sf::Font megaFont;
  if (!megaFont.LoadFromFile("../resources/fonts/megaman_2.ttf", 50)) {
    std::cout << "Fail megaman font" << std::endl;
    return EXIT_FAILURE;
  }

  sf::String waveText;
  waveText.SetFont(megaFont);
  waveText.SetColor(sf::Color::Red);
  waveText.SetSize(75.f);
  waveText.SetPosition(225, SCREEN_HEIGHT/2 - waveText.GetSize());

  float waveTime = 0;
  int waveNumber = 0;
  bool newWave = true;

  int numBoss = 1;
  int killPerWave = 15;
  int killThisWave = 0;

  sf::String Timer, KillCount, HP, GameOverString, Score;


  Timer.SetFont(MyFont);
  Timer.SetColor(sf::Color(0, 0, 255));
  Timer.SetSize(50.f);
  Timer.SetPosition(SCREEN_WIDTH/2 - Timer.GetSize()/2 - 75, 10.f);

  KillCount.SetFont(MyFont);
  KillCount.SetColor(sf::Color(255, 0, 0));
  KillCount.SetSize(50.f);
  KillCount.SetPosition(SCREEN_WIDTH - 250.f, 10.f);

  HP.SetFont(MyFont);
  HP.SetColor(sf::Color(0, 255, 0));
  HP.SetSize(50.f);
  HP.SetPosition(25.f, 10.f);

  float running_time = 0.0;
  float last_time = 0.0;

  std::srand(std::time(NULL));

  int spawn_rate = 1;
  float spawn_time = 0.0;

  sf::SoundBuffer predBuffer;
  sf::Sound predSound;

  if (!predBuffer.LoadFromFile("../resources/sfx/predator.ogg")) {
    std::cout << "Error loading sfx" << std::endl; 
  }
  predSound.SetBuffer(predBuffer);

  //Title stuff
  Title title(App);

  GameState gameState = INTRO;

  
  //Title loop
  while (App.IsOpened()) {

    //Process events
    sf::Event Event;

    //Window closed
    while (App.GetEvent(Event)) 
    {
      if(Event.Type == sf::Event::Closed)
        App.Close();

      //Escape key pressed
      if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))	
        App.Close();
    }

    if (title.showTitle())
    {
      App.Clear();
      title.update();
      App.Display();
      continue;
    }
    else
    {
      gameState = WAVE;
      break;
    }
  }


  Music::GetInstance().playNormal();

  ParticleSystem particleSystem(SCREEN_WIDTH, SCREEN_HEIGHT);
  particleSystem.setDissolve( true );
  particleSystem.setDissolutionRate( 1 );
	//particleSystem.setGravity(2.0f, 1.2f );

  //Peaking
  Peak peaker(App);

  //Effect
  EffectSystem& effectSystem = EffectSystem::GetInstance();

  //Start game loop
  while (App.IsOpened()) {

    //Process events
    sf::Event Event;

    //Window closed
    while (App.GetEvent(Event)) 
    {
      if(Event.Type == sf::Event::Closed)
        App.Close();

      //Escape key pressed
      if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))	
        App.Close();

      if(Event.Key.Code == sf::Key::F1) {

        sf::Image Screen = App.Capture();
        Screen.SaveToFile("../screenshots/screenshot.jpg");
      }      
    }

    if (player->getHealth() > 0)
    {
        float ElapsedTime = App.GetFrameTime();
        running_time += ElapsedTime;


        switch (gameState)
        {
            case INTRO:
                break;
            case WAVE:
            {
                if (newWave)
                {
                  waveNumber++;
                  waveTime = running_time;
                  newWave = false;

                  std::stringstream wave;
                  wave << waveNumber;
                  waveText.SetText("Wave " + wave.str());

                  killPerWave += 10 * waveNumber;
                  killThisWave = 0;
                }

                if (killThisWave > killPerWave && gameState == WAVE)
                {
                    gameState = BOSS;

                    //Create Boss
                    for (int i = 0; i < numBoss; i++) {
                      objects.push_back(new Boss(particleSystem, sf::Randomizer::Random(200, 600), sf::Randomizer::Random(200, 500), 40));
                    }

                    newWave = true;
                    if (!player->isRageMode())
                    {
                      Music::GetInstance().stop();
                      Music::GetInstance().playBoss();
                    }
                    break;
                }

                if (!player->isRageMode() && Music::GetInstance().getSong() != "dark_encounter.ogg")
                {
                  Music::GetInstance().stop();
                  Music::GetInstance().playNormal();
                }

                //Increase spawn rate every 30 seconds
                if (running_time - spawn_time > 30) {
                    spawn_rate++;
                    spawn_time = running_time;
                }

                //Spawn Enemy every 2 seconds
                if (running_time - last_time > 2.0) {
                    for (int i = 0; i < spawn_rate; i++) {

                    objects.push_back(new Enemy(particleSystem, rand() % (SCREEN_WIDTH-100) + 40, rand() % (SCREEN_HEIGHT-100) + 40));
                    }
                    last_time = running_time;
                }

                grid.setup(objects);

                //Get elapsed time

                //Handle input
                player->handleInput(App, ElapsedTime, objects, grid);

                App.Draw(BackgroundSprite);

                //Draw body part over floor
                effectSystem.drawBg(App);

                drawScore(App, player, KillCount, Timer, HP, Score, static_cast<int> (running_time));

                player->update(App);
                player->draw(App);

                //Move and draw all object (except bullets)
                for (unsigned int i = 0; i < objects.size(); ++i) {

                    //Aggro is only for enemy
                    objects[i]->aggro(*player, ElapsedTime, objects, grid.getNearby(objects[i]), running_time);

                    //Don't draw player here
                    if (!objects[i]->isPlayer())
                    App.Draw(objects[i]->getSprite());
                }

                //Draw then move bullets
                for(unsigned int i = 0; i < player->bullets.size(); ++i) {
                    App.Draw(player->bullets[i]->getSprite());
                    player->bullets[i]->move(ElapsedTime, objects, grid.getNearby(player->bullets[i]), player->bullets, i);
                    //player->bullets[i]->drawEdge(App);
                }

                //Check if player kill a zombie
                for(unsigned int i = 0; i < objects.size(); ++i) {
                    if (!objects[i]->alive(objects, i, running_time))
                    {
                        player->addKill();
                        killThisWave++;
                    }
                }

                break;
            }
            case BOSS:
                if (newWave)
                {
                  waveTime = running_time;
                  newWave = false;
                  waveText.SetText("BOSS");
                }

                if (!player->isRageMode() && Music::GetInstance().getSong() != "vbogey.ogg")
                {
                  Music::GetInstance().stop();
                  Music::GetInstance().playBoss();
                }

                grid.setup(objects);

                //Handle input
                player->handleInput(App, ElapsedTime, objects, grid);

                App.Draw(BackgroundSprite);

                //Draw body part over floor
                effectSystem.drawBg(App);

                drawScore(App, player, KillCount, Timer, HP, Score, static_cast<int> (running_time));

                player->update(App);
                player->draw(App);

                //Move and draw all object (except bullets)
                for (unsigned int i = 0; i < objects.size(); ++i) {

                    //Aggro is only for enemy
                    objects[i]->aggro(*player, ElapsedTime, objects, grid.getNearby(objects[i]), running_time);

                    //Don't draw player here
                    if (!objects[i]->isPlayer())
                    App.Draw(objects[i]->getSprite());
                }

                //Draw then move bullets
                for(unsigned int i = 0; i < player->bullets.size(); ++i) {
                    App.Draw(player->bullets[i]->getSprite());
                    player->bullets[i]->move(ElapsedTime, objects, grid.getNearby(player->bullets[i]), player->bullets, i);
                    //player->bullets[i]->drawEdge(App);
                }
                
                //Check if player kill a zombie
                for(unsigned int i = 0; i < objects.size(); ++i) {
                    if (!objects[i]->alive(objects, i, running_time))
                    {
                        player->addKill();
                    }
                }

                //if objects contain only player
                if (objects.size() == 1)
                {
                  gameState = WAVE;
                  newWave = true;

                  //Increase number of Boss every 5 waves
                  if (waveNumber % 5 == 0)
                  {
                    numBoss++;
                  }
                  if (!player->isRageMode())
                  {
                    Music::GetInstance().stop();
                    Music::GetInstance().playNormal();
                  }
                }

                break;
        }

        grid.clear();

        particleSystem.remove();
        particleSystem.update();
        particleSystem.render();

        effectSystem.update(App.GetFrameTime());
        effectSystem.draw(App);

        App.Draw(particleSystem.getSprite());

        //Peaking
        peaker.update();

        if (running_time - waveTime <= 1.5)
        {
          App.Draw(waveText);
        }

        //Diplay window contents on screen
        App.Display();
    }

    //Dead
    else
    {
      if (player->playDeath(App))
      {
        App.Display();
      }
      else if (game_over)  {
        App.Clear();
        App.Draw(predDeathSprite);
        App.Draw(GameOverString);
        App.Draw(Timer);
        App.Draw(KillCount);
        App.Draw(Score);
        App.Display();
      }

      else {
        game_over = true;
        Music::GetInstance().stop();

        //play game over song
        Music::GetInstance().playGameOver();

        //Stay there until credit end
        showCredits(App);

        GameOverString.SetFont(MyFont);
        GameOverString.SetColor(sf::Color(255, 255, 0));
        GameOverString.SetSize(100.f);
        GameOverString.SetPosition(SCREEN_WIDTH/2 -
            GameOverString.GetSize()/2 - 225,
            SCREEN_HEIGHT/2 - 200);

        GameOverString.SetText("Game Over");

        Timer.SetFont(MyFont);
        Timer.SetColor(sf::Color(255, 255, 0));
        Timer.SetSize(50.f);
        Timer.SetPosition(SCREEN_WIDTH/2 - Timer.GetSize()/2 - 75,
            SCREEN_HEIGHT/2);

        KillCount.SetFont(MyFont);
        KillCount.SetColor(sf::Color(255, 255, 0));
        KillCount.SetSize(50.f);
        KillCount.SetPosition(SCREEN_WIDTH/2 - KillCount.GetSize()/2 - 80,
            SCREEN_HEIGHT/2 + 100);

        Score.SetFont(MyFont);
        Score.SetColor(sf::Color(255, 255, 0));
        Score.SetSize(50.f);

        Score.SetPosition(SCREEN_WIDTH/2 - KillCount.GetSize()/2 - 80,
            SCREEN_HEIGHT/2 + 200);

        Music::GetInstance().stop();
        predSound.Play();
      }    
    }
  }
  return 0;      
}
Ejemplo n.º 6
0
void settings_frame::OnMenuChoice(wxCommandEvent& event) {
	switch (event.GetId()) {
		case ID_MENUITEM_SAVE:
			if (saveSettingsAbstract())
			 (abstract_panel::settingsChanged) = false;
			if (simpleTab!=0)
        			simpleTab->saveCbxChoices();
		 break;

		case ID_MENUITEM_QUIT:
				handleExit();
		 break;

		case ID_MENUITEM_RESET:
			if ((customMessageBox(SS_MAIN_ICON,_("Reset ALL settings to default values?"), _("Confirmation needed"), wxYES_NO)) == wxYES) {
						resetSettings();
			}
		 break;

		case ID_MENUITEM_SIMPLE:
			if (sett().getMode()==SET_MODE_EXPERT)
			{
				sett().setMode(SET_MODE_SIMPLE);

				simpleTab = new tab_simple(this,notebook,ID_SIMPLE);
				notebook->InsertPage(0,simpleTab,simpleTabCap);
				simpleTab->updateControls(UPDATE_ALL);

				//if not on ui page goto simple
				if (notebook->GetSelection()!=1)
					notebook->SetSelection(0);

				notebook->DeletePage(5);
				notebook->DeletePage(4);
				notebook->DeletePage(3);
				notebook->DeletePage(2);
				qualityTab = 0;
				detailTab = 0;
				audioTab = 0;
//				hotkeyTab = 0;
				SetTitle(GetAppName() + _("(simple mode)"));
				if (!sett().getDisableWarning()){
					customMessageBox(SS_MAIN_ICON,expertModeWarning, _("Hint"), wxOK);
				}
			}
		  break;

		case ID_MENUITEM_EXPERT:
			if (sett().getMode()==SET_MODE_SIMPLE) {
				switchToExpertMode();
			}
			break;
		case ID_MENUITEM_DISABLE_WARN:
			sett().setDisableWarning(menuFile->IsChecked(ID_MENUITEM_DISABLE_WARN));
			break;

		case ID_MENUITEM_ABOUT:
			showAbout();
			break;
		case ID_MENUITEM_CREDITS:
			showCredits();
			break;
		case ID_MENUITEM_CONTACT:
			openContactPage();
			break;
		case ID_MENUITEM_BUGREPORT:
			openNewTicket();
			break;
	}
}