本文整理汇总了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);
}
}
示例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:
//.........这里部分代码省略.........