Exemplo n.º 1
0
int main( int argc, char* argv[] )
{
       
    
    //get_settings read_settings; //create a settings reading object.    
    int screenDataW = 1920; //put screen data into a temp var
    int screenDataH = 1080;
    

    
    SDL_Init( SDL_INIT_EVERYTHING ); //start SDL
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); //set GL version of the window
    
    SDL_Window* window = SDL_CreateWindow( "RainbowRPG - SDL2.0 - OpenGL2.1", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screenDataW, screenDataH, SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_GRABBED); //create OpenGL window

    SDL_GLContext glcontext = SDL_GL_CreateContext(window); //set context as OpenGL
//    SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
        initGL(screenDataW, screenDataH); //init GL.


    //command_thread.detach();
//    SDL_Delay(1000);
    std::string mapFile ("a.map");
    std::cout << "Initialising map!\n\n";
    
    map* ptrmap; //create a pointer of type map.
    map currentMap (screenDataW, screenDataH, mapFile);
    ptrmap = &currentMap; //make pointer point to instance of map.
    std::cout << "checking for inputted commands....";
    

    command* ptrCommand; //create a pointer of type command.
    command commandline; //create command line object.
    std::cout << "creating command line thread...\n";
    boost::thread command_thread ( boost::bind (&command::start_command, &commandline) ); //create a thread of the command line.
    std::cout << "Command thread started\n\n";
    ptrCommand = & commandline; //make pointer point to command object.
    
    //boost::thread logic_loop (boost::bind(&entity_logic_loop, ptrmap)); //create logic loop thread.
    
    std::cout << "Running game loop func\n\n";
    game_loop(ptrCommand, ptrmap, window);
    //game_loop( ptrmap, window);

    currentMap.destroy_map(); //destroy the map!
    SDL_GL_DeleteContext(glcontext); //clean up
    SDL_Quit(); //quit SDL   
    std::cout << "\nQuited nicely, press any letter/number key then tap return to terminate \n(This is a problem with using threads and std::cin together, must find a better way of doing this safely\n\n"; // - Remember killing the thread causes recursive terminate >.<.)\n\n";
    command_thread.join(); //detach both out threads.
    //logic_loop.join();


    return 0;
    
    }
Exemplo n.º 2
0
/**
 * \brief Compares the current cut list with the saved cut list
 */
bool DeleteMap::IsSaved(void) const
{
    if (!m_ctx || !m_ctx->playingInfo || gCoreContext->IsDatabaseIgnored())
        return true;

    frm_dir_map_t currentMap(m_deleteMap);
    frm_dir_map_t savedMap;
    m_ctx->LockPlayingInfo(__FILE__, __LINE__);
    m_ctx->playingInfo->QueryCutList(savedMap);
    m_ctx->UnlockPlayingInfo(__FILE__, __LINE__);

    // Remove temporary placeholder marks from currentMap
    QMutableMapIterator<uint64_t, MarkTypes> it(currentMap);
    while (it.hasNext())
    {
        it.next();
        if (MARK_PLACEHOLDER == it.value())
            it.remove();
    }

    return currentMap == savedMap;
}
Exemplo n.º 3
0
VectorXs DenseCRF::map ( int n_iterations ) const {
	// Run inference
	MatrixXf Q = inference( n_iterations );
	// Find the map
	return currentMap( Q );
}
Exemplo n.º 4
0
int main( int argc, char* argv[] )
{
       
    
    //get_settings read_settings; //create a settings reading object.    
    int screenDataW = 1920; //put screen data into a temp var
    int screenDataH = 1080;
    

    
    if (SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
    {
        std::cout << "SDL init error: " << SDL_GetError();
     return 0;
    } //start SDL

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); //set GL version of the window
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);    
    SDL_Window* window = SDL_CreateWindow( "RainbowRPG - SDL2.0 - OpenGL2.1", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screenDataW, screenDataH, SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_OPENGL); //create OpenGL window

    SDL_GLContext glcontext = SDL_GL_CreateContext(window); //set context as OpenGL
        initGL(screenDataW, screenDataH); //init GL.
    
    GLenum err = glewInit();

    if (GLEW_OK != err)
    {
         std::cout << "initialiseing GLEW failed." << glewGetErrorString(err);
         return 0 ;
    }

    std::cout << "Using GLEW - " << glewGetString(GLEW_VERSION) << "\n";

//     glMatrixMode (GL_MODELVIEW);
//   glLoadIdentity();     
//        glScalef(scale, scale, scale);
//      glBegin(GL_QUADS); //draw quad.
//            glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
//            //glColor3f(SQUARE::colour4f[0],SQUARE::colour4f[1],SQUARE::colour4f[2]);
//            //glColor4f(SQUARE::colour4f[0],SQUARE::colour4f[1],SQUARE::colour4f[2],SQUARE::colour4f[3]);
//            glVertex2f(-1.0f,1.0f);
//            glVertex2f(1.0f,1.0f);
//            glVertex2f(1.0f,-1.0f);
//            glVertex2f(-1.0f,-1.0f);
//            glEnd();
//           
//            GLenum error = glGetError();
//            if( error != GL_NO_ERROR )
//            {
//            std::cout << "Error drawing! 177 " << gluErrorString( error ) << "\n";
//            return false;
//            }
//            SDL_GL_SwapWindow(window); //show content.
//            SDL_Delay(1000);
//     return 0;

    //command_thread.detach();
//    SDL_Delay(1000);
    std::string mapFile ("a.map");
    std::cout << "Initialising map!\n\n";
    
    map* ptrmap; //create a pointer of type map.
    map currentMap (screenDataW, screenDataH, mapFile);
    ptrmap = &currentMap; //make pointer point to instance of map.
    std::cout << "checking for inputted commands....";
    

    command* ptrCommand; //create a pointer of type command.
    command commandline; //create command line object.
    std::cout << "creating command line thread...\n";
    boost::thread command_thread ( boost::bind (&command::start_command, &commandline) ); //create a thread of the command line.
    std::cout << "Command thread started\n\n";
    ptrCommand = & commandline; //make pointer point to command object.
    
    int entities = ptrmap -> return_number_of_entities();
    
    boost::thread logic_loop (boost::bind(&entity_logic_loop, entities, ptrmap)); //create logic loop thread.
    
    std::cout << "Running game loop func\n\n";
    game_loop(ptrCommand, ptrmap, window);
    //game_loop( ptrmap, window);

    currentMap.destroy_map(); //destroy the map!
    SDL_GL_DeleteContext(glcontext); //clean up
    SDL_Quit(); //quit SDL   
    logic_loop.join(); //join logic thread.
    std::cout << "\nQuited nicely, press any letter/number key then tap return to terminate \n(This is a problem with using threads and std::cin together, must find a better way of doing this safely\n\n"; // - Remember killing the thread causes recursive terminate >.<.)\n\n";
    command_thread.join(); //detach both out threads.
    


    return 0;
    
    }
Exemplo n.º 5
0
void PlayGame(sf::RenderWindow& window) {
	sf::View view;
	sf::Image layout;
	sf::Music theme;
	theme.openFromFile("resources/audio/Child of Light - Boss Battle Theme.wav");
	theme.play();
	
	int mapNum = rand() % 4 + 1;
	
	string mapString("resources/environment/map." + std::to_string(mapNum) + ".png");
	//string mapString("resources/environment/map." + std::to_string(mapNum) + ".png");
	string outputMapString("Loaded Map " + std::to_string(mapNum) + ".");
	cout << outputMapString << endl;

	
	layout.loadFromFile(mapString);

	sf::Texture red;
	sf::Texture green;
	sf::Texture blue;
	sf::Texture black;
	sf::Texture blank;


	red.loadFromFile("resources/environment/darkgrassyrock.jpg");
	green.loadFromFile("resources/environment/playerSpawn.jpg");
	blue.loadFromFile("resources/environment/purplecliffrock.jpg");
	black.loadFromFile("resources/environment/darkgrassyrock.jpg");
	blank.loadFromFile("resources/environment/darkestrock.jpg");

	Map currentMap(window, 150, red, green, blue, black, blank, layout);

	sf::Clock deltaTimeClock;
	float DeltaTime = 0;

	// load some resources like textures which will be used for the duration of the game
	sf::Texture petRockTex;
	petRockTex.loadFromFile("resources/character/petRock.png");
	sf::Clock spawnTime;
	bool pause = false;
	sf::Texture reaperBossIdleTex;
	reaperBossIdleTex.loadFromFile("resources/character/Reaper Boss-Idle.png");


	//window.setFramerateLimit(60);
	//std::vector<Character*> petRockList;
	std::vector<std::unique_ptr<Character>> petRockList;
	MeleeWeapon sword("axe", "gold", 5, 9, 10, "Golden-BattleAxe.png");

	Player player(100, 10, 10, 10, 10, 10, 10, 10, 10, window, petRockList, DeltaTime, currentMap);
	//ReaperBoss reaperBoss(500, window, player);



	player.equipMelee(sword);



	sf::Font asmanFont;
	sf::Text pauseText;
	asmanFont.loadFromFile("resources/font/ASMAN.ttf");
	pauseText.setFont(asmanFont);
	pauseText.setString("Paused");
	pauseText.setCharacterSize(200);
	pauseText.setColor(sf::Color::Red);
	pauseText.setPosition(player.position.x - 350, player.position.y - 20);

	for (int i = 0; i < 10; i++) { // make 10 enemies 
		std::unique_ptr<Character> newPetRock(new PetRock(1, window, petRockTex, player, DeltaTime, currentMap));
		petRockList.push_back(std::move(newPetRock));
	}
	//ReaperBoss reaperBoss(500, window, player);
	std::unique_ptr<Character> reaperBoss(new ReaperBoss(750, window, player, DeltaTime, currentMap));
	petRockList.push_back(std::move(reaperBoss));



	//sf::Sprite backGround;
	//sf::Texture backGroundTex;
	//backGroundTex.loadFromFile("resources/environment/floorBackground.jpg");
	//backGround.setTexture(backGroundTex);

	//backGround.setScale(5, 5);



	view.setCenter(sf::Vector2f(player.sprite.getPosition().x, player.sprite.getPosition().y));
	view.setSize(1780, 980);

	while (window.isOpen()) {


		sf::Time timeFromClock = deltaTimeClock.restart();
		DeltaTime = timeFromClock.asSeconds();

		if (spawnTime.getElapsedTime().asSeconds() > 10 && petRockList.size() < 10) {
			for (int i = 0; i < 10; i++) { // make 10 enemies 
				std::unique_ptr<Character> newPetRock(new PetRock(1, window, petRockTex, player, DeltaTime, currentMap));
				petRockList.push_back(std::move(newPetRock));
			}
			spawnTime.restart();
		}



		if (!pause && sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
			pause = true;
		}
		if (pause && sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
			pause = false;
		}
		// get all the input first every frame
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed) {
				window.close();
			}

		} // input loop ended


		window.setView(view);

		view.setCenter(sf::Vector2f(player.sprite.getPosition().x, player.sprite.getPosition().y));

		window.clear();


		if (!pause) {  //This is the pause function

					   //window.draw(backGround);
			currentMap.Update();

			player.Update();

			for (int i = 0; i < petRockList.size(); i++) {
				petRockList.at(i)->Update();
			}
			window.draw(player.scoreText);
		}
		else {
			window.draw(pauseText);
		}


		window.display();
		if (!player.alive) {
			return;
		}
	}
}