当前位置: 首页>>代码示例>>C++>>正文


C++ Entity::GetPos方法代码示例

本文整理汇总了C++中Entity::GetPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetPos方法的具体用法?C++ Entity::GetPos怎么用?C++ Entity::GetPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


在下文中一共展示了Entity::GetPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetEntitiesAtPosition

void Map::GetEntitiesAtPosition(const Point & pos, std::vector<Entity*> & outEntities) const
{
	const size_t entityCount = m_Entities.size();
	Entity * entity = NULL;
	for(unsigned int i = 0; i < entityCount; i++)
	{
		entity = m_Entities[i];

		if(entity && ((entity->GetPos() - pos).LengthSq() < 1) )
			outEntities.push_back(entity);
	}
}
开发者ID:MatthewWGross,项目名称:Gilead,代码行数:12,代码来源:Map.cpp

示例2: main

int main(int argc, char *argv[])
{
    Options& options = Options::GetInstance();
    options.LoadFromCommandLine(argc, argv);
	options.LoadFromIniFile("gravity.ini");

    GRAVITY_LOG(info, "Client started.");

    sf::ContextSettings settings;
	settings.depthBits = 0;
	settings.stencilBits = 8;
	settings.antialiasingLevel = options.msaa;
	int style = options.fullscreen ? sf::Style::Fullscreen : sf::Style::Default;

    sf::RenderWindow window(sf::VideoMode(options.hres, options.vres, options.bitdepth), "Gravity", style, settings);
    ::Gravity::Game::Game game;
	
    game.Start();
    
	BoundingCamera camera(Vec2f(400, 300), Vec2f());


    // ROCKET

    RocketRendererInterfaceImpl rendererInterface;
    RocketSystemInterfaceImpl systemInterface;
    RocketShellInterfaceImpl shellInterface("../data/gui/");

    rendererInterface.target =  &window;
    rendererInterface.states = (sf::RenderStates *) &sf::RenderStates::Default;

    Rocket::Core::SetFileInterface(&shellInterface);
    Rocket::Core::SetRenderInterface(&rendererInterface);
    Rocket::Core::SetSystemInterface(&systemInterface);

    if(!Rocket::Core::Initialise())
        return 0;

	Rocket::Controls::Initialise();

    Rocket::Core::FontDatabase::LoadFontFace("Delicious-Bold.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Delicious-BoldItalic.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Delicious-Italic.otf");
    Rocket::Core::FontDatabase::LoadFontFace("Delicious-Roman.otf");
    Rocket::Core::FontDatabase::LoadFontFace("DejaVuSans-Bold.ttf");
    Rocket::Core::FontDatabase::LoadFontFace("DejaVuSans-BoldOblique.ttf");
    Rocket::Core::FontDatabase::LoadFontFace("DejaVuSans-Oblique.ttf");
    Rocket::Core::FontDatabase::LoadFontFace("DejaVuSans.ttf");

    Rocket::Core::Context *Context = Rocket::Core::CreateContext("default",
        Rocket::Core::Vector2i(window.getSize().x, window.getSize().y));
    
    Rocket::Debugger::Initialise(Context);
	//Rocket::Debugger::SetVisible(true);
    
    Rocket::Core::ElementDocument *document = Context->LoadDocument("my.rml");

    if(document)
    {
        document->Show();
        document->RemoveReference();
    };

    // END ROCKET


    //Rocket::Core::ElementDocument* document;

	std::cout << "OpenGL Version" << window.getSettings().ContextSettings::majorVersion << "." << window.getSettings().ContextSettings::minorVersion << std::endl;
    sf::ContextSettings settingz = window.getSettings();
    std::cout << settingz.majorVersion << "." << settingz.minorVersion << std::endl;

    while(window.isOpen()) {
    	sf::Event event;
        Entity* ship = game.GetWorld().GetEntities()[0];

		while (window.pollEvent(event)) {
        //window.PollEvent(event);
			if (event.type == sf::Event::Closed)
				window.close();

			if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
				return 0;

			if ((event.type == sf::Event::MouseWheelMoved)) {
				options.renderscale += event.mouseWheel.delta*.1f;
			}

			if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) {
                Shape* bombShape = Shape::CreateBombShape();
				Entity* bomb = new Entity(game.GetWorld(), *bombShape, ship->GetPos() + Vec2f(1, 1));
                bomb->SetVel(ship->GetVel());
                bomb->SetMass(0.01f);
                game.GetWorld().AddEntity(*bomb);
                
			}
            
            switch(event.type)
            {
                case sf::Event::Resized:
//.........这里部分代码省略.........
开发者ID:MarcinKoziuk,项目名称:gravity,代码行数:101,代码来源:cmain.cpp


注:本文中的Entity::GetPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。