Пример #1
0
void Game::Start(void)
{
	if(_gameState != Uninitialized)
		return;
	
	_mainWindow.Create(sf::VideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,32),"Test Game");
	
	_mainWindow.SetFramerateLimit(60);

	_mainWindow.Clear(sf::Color(0,0,0));

	Player *player1 = new Player();
	player1->SetPosition((SCREEN_WIDTH/2),(SCREEN_HEIGHT/2));
	
	_gameObjectManager.Add("Player",player1);

	_gameState= Game::Playing;


	while(!IsExiting())
	{
		GameLoop();
	}

	_mainWindow.Close();
}
Пример #2
0
void Game::Start()
{
    if (_gameState != UNITIALIZED) return;

    _mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Platformer Proto 01");
    _mainWindow.setKeyRepeatEnabled(false);
    _frameSpeed = 30.0f;
    _gameState = PLAYING;

    // set up test tiles
    //Tile *newTile = new Tile("Resources/Textures/green.jpg", true);
    //newTile->Load("Resources/Textures/green.jpg");
    //_gameObjectManager.Add("Green Tile", newTile);
    _levelManager.Load("Resources/Maps/Level_Map_1.txt");




    // main loop
    while (!IsExiting())
    {
        GameLoop();
    }
    _mainWindow.close();
} // end Start
Пример #3
0
// Set everything up
void Game::Start()
{
	_mainWindow.create(sf::VideoMode(800, 600), "Just. One. Second.");

	_gameMusic.openFromFile("audio/music/horrible.wav");
	_gameMusic.setLoop(true);	// so sorry
	_gameMusic.setVolume(15);
	_gameMusic.play();

	_outline.setFillColor(sf::Color::Transparent);
	_outline.setSize(sf::Vector2f(790, 590));
	_outline.setPosition(5, 5);
	_outline.setOutlineThickness(5);

	sf::Clock clock;
	sf::Time elapsed;

	while (!IsExiting())
	{
		elapsed = clock.restart();

		_mainWindow.clear();
		Update(elapsed.asSeconds());
		_mainWindow.draw(_outline);
		_mainWindow.display();
	}
}
Пример #4
0
void Game::Start(void)
{
	if (_gameState != Uninitialized)
	{
		std::cout << "_gameState already initialized. Do not call Game::Start() more than one time!" << std::endl;
		return;
	}

	_mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Pang!");

	PlayerPaddle *player1 = new PlayerPaddle();
	player1->SetPosition((SCREEN_WIDTH / 2), 700);

	GameBall *ball = new GameBall();
	ball->SetPosition((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - 15);

	_gameObjectManager.Add("Paddle1", player1);
	_gameObjectManager.Add("Ball", ball);

	_gameState = Game::ShowingSplash;

	while (!IsExiting())
	{
		GameLoop();
	}

	_mainWindow.close();
}
Пример #5
0
void Game::Start()
{
    if (_gameState != Uninitialized)
        return;

    _mainWindow.create(sf::VideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,32),"BananaGame");
    _gameState = ShowingSplash;


    PlayerPaddle* pl1 = new PlayerPaddle();
    pl1->SetPosition(SCREEN_WIDTH/2,530);
     PlayerPaddle* pl2 = new PlayerPaddle();
    pl2->SetPosition(SCREEN_WIDTH/2,50);

    AIPaddle* comp = new  AIPaddle();
    comp->SetPosition(SCREEN_WIDTH/2,50);


    GameBall* ball = new GameBall();
    ball->SetPosition(SCREEN_WIDTH/2,SCREEN_HEIGHT/2);

    _gameObjectManager.Add("Player1",pl1);
 //  _gameObjectManager.Add("Player2",pl2);
    _gameObjectManager.Add("Comp",comp);
    _gameObjectManager.Add("Ball",ball);

    while (!IsExiting()) {
        GameLoop();
    }
    _mainWindow.close();
}
Пример #6
0
void Game::Start()
{
  if(m_gameState != eUninitalized)
    return; // should throw some error

  m_mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Pang!");
	m_mainWindow.setVerticalSyncEnabled(true);
	// m_mainWindow.setFramerateLimit(60); // FPS to 60

	// create a player paddle
	std::shared_ptr<PlayerPaddle> player1 = std::shared_ptr<PlayerPaddle>(new PlayerPaddle());
	player1->SetPosition((SCREEN_WIDTH/2)-45, 700);
	m_gameObjectManager.Add("Paddle1", player1);

	// create a ball
	std::shared_ptr<GameBall> ball = std::shared_ptr<GameBall>(new GameBall());
	ball->SetPosition(SCREEN_WIDTH /2, (SCREEN_HEIGHT/ 2) -15);
	m_gameObjectManager.Add("Ball", ball);

  // first thing to do is to display the splash screen
  m_gameState = eShowingSplash;

	// load player 1 paddle
  player1->Load("Resources\\images\\paddle.png");
  player1->SetPosition((1024/2)-45,700);

  while(!IsExiting())
  {
    GameLoopIteration();
  }

  m_mainWindow.close();
}
Пример #7
0
void Game::Start(void) {
    if(_gameState!=Uninitialized)
        return;
    _gameState=ShowingSplash;
    while(!IsExiting()) {
        GameLoop();
    }
}
void Game::Start(void)
{
  if(_gameState != Uninitialized)
    return;

  _mainWindow.Create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32),"Paint Wars!");

  SFMLSoundProvider soundProvider;
  ServiceLocator::RegisterAudioService(&soundProvider);

  ServiceLocator::GetAudio()->PlaySong("assets/NewSoundtrack.ogg",true);

  PlayerShip *player1 = new PlayerShip();
  player1->SetPosition(SCREEN_WIDTH/2, _gameField.Bottom - 40);
  _gameObjectManager.Add("Ship1", player1);
  Laser *laser1 = new Laser();
  laser1->SetPosition(Game::SCREEN_WIDTH / 2, Game::SCREEN_HEIGHT + 100);
  _gameObjectManager.Add("Laser1", laser1);
   AIShip *enemy1 = new AIShip();
   enemy1->SetPosition(SCREEN_WIDTH/2, _gameField.Top);
   _gameObjectManager.Add("Enemy1", enemy1);
   AIShip *enemy2 = new AIShip();
   enemy2->SetPosition(SCREEN_WIDTH/2, _gameField.Top);
   _gameObjectManager.Add("Enemy2", enemy2);
   AIShip *enemy3 = new AIShip();
   enemy3->SetPosition(SCREEN_WIDTH/2, _gameField.Top);
   _gameObjectManager.Add("Enemy3", enemy3);
   AILaser *ailaser1 = new AILaser();
   ailaser1->SetPosition(SCREEN_WIDTH/2, _gameField.Top - 100);
   _gameObjectManager.Add("AILaser1", ailaser1);
   AILaser2 *ailaser2 = new AILaser2();
   ailaser2->SetPosition(SCREEN_WIDTH/2, _gameField.Top - 100);
   _gameObjectManager.Add("AILaser2", ailaser2);
   AILaser3 *ailaser3 = new AILaser3();
   ailaser3->SetPosition(SCREEN_WIDTH/2, _gameField.Top - 100);
   _gameObjectManager.Add("AILaser3", ailaser3);
   Boss *boss = new Boss();
   boss->SetPosition(SCREEN_WIDTH/2, _gameField.Top - 100);
   _gameObjectManager.Add("Boss", boss);
   BossLaser *bosslaser = new BossLaser();
   bosslaser->SetPosition(SCREEN_WIDTH/2, _gameField.Top - 100);
   _gameObjectManager.Add("BossLaser",bosslaser);
   WeaponPowerUp *weaponpowerup = new WeaponPowerUp();
    weaponpowerup->SetPosition(SCREEN_WIDTH/2, _gameField.Top - 100);
   _gameObjectManager.Add("WeaponPowerUp",weaponpowerup);
    ShieldPowerUp *shieldpowerup = new ShieldPowerUp();
    shieldpowerup->SetPosition(SCREEN_WIDTH/2, _gameField.Top - 100);
   _gameObjectManager.Add("ShieldPowerUp",shieldpowerup);
   
   _gameState = Game::ShowingSplash;

  while(!IsExiting())
  {
    GameLoop();
  }

  _mainWindow.Close();
}
int DeviceManagerThread::Run()
{
    ThreadCommand::PopBuffer command;

    SetThreadName("OVR::DeviceManagerThread");
    LogText("OVR::DeviceManagerThread - running (ThreadId=%p).\n", GetThreadId());
    

    while(!IsExiting())
    {
        // PopCommand will reset event on empty queue.
        if (PopCommand(&command))
        {
            command.Execute();
        }
        else
        {
            bool commands = 0;
            do
            {
                int n = poll(&PollFds[0], PollFds.GetSize(), -1);

                for (int i = 0; i < PollFds.GetSize(); i++)
                {
                    if (PollFds[i].revents & POLLERR)
                    {
                        OVR_DEBUG_LOG(("poll: error on [%d]: %d", i, PollFds[i].fd));
                    }
                    else if (PollFds[i].revents & POLLIN)
                    {
                        if (FdNotifiers[i])
                            FdNotifiers[i]->OnEvent(i, PollFds[i].fd);
                        else if (i == 0) // command
                        {
                            char dummy[128];                            
                            read(PollFds[i].fd, dummy, 128);
                            commands = 1;
                        }
                    }

                    if (PollFds[i].revents & POLLHUP)
                        PollFds[i].events = 0;

                    if (PollFds[i].revents != 0)
                    {
                        n--;
                        if (n == 0)
                            break;
                    }
                }                    
            } while (PollFds.GetSize() > 0 && !commands);
        }
    }

    LogText("OVR::DeviceManagerThread - exiting (ThreadId=%p).\n", GetThreadId());
    return 0;
}
Пример #10
0
void Game::Start()
{

	renderWindow.create(sf::VideoMode(800, 480), "Pong Clone", sf::Style::Fullscreen);
	gameState = Game::ScreenSplash;

	while (!IsExiting()) {
		GameLoop();
	}

	renderWindow.close();
}
Пример #11
0
void Game::Start(void)
{
	if(_gameState != Uninitialized)
		return;

	_mainWindow.create(sf::VideoMode(1024, 768, 32), "DOVEngine");
	_gameState = Game::Playing;

	while(!IsExiting())
	{
		GameLoop();
	}

	_mainWindow.close();
}
Пример #12
0
void Game::Start(void)
{
    if(m_gameState != Uninitialized)
        return;
    
    m_mainWindow.create(sf::VideoMode(1024,768,32),"Pang!");
    
    m_gameState = Game::ShowingSplash;

    while(!IsExiting())
    {
        GameLoop();
    }

    m_mainWindow.close();
}
Пример #13
0
void Game::Start()
{
	if(_gameState != Uninitialized)
		return;
	
	_mainWindow.create(sf::VideoMode(1024,700,32),"Game!"/*, sf::Style::Fullscreen*/);

	_gameState= Game::ShowingSplash;

	while(!IsExiting())
	{
		GameLoop();
	}

	_mainWindow.close();
}
void Game::Start(void)
{
  if(_gameState != Uninitialized)
    return;

  _mainWindow.Create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32),"La tour de défense");
  _field.Load("example.txt");
  _gameState = Game::ShowingSplash;
  
  while(!IsExiting())
  {
    GameLoop();
  }

  _mainWindow.Close();
}
Пример #15
0
void Game::Start()
{
  if (m_gameState != GameState::Uninitialized)
  {
    return;
  }

  m_mainWindow = new Window("Game Title", sf::Vector2i(1228, 768), false);
  m_mainWindow->GetRenderWindow()->setIcon(sfml_icon.width, sfml_icon.height, sfml_icon.pixel_data);

#ifndef NDEBUG
  OutputLog::GetInstance().Initialise();
#endif

  m_gameState = GameState::Playing;

  // Load files
  ResourceLoader::GetInstance().LoadFonts();
  ResourceLoader::GetInstance().LoadSoundEffects();
  ResourceLoader::GetInstance().LoadTextures();
  ResourceLoader::GetInstance().LoadStyles();

  // Add Scenes
  m_SceneManager.AddScene("SplashScreen", new SSplash());

  m_SceneManager.AddScene("DefaultScene", new SDefault());

  OutputLog::GetInstance().AddLine("Starting...", MessageType::MESSAGE);

  GameObject* defaultCamera = ObjectFactory::GetInstance().Spawn("DefaultCamera");

  m_mainWindow->AddCamera(defaultCamera);

  // Set the initial scene
  m_SceneManager.SetScene("SplashScreen");

  // While the game is not exiting run the game loop
  while (!IsExiting())
  {
    GameLoop();
  }

  delete m_mainWindow;
}
//Game::Start() is global and shouldnt be called more than once
void Game::Start(void)
{
	/*"Uninitialized" is default value, when game created it will start
	uninitialized which is useless*/
	if(_gamestate != Uninitialized)
		return

	// VideoMode(Resoultion(1024x768),32bpp color),"Title"
	_mainWindow.Create(sd::VideoMode(1024,768,32),"Pong!");
	//switching game to playin state
	_gameState = Game::Playing;

	while(!IsExiting())
	{
	GameLoop();
	}

	_mainWindow.Close();
}
Пример #17
0
void Game::Start() {

	if(_gameState != Uninitialized)
		return;

	gameClock.restart();
	canFire = true;

	_mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "The Good...");

	_gameState = Game::Playing;
	
	_mainView.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
	_mainView.setCenter(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
	_mainWindow.setView(_mainView);
	_mainWindow.setKeyRepeatEnabled(false);

	 
	Player* player1 = new Player();
	player1 ->SetPosition(20.0, 620.0f);

	Floor* floor = new Floor(); 
	floor ->SetPosition(0, 720.0f);

	Floor* floor2 = new Floor();
	floor2 ->SetPosition(120.0, 670.0);

	 fire_speed = 0.5f;


	_gameObjectManager.Add("Player", player1);
	_gameObjectManager.Add("floor", floor);
//	_gameObjectManager.Add("floor2", floor2);

	while(!IsExiting()){
		GameLoop();
	}

	_mainWindow.close();
	

	Game::GameLoop();
}
Пример #18
0
void Game::Start(void)
{
		player1score = 0;
	player2score = 0;
	SetVariables();

	//We check that the game state is uninitialized so that we do not call it more than once.
	if(_gameState != Uninitialized)//Throwing an error would be proper
		return;

	_mainWindow.create(sf::VideoMode(SCREEN_LENGTH,SCREEN_HEIGHT,32),"Pang!");//Creates the resolutions, 32bpp color, and title.
	_gameState= Game::ShowingSplash;//Title screen

	while(!IsExiting())//While the game is in play mode, we run the gameloop.
	{
		GameLoop();//repeats as long as we're not in exit mode.
	}

	_mainWindow.close();//Closes the window when not in play mode.
}
Пример #19
0
void Game::Start() {
	if (_gameState != Uninitialized) 
		return;
	_mainWindow.create(sf::VideoMode(1280, 720), "BIT GAME");
	_mainWindow.setIcon(BitGameIcon.width, BitGameIcon.height, BitGameIcon.pixel_data);

	//_p1.load("Images/Player.png");
	_p1.setPosition(1280/2, 720/2);
	_p1.setOrigin(25, 45);
	_p1.setFillColor(sf::Color(0,0,255,255));
	_p1.setRadius(10.f);

	_gameState = Game::ShowingSplash;

	while (!IsExiting()) {
		GameLoop();
	}

	_mainWindow.close();
}
Пример #20
0
int DeviceManagerThread::Run()
{
    ThreadCommand::PopBuffer command;

    SetThreadName("OVR::DeviceManagerThread");
    LogText("OVR::DeviceManagerThread - running (ThreadId=%p).\n", GetThreadId());
    
    // Signal to the parent thread that initialization has finished.
    StartupEvent.SetEvent();

    while(!IsExiting())
    {
        // PopCommand will reset event on empty queue.
        if (PopCommand(&command))
        {
            command.Execute();
        }
        else
        {
            bool commands = 0;
            do
            {
                int waitMs = -1;

                // If devices have time-dependent logic registered, get the longest wait
                // allowed based on current ticks.
                if (!TicksNotifiers.IsEmpty())
                {
                    UInt64 ticksMks = Timer::GetTicks();
                    int  waitAllowed;

                    for (UPInt j = 0; j < TicksNotifiers.GetSize(); j++)
                    {
                        waitAllowed = (int)(TicksNotifiers[j]->OnTicks(ticksMks) / Timer::MksPerMs);
                        if (waitAllowed < waitMs)
                            waitMs = waitAllowed;
                    }
                }

                // wait until there is data available on one of the devices or the timeout expires
                int n = poll(&PollFds[0], PollFds.GetSize(), waitMs);

                if (n > 0)
                {
                    // Iterate backwards through the list so the ordering will not be
                    // affected if the called object gets removed during the callback
                    // Also, the HID data streams are located toward the back of the list
                    // and servicing them first will allow a disconnect to be handled
                    // and cleaned directly at the device first instead of the general HID monitor
                    for (int i=PollFds.GetSize()-1; i>=0; i--)
                    {
                        if (PollFds[i].revents & POLLERR)
                        {
                            OVR_DEBUG_LOG(("poll: error on [%d]: %d", i, PollFds[i].fd));
                        }
                        else if (PollFds[i].revents & POLLIN)
                        {
                            if (FdNotifiers[i])
                                FdNotifiers[i]->OnEvent(i, PollFds[i].fd);
                            else if (i == 0) // command
                            {
                                char dummy[128];
                                read(PollFds[i].fd, dummy, 128);
                                commands = 1;
                            }
                        }

                        if (PollFds[i].revents & POLLHUP)
                            PollFds[i].events = 0;

                        if (PollFds[i].revents != 0)
                        {
                            n--;
                            if (n == 0)
                                break;
                        }
                    }
                }
            } while (PollFds.GetSize() > 0 && !commands);
        }
    }

    LogText("OVR::DeviceManagerThread - exiting (ThreadId=%p).\n", GetThreadId());
    return 0;
}
Пример #21
0
void Game::Start() {

    if(_gameState != Uninitialized) {
        return;
    }

    /* Initialize all prototype arrays and game objects */

    /* Load resources and xml files */
    ConstructResources();   // load all files into memory
    ConstructPrototypes();  // construct entity prototypes (from xml raw files)

    _gameState = Playing;
    _inventoryConsole = NULL;
    _inventoryInfo = NULL;
    Turns = 0;

    // Initialize player:
    player.cam_follow = true;
    player.speed = 100.0f;
    player.viewinginventory = false;

    player.Message("Have a secure day!", TCODColor::green, TCODColor::black);

    GameMap.Initialize(100, 100, getTurf("t_wall"), this);
    RandomGen = new TCODRandom();


    const char* smap[] = {
		"##############################################",
		"#######################      #################",
		"#####################    #     ###############",
		"######################  ###        ###########",
		"##################      #####             ####",
		"################       ########    ###### ####",
		"###############      #################### ####",
		"################    ######                  ##",
		"########   #######  ######   #     #     #  ##",
		"########   ######      ###                  ##",
		"########                                    ##",
		"####       ######      ###   #     #     #  ##",
		"#### ###   ########## ####                  ##",
		"#### ###   ##########   ########### ##########",
		"#### ##################   #####          #####",
		"#### ###             #### #####          #####",
		"####           #     ####                #####",
		"########       #     #### #####          #####",
		"########       #####      #######      #######",
		"#########++ ++####################++++########",
		"##                                          ##",
		"#                                            #",
		"#                                      g     #",
		"#                                     g g    #",
		"#       M                                    #",
		"#                        @                   #",
		"#                                      g     #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                S                           #",
		"#              S S S                         #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#   //////////////////// /  //////////////// #",
		"#                    /   /      [            #",
		"#                       / ?                  #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#                                            #",
		"#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#",
		"##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##",
		"##############################################",


	};
    for (int y=0; y < 54; y++ ) {
        for (int x=0; x < 46; x++ ) {
            if ( smap[y][x] == '#' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_wall"));
            }
            else if ( smap[y][x] == '~' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_water"));
            }
            else if ( smap[y][x] == 'g' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnMob(x, y, getMob("m_goat"));
            }
            else if ( smap[y][x] == 'M' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnMob(x, y, getMob("m_kelrah"));
            }
            else if ( smap[y][x] == 'S' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnMob(x, y, getMob("m_skeleton"));
            }
            else if ( smap[y][x] == '+' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_window"));
            }
            else if ( smap[y][x] == '@' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.InsertMob(x, y, &player);
                player.x = x;
                player.y = y;
                player.cam_x = player.x;
                player.cam_y = player.y;
            }
            else if ( smap[y][x] == '/' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnItem(x, y, getItem("i_shortsword"));
            }
            else if ( smap[y][x] == '[' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnItem(x, y, getItem("i_backpack"));
            }
            else if ( smap[y][x] == '?' ) {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
                GameMap.SpawnItem(x, y, getItem("i_flail"));
            }
            else {
                GameMap.SpawnTurf(x, y, getTurf("t_grass"));
            }
        }
    }
    Test = "Lol!";

    // Initialize TCOD
    //TCODConsole::setCustomFont("terminal12x12.png", TCOD_FONT_LAYOUT_ASCII_INROW);
    TCODConsole::initRoot(VIEW_WIDTH, VIEW_HEIGHT, "Origin: Tales of Anarchy", false);
    TCODSystem::setFps(15);
    TCODConsole::setKeyboardRepeat(30, 5);

    DrawHud(true);

    std::cout << "Game Started" << std::endl << std::endl;
    LoadGame();

    while(!IsExiting()) {
        GameLoop();
    }
    SaveGame();
}
Пример #22
0
void Game::Start()
{
	if (_gameState != Uninitialized)
		return;

	_mainWindow.create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32), "Map Maker");
	_mainWindow.setFramerateLimit(60);

	int level[] =
    {
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    };

	const int MAPWIDTH = 20;
	const int MAPHEIGHT = 20;
	const std::string tileset = "images/tileset2.png";

	Map* board = new Map(tileset, sf::Vector2i(16, 16), "maps/4.txt", MAPWIDTH, MAPHEIGHT);
	TextureBar* bar = new TextureBar("images/texturebar.png", tileset, MAPWIDTH, MAPHEIGHT);

	Initialize("Map", board, 0, 0);
	Initialize("Texture Bar", bar, 0, 800);

	LoadFonts();

	_gameState = Playing;

	while (!IsExiting())
	{
		GameLoop();
	}

	_mainWindow.close();
}
Пример #23
0
int DeviceManagerThread::Run()
{

    SetThreadName("OVR::DeviceManagerThread");
    LogText("OVR::DeviceManagerThread - running (ThreadId=0x%p).\n", GetThreadId());

    // Store out the run loop ref.
    RunLoop = CFRunLoopGetCurrent();

    // Create a 'source' to enable us to signal the run loop to process the command queue.
    CFRunLoopSourceContext sourceContext;
    memset(&sourceContext, 0, sizeof(sourceContext));
    sourceContext.version = 0;
    sourceContext.info = this;
    sourceContext.perform = &staticCommandQueueSourceCallback;

    CommandQueueSource = CFRunLoopSourceCreate(kCFAllocatorDefault, 0 , &sourceContext);

    CFRunLoopAddSource(RunLoop, CommandQueueSource, kCFRunLoopDefaultMode);


    // Signal to the parent thread that initialization has finished.
    StartupEvent.SetEvent();


    ThreadCommand::PopBuffer command;
   
    while(!IsExiting())
    {
        // PopCommand will reset event on empty queue.
        if (PopCommand(&command))
        {
            command.Execute();
        }
        else
        {
            SInt32 exitReason = 0;
            do {

                UInt32 waitMs = INT_MAX;

                // If devices have time-dependent logic registered, get the longest wait
                // allowed based on current ticks.
                if (!TicksNotifiers.IsEmpty())
                {
                    UInt64 ticksMks = Timer::GetTicks();
                    UInt32  waitAllowed;

                    for (UPInt j = 0; j < TicksNotifiers.GetSize(); j++)
                    {
                        waitAllowed = (UInt32)(TicksNotifiers[j]->OnTicks(ticksMks) / Timer::MksPerMs);
                        if (waitAllowed < waitMs)
                            waitMs = waitAllowed;
                    }
                }
                
                // Enter blocking run loop. We may continue until we timeout in which
                // case it's time to service the ticks. Or if commands arrive in the command
                // queue then the source callback will call 'CFRunLoopStop' causing this
                // to return.
                CFTimeInterval blockInterval = 0.001 * (double) waitMs;
                exitReason = CFRunLoopRunInMode(kCFRunLoopDefaultMode, blockInterval, false);

                if (exitReason == kCFRunLoopRunFinished)
                {
                    // Maybe this will occur during shutdown?
                    break;
                }
                else if (exitReason == kCFRunLoopRunStopped )
                {
                    // Commands need processing or we're being shutdown.
                    break;
                }
                else if (exitReason == kCFRunLoopRunTimedOut)
                {
                    // Timed out so that we can service our ticks callbacks.
                    continue;
                }
                else if (exitReason == kCFRunLoopRunHandledSource)
                {
                    // Should never occur since the last param when we call
                    // 'CFRunLoopRunInMode' is false.
                    OVR_ASSERT(false);
                    break;
                }
                else
                {
                    OVR_ASSERT_LOG(false, ("CFRunLoopRunInMode returned unexpected code"));
                    break;
                }
            }
            while(true);                    
        }
    }

                                   
    CFRunLoopRemoveSource(RunLoop, CommandQueueSource, kCFRunLoopDefaultMode);
    CFRelease(CommandQueueSource);
    
    LogText("OVR::DeviceManagerThread - exiting (ThreadId=0x%p).\n", GetThreadId());

    return 0;
}