本文整理汇总了C++中world::create_entity方法的典型用法代码示例。如果您正苦于以下问题:C++ world::create_entity方法的具体用法?C++ world::create_entity怎么用?C++ world::create_entity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类world
的用法示例。
在下文中一共展示了world::create_entity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: perform_logic_step
void testbed::perform_logic_step(world& world) {
auto inputs = world.get_message_queue<messages::crosshair_intent_message>();
for (auto& it : inputs) {
bool draw = false;
if (it.intent == intent_type::CROSSHAIR_PRIMARY_ACTION) {
keep_drawing = it.pressed_flag;
draw = true;
}
if (draw || (it.intent == intent_type::MOVE_CROSSHAIR && keep_drawing)) {
auto ent = world.create_entity("drawn_sprite");
ingredients::sprite_scalled(ent, it.crosshair_world_pos, vec2(10, 10), assets::texture_id::BLANK);
}
}
auto key_inputs = world.get_message_queue<messages::unmapped_intent_message>();
for (auto& it : key_inputs) {
if (it.intent == intent_type::SWITCH_CHARACTER && it.pressed_flag) {
++current_character;
current_character %= characters.size();
ingredients::inject_window_input_to_character(characters[current_character], world_camera);
}
}
for (auto& tested : draw_bodies) {
auto& s = tested->get<components::physics_definition>();
auto& lines = renderer::get_current().logic_lines;
auto vv = s.fixtures[0].debug_original;
for (int i = 0; i < vv.size(); ++i) {
auto& tt = tested->get<components::transform>();
auto pos = tt.pos;
lines.draw_cyan((pos + vv[i]).rotate(tt.rotation, pos), (pos + vv[(i + 1) % vv.size()]).rotate(tt.rotation, pos));
}
}
}
示例2: initialize
void testbed::initialize(world& world) {
auto window_rect = window::glwindow::get_current()->get_screen_rect();
world.get_system<gui_system>().resize(vec2i(window_rect.w, window_rect.h));
resource_manager.destroy_everything();
world.delete_all_entities();
resource_manager.create(assets::texture_id::TEST_CROSSHAIR, std::wstring(L"hypersomnia/gfx/crosshair.png"));
resource_manager.create(assets::texture_id::TEST_PLAYER, L"hypersomnia/gfx/walk_1.png");
resource_manager.create(assets::texture_id::TEST_BACKGROUND, L"hypersomnia/gfx/snow_textures/snow3.png");
resource_manager.create(assets::texture_id::CRATE, L"hypersomnia/gfx/crate2_destroyed.png");
resource_manager.create(assets::texture_id::CAR_INSIDE, L"hypersomnia/gfx/crate2.png");
resource_manager.create(assets::texture_id::CAR_FRONT, L"hypersomnia/gfx/crate2.png");
resource_manager.create(assets::texture_id::MOTORCYCLE_FRONT, L"hypersomnia/gfx/motorcycle_front.png");
resource_manager.create(assets::texture_id::MOTORCYCLE_INSIDE, L"hypersomnia/gfx/motorcycle_inside.png");
resource_manager.create(assets::texture_id::TRUCK_FRONT, L"hypersomnia/gfx/truck_front.png");
resource_manager.create(assets::texture_id::TRUCK_INSIDE, L"hypersomnia/gfx/truck_inside.png");
resource_manager.create(assets::texture_id::TEST_SPRITE, L"hypersomnia/gfx/frog.png");
auto& assault_rifle_gui = resource_manager.create(assets::texture_id::ASSAULT_RIFLE, L"hypersomnia/gfx/assault_rifle.png").gui_sprite_def;
assault_rifle_gui.flip_horizontally = true;
assault_rifle_gui.flip_vertically = true;
resource_manager.create(assets::texture_id::SHOTGUN, L"hypersomnia/gfx/shotgun.png");
auto& magazine_gui = resource_manager.create(assets::texture_id::SAMPLE_MAGAZINE, L"hypersomnia/gfx/magazine.png").gui_sprite_def;
magazine_gui.rotation_offset = -270;
auto& suppressor_gui = resource_manager.create(assets::texture_id::SAMPLE_SUPPRESSOR, L"hypersomnia/gfx/suppressor.png").gui_sprite_def;
suppressor_gui.flip_horizontally = true;
resource_manager.create(assets::texture_id::PINK_CHARGE, L"hypersomnia/gfx/pink_charge.png");
resource_manager.create(assets::texture_id::PINK_SHELL, L"hypersomnia/gfx/pink_shell.png");
auto& backpack_gui = resource_manager.create(assets::texture_id::BACKPACK, L"hypersomnia/gfx/backpack.png").gui_sprite_def;
backpack_gui.rotation_offset = -90.f;
backpack_gui.gui_bbox_expander = vec2(0, 2);
augs::image attachment_circle_filled;
attachment_circle_filled.create_filled_circle(16);
augs::image attachment_circle_border;
attachment_circle_border.create_circle(16);
resource_manager.create(assets::texture_id::ATTACHMENT_CIRCLE_FILLED, attachment_circle_filled);
resource_manager.create(assets::texture_id::ATTACHMENT_CIRCLE_BORDER, attachment_circle_border);
resource_manager.create(assets::texture_id::CONTAINER_OPEN_ICON, L"hypersomnia/gfx/container_open_icon.png");
resource_manager.create(assets::texture_id::CONTAINER_CLOSED_ICON, L"hypersomnia/gfx/container_closed_icon.png");
resource_manager.create(assets::texture_id::GUI_CURSOR, L"hypersomnia/gfx/gui_cursor.png");
resource_manager.create(assets::texture_id::GUI_CURSOR_ADD, L"hypersomnia/gfx/gui_cursor_add.png");
resource_manager.create(assets::texture_id::GUI_CURSOR_ERROR, L"hypersomnia/gfx/gui_cursor_error.png");
resource_manager.create(assets::texture_id::BLANK, L"hypersomnia/gfx/blank.png");
resource_manager.create(assets::texture_id::SECONDARY_HAND_ICON, L"hypersomnia/gfx/secondary_hand_icon.png");
resource_manager.create(assets::texture_id::PRIMARY_HAND_ICON, L"hypersomnia/gfx/primary_hand_icon.png");
resource_manager.create(assets::texture_id::SHOULDER_SLOT_ICON, L"hypersomnia/gfx/shoulder_slot_icon.png");
resource_manager.create(assets::texture_id::ARMOR_SLOT_ICON, L"hypersomnia/gfx/armor_slot_icon.png");
resource_manager.create(assets::texture_id::CHAMBER_SLOT_ICON, L"hypersomnia/gfx/chamber_slot_icon.png");
resource_manager.create(assets::texture_id::DETACHABLE_MAGAZINE_ICON, L"hypersomnia/gfx/detachable_magazine_slot_icon.png");
resource_manager.create(assets::texture_id::GUN_BARREL_SLOT_ICON, L"hypersomnia/gfx/gun_barrel_slot_icon.png");
auto& font = resource_manager.create(assets::font_id::GUI_FONT);
font.open("hypersomnia/Kubasta.ttf", 16, L" A[email protected]#$%^&*()_+-=[];'\\,./{}:\"|<>?");
resource_manager.create_sprites_indexed(
assets::texture_id::TORSO_MOVING_FIRST,
assets::texture_id::TORSO_MOVING_LAST,
L"hypersomnia/gfx/sprite");
resource_manager.create(assets::atlas_id::GAME_WORLD_ATLAS,
resources::manager::atlas_creation_mode::FROM_ALL_TEXTURES
| resources::manager::atlas_creation_mode::FROM_ALL_FONTS);
resource_manager.create(assets::shader_id::DEFAULT_VERTEX, L"hypersomnia/shaders/default.vsh", graphics::shader::type::VERTEX);
resource_manager.create(assets::shader_id::DEFAULT_FRAGMENT, L"hypersomnia/shaders/default.fsh", graphics::shader::type::FRAGMENT);
resource_manager.create(assets::program_id::DEFAULT, assets::shader_id::DEFAULT_VERTEX, assets::shader_id::DEFAULT_FRAGMENT);
resource_manager.create_inverse_with_flip(assets::animation_id::TORSO_MOVE,
assets::texture_id::TORSO_MOVING_FIRST,
assets::texture_id::TORSO_MOVING_LAST,
20.0f);
auto& player_response = resource_manager.create(assets::animation_response_id::TORSO_SET);
player_response[messages::animation_response_message::MOVE] = assets::animation_id::TORSO_MOVE;
world_camera = world.create_entity("camera");
auto crate = world.create_entity("crate");
auto crate2 = world.create_entity("crate2");
auto crate3 = world.create_entity("crate3");
auto crate4 = world.create_entity("crate4");
for (int x = -4 * 1; x < 4 * 1; ++x)
{
auto frog = world.create_entity("frog");
ingredients::sprite(frog, vec2(100 + x * 40, 400), assets::texture_id::TEST_SPRITE, augs::white, render_layer::DYNAMIC_BODY);
//.........这里部分代码省略.........