• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ engine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中engine的典型用法代码示例。如果您正苦于以下问题:C++ engine类的具体用法?C++ engine怎么用?C++ engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: update

	void gui::update(engine& eng, double t, const entity_list& elist)
	{
		using namespace component;
		static component_id gui_mask
			= genmask(Component::GUI)
			| genmask(Component::STATS)
			| genmask(Component::POSITION)
			| genmask(Component::SPRITE);
		
		for(auto& e : elist) {
			if((e->mask & gui_mask) == gui_mask) {
				auto& stats = e->stat;
				auto& pos = e->pos;
				auto& spr = e->spr;
				auto fnt = font::get_font("SourceCodePro-Regular.ttf", 20);
				// XXX we should color code some of these
				// i.e. as health gets lower it goes from green to red, to grey dead/unconscious
				std::stringstream ss;
				ss  << "Turn: " << std::setw(4) << eng.get_turns()
					<< " | "
					<< "Health: " << stats->health
					<< " | "
					<< datetime(eng.get_turns()).printable()
					;
				auto surf = font::render_shaded(ss.str(), fnt, graphics::color(255,255,255), graphics::color(0,0,0));
				// surface gets free'd by update_texture, so we need to get height (and width if needed) before we call it.
				// gui tagged entities get absolute pixel positioning for *free*.
				pos->pos.x = 0;
				pos->pos.y = eng.get_window().height() - surf->h;
				spr->update_texture(std::make_shared<graphics::surface>(surf));
			}
		}
	}
开发者ID:sweetkristas,项目名称:roguelike,代码行数:33,代码来源:gui_process.cpp


示例2: lua_pushcfunction

	void lua::register_mark_library(const engine & engine) {
		// Register the Lua API.
		engine.register_library("object", mark_library);
		
		// Register the mark userdata type.
		if (engine.push_metatable(mark_class)) {
			// Garbage collection finalizer.
			lua_pushcfunction(engine, mark_gc);
			lua_setfield(engine, -2, "__gc");
		}
		lua_pop(engine, 1);
		
		// Register the actor userdata type.
		if (engine.push_metatable(actor_class)) {
			// Getter metamethod.
			lua_pushcfunction(engine, actor_index);
			lua_setfield(engine, -2, "__index");
			
			// Setter metamethod.
			lua_pushcfunction(engine, actor_newindex);
			lua_setfield(engine, -2, "__newindex");
			
			// Garbage collection finalizer.
			lua_pushcfunction(engine, actor_gc);
			lua_setfield(engine, -2, "__gc");
		}
		lua_pop(engine, 1);
	}
开发者ID:Nexuapex,项目名称:Harmony,代码行数:28,代码来源:lua_mark.cpp


示例3: add_testing_generators

void add_testing_generators(engine& e,
                            generator_registry& gr)
{
   auto run_product = make_shared<product_argument_writer>("run_product", e.get_type_registry().get(types::TESTING_RUN_PASSED));
   auto run_output_product = make_shared<product_argument_writer>("run_output_product", e.get_type_registry().get(types::TESTING_OUTPUT));
   auto test_executable = make_shared<source_argument_writer>("test_executable", e.get_type_registry().get(types::EXE));
   auto additional_dirs = make_shared<shared_lib_dirs_writer>("additional_dirs", e.get_type_registry().get(types::SHARED_LIB));
   auto args = make_shared<testing_run_args_writer>(e.get_type_registry());
#if defined(_WIN32)
   cmdline_builder cmdline("@SET PATH=%PATH%;$(additional_dirs)\n"
                           "@$(test_executable) $(args)\n");
#else
   cmdline_builder cmdline("export LD_LIBRARY_PATH=$(additional_dirs):$LD_LIBRARY_PATH\n"
                           "$(test_executable) $(args)");
#endif
   cmdline += run_product;
   cmdline += run_output_product;
   cmdline += test_executable;
   cmdline += additional_dirs;
   cmdline += args;

   auto action = std::make_shared<testing_run_action>("testing.run", run_product, run_output_product);
   *action += cmdline;

   auto sources = make_consume_types(e, {types::EXE});
   auto products = make_product_types(e, {types::TESTING_OUTPUT, types::TESTING_RUN_PASSED});

   unique_ptr<generator> g(new generator(e, "testing.run", sources, products, true, action));
   g->include_composite_generators(true);
   gr.insert(std::move(g));

   add_testing_suite_generator(e, gr);
}
开发者ID:darkangel-ua,项目名称:hammer,代码行数:33,代码来源:testing_generators.cpp


示例4: do_menu

void menu_system::do_menu(engine& window)
{
    if(!window.render_me)
        return;

    if(window.width != lw || window.height != lh)
    {
        lw = window.width;
        lh = window.height;

        tex.create(lw, lh);

        tex.clear(sf::Color(60, 60, 60, 255));

        tex.display();
    }

    ///Note to self, I have totally broken the OpenGL rendering internals
    ///which makes SFML really very sad
    //glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);

    //text::immediate(&window.window, "Start", {window.width/2.f, window.height/1.5f}, 60, true);

    bool lclick = once<sf::Mouse::Left>();

    vec2f wind = (vec2f){window.width, window.height};

    for(auto& i : ui_elements)
    {
        vec2f mouse_coords = {window.get_mouse_x(), window.get_mouse_y()};

        bool is_within = mouse_coords > i.pos * wind - i.dim/2.f && mouse_coords < i.pos * wind + i.dim/2.f;

        vec3f col = {0.7,0.7,0.7};

        if(is_within)
        {
            col = {1,1,1};

            if(lclick)
            {
                i.callback(*this);
            }
        }

        text::immediate(&window.window, i.label, i.pos * (vec2f){window.width, window.height}, i.font_size, true, col);
    }

    sf::Sprite spr;
    spr.setTexture(tex.getTexture());

    spr.setColor(sf::Color(255, 255, 255, 60));

    window.window.draw(spr);

    //window.window.clear(sf::Color(0,0,0,255));
}
开发者ID:20k,项目名称:SwordFight,代码行数:57,代码来源:menu.cpp


示例5: add_link_generators

void add_link_generators(engine& e,
                         const build_action_ptr& link_action,
                         std::function<std::unique_ptr<generator>(const build_action_ptr& action)> link_generator_creator)
{
   e.generators().insert(link_generator_creator(link_action));

   auto a1 = std::make_shared<testing_link_action>(link_action);
   e.generators().insert(make_unique<testing_link_generator>(e, move(link_generator_creator(a1))));

   auto a2 = std::make_shared<testing_link_fail_action>(e, link_action);
   e.generators().insert(make_unique<testing_link_fail_generator>(e, move(link_generator_creator(a2))));
}
开发者ID:darkangel-ua,项目名称:hammer,代码行数:12,代码来源:testing_generators.cpp


示例6: operator

 engine::want operator()(engine& eng,
     asio::error_code& ec,
     std::size_t& bytes_transferred) const
 {
   bytes_transferred = 0;
   return eng.shutdown(ec);
 }
开发者ID:4nc3str4l,项目名称:LostEngine,代码行数:7,代码来源:shutdown_op.hpp


示例7: update

	void action::update(engine& eng, float t, const entity_list& elist)
	{
		using namespace component;
		static component_id mask = genmask(Component::INPUT) | genmask(Component::POSITION);
		for(auto& e : elist) {
			if((e->mask & mask) == mask) {
				auto& inp = e->inp;
				auto& pos = e->pos;

				switch(inp->action)
				{
				case input::Action::none:	break;
				case input::Action::moved:	
					// Test to see if we moved but the collision detection failed it.
					// XX there must be a better way.
					if(pos->mov.x == 0 && pos->mov.y == 0) {
						inp->action = input::Action::none;
					} else {
						e->pos->pos += e->pos->mov;
						e->pos->mov.clear();
						if(e->is_player()) {
							eng.set_camera(e->pos->pos);

							eng.getMap()->clearVisible();
							eng.getMap()->updatePlayerVisibility(e->pos->pos, e->stat->visible_radius);
						}
					}
					break;
				case input::Action::pass:	break;
				case input::Action::attack:	break;
				case input::Action::spell:	break;
				case input::Action::use:	break;
				default: 
					ASSERT_LOG(false, "No action defined for " << static_cast<int>(inp->action));
					break;
				}
				// increment turns on successful update.
				if(inp->action != input::Action::none) {
					eng.inc_turns();
				}
			} else if((e->mask & genmask(Component::AI)) == genmask(Component::AI)) {
				//auto& aip = e->aip;
			}
		}
	}
开发者ID:sweetkristas,项目名称:mercy,代码行数:45,代码来源:action_process.cpp


示例8: update

	void render::update(engine& eng, double t, const entity_list& elist)
	{
		using namespace component;
		static component_id sprite_mask = genmask(Component::POSITION)  | genmask(Component::SPRITE);
		static component_id gui_mask = sprite_mask | genmask(Component::GUI);
		static component_id map_mask = genmask(Component::MAP);
		
		const point& cam = eng.get_camera();
		const point screen_centre(eng.get_window().width() / 2, eng.get_window().height() / 2);
		const point& ts = eng.get_tile_size();

		for(auto& e : elist) {
			if((e->mask & gui_mask) == gui_mask) {
				auto& spr = e->spr;
				auto& pos = e->pos;
				auto& g = e->gui;
				if(spr->tex.is_valid()) {
					spr->tex.blit(rect(pos->pos.x, pos->pos.y));
				}
				for(auto& w : g->widgets) {
					w->draw(rect(0, 0, eng.get_window().width(), eng.get_window().height()), 0.0f, 1.0f);
				}
			}  else if((e->mask & sprite_mask) == sprite_mask) {
				auto& spr = e->spr;
				auto& pos = e->pos;
				if(spr->tex.is_valid()) {
					spr->tex.blit(rect(screen_centre.x - (cam.x - pos->pos.x) * ts.x - ts.x/2, screen_centre.y - (cam.y - pos->pos.y) * ts.y - ts.y/2, ts.x, ts.y));
				}
			} else if((e->mask & map_mask) == map_mask) {
				auto& map = e->map;

				const int screen_width_in_tiles = (eng.get_window().width() + eng.get_tile_size().x - 1) / eng.get_tile_size().x;
				const int screen_height_in_tiles = (eng.get_window().height() + eng.get_tile_size().y - 1) / eng.get_tile_size().y;
				rect area = rect::from_coordinates(-screen_width_in_tiles / 2 + cam.x, 
					-screen_height_in_tiles / 2 + cam.y,
					screen_width_in_tiles / 2 + cam.x,
					screen_height_in_tiles / 2 + cam.y);

				for(auto& chk : map->t.get_chunks_in_area(area)) {
					chk->draw(eng, cam);
				}
			}
		}
	}
开发者ID:sweetkristas,项目名称:roguelike,代码行数:44,代码来源:render_process.cpp


示例9: operator

  engine::want operator()(engine& eng,
      asio::error_code& ec,
      std::size_t& bytes_transferred) const
  {
    typename ConstBufferSequence::const_iterator iter = buffers_.begin();
    typename ConstBufferSequence::const_iterator end = buffers_.end();
    std::size_t accumulated_size = 0;

    for (;;)
    {
      engine::want want = eng.handshake(type_, ec);
      if (want != engine::want_input_and_retry
          || bytes_transferred == total_buffer_size_)
        return want;

      // Find the next buffer piece to be fed to the engine.
      while (iter != end)
      {
        const_buffer buffer(*iter);

        // Skip over any buffers which have already been consumed by the engine.
        if (bytes_transferred >= accumulated_size + buffer_size(buffer))
        {
          accumulated_size += buffer_size(buffer);
          ++iter;
          continue;
        }

        // The current buffer may have been partially consumed by the engine on
        // a previous iteration. If so, adjust the buffer to point to the
        // unused portion.
        if (bytes_transferred > accumulated_size)
          buffer = buffer + (bytes_transferred - accumulated_size);

        // Pass the buffer to the engine, and update the bytes transferred to
        // reflect the total number of bytes consumed so far.
        bytes_transferred += buffer_size(buffer);
        buffer = eng.put_input(buffer);
        bytes_transferred -= buffer_size(buffer);
        break;
      }
    }
  }
开发者ID:4nc3str4l,项目名称:LostEngine,代码行数:43,代码来源:buffered_handshake_op.hpp


示例10: get_document

    node_pointer get_document() throw(std::string)
    {
      if (document.get() == nullptr) {
	expat_engine.parse();
      }
      if (document.get() == nullptr) {
	throw std::string(nullptr);
      }
      return document;
    }
开发者ID:FlyingRhenquest,项目名称:cppxml,代码行数:10,代码来源:node_engine.hpp


示例11: operator

  engine::want operator()(engine& eng,
      boost::system::error_code& ec,
      std::size_t& bytes_transferred) const
  {
    boost::asio::mutable_buffer buffer =
      boost::asio::detail::buffer_sequence_adapter<boost::asio::mutable_buffer,
        MutableBufferSequence>::first(buffers_);

    return eng.read(buffer, ec, bytes_transferred);
  }
开发者ID:151706061,项目名称:Voreen,代码行数:10,代码来源:read_op.hpp


示例12: operator

  engine::want operator()(engine& eng,
      pdalboost::system::error_code& ec,
      std::size_t& bytes_transferred) const
  {
    pdalboost::asio::const_buffer buffer =
      pdalboost::asio::detail::buffer_sequence_adapter<pdalboost::asio::const_buffer,
        ConstBufferSequence>::first(buffers_);

    return eng.write(buffer, ec, bytes_transferred);
  }
开发者ID:AsherBond,项目名称:PDAL,代码行数:10,代码来源:write_op.hpp


示例13: getinfo

void car::getinfo(engine& m)
{
	cout << endl;
	cout << "lenth " << length << endl;
	cout << "width " << width << endl;
	cout << "hight " << hight << endl;
	cout << "weight " << weight << endl;
	cout << "places " << numplaces << endl;
	cout << "max speed " << maxspeed << endl;
	m.getinfo1();
	cout << endl << "===========================" << endl << endl;
}
开发者ID:icekiborg,项目名称:laba3,代码行数:12,代码来源:main.cpp


示例14: debug_controls

///none of these affect the camera, so engine does not care about them
///assume main is blocking
void debug_controls(fighter* my_fight, engine& window)
{
    sf::Keyboard key;

    if(once<sf::Keyboard::T>())
    {
        my_fight->queue_attack(attacks::OVERHEAD);
    }

    if(once<sf::Keyboard::Y>())
    {
        my_fight->queue_attack(attacks::SLASH);
    }

    if(once<sf::Keyboard::F>())
    {
        my_fight->queue_attack(attacks::STAB);
    }

    if(once<sf::Keyboard::G>())
    {
        my_fight->queue_attack(attacks::REST);
    }

    if(once<sf::Keyboard::R>())
    {
        my_fight->queue_attack(attacks::BLOCK);
    }

    if(once<sf::Keyboard::V>())
    {
        my_fight->queue_attack(attacks::RECOIL);
    }

    if(once<sf::Keyboard::Z>())
    {
        my_fight->queue_attack(attacks::TROMBONE);
    }

    if(once<sf::Mouse::XButton1>())
        my_fight->queue_attack(attacks::SLASH_ALT);

    if(once<sf::Mouse::XButton2>())
        my_fight->queue_attack(attacks::OVERHEAD_ALT);


    if(once<sf::Keyboard::H>())
    {
        my_fight->try_feint();
    }

    if(once<sf::Keyboard::SemiColon>())
    {
        my_fight->die();
    }

    float y_diff = 0;

    if(key.isKeyPressed(sf::Keyboard::U))
    {
        y_diff = 0.01f * window.get_frametime()/2000.f;
    }

    if(key.isKeyPressed(sf::Keyboard::O))
    {
        y_diff = -0.01f * window.get_frametime()/2000.f;
    }

    my_fight->set_rot_diff({0, y_diff, 0});

    static float look_height = 0.f;

    if(key.isKeyPressed(sf::Keyboard::Comma))
    {
        look_height += 0.01f * window.get_frametime() / 8000.f;
    }

    if(key.isKeyPressed(sf::Keyboard::Period))
    {
        look_height += -0.01f * window.get_frametime() / 8000.f;
    }

    my_fight->set_look({look_height, 0.f, 0.f});

    vec2f walk_dir = {0,0};

    if(key.isKeyPressed(sf::Keyboard::I))
        walk_dir.v[0] = -1;

    if(key.isKeyPressed(sf::Keyboard::K))
        walk_dir.v[0] = 1;

    if(key.isKeyPressed(sf::Keyboard::J))
        walk_dir.v[1] = -1;

    if(key.isKeyPressed(sf::Keyboard::L))
        walk_dir.v[1] = 1;

//.........这里部分代码省略.........
开发者ID:20k,项目名称:SwordFight,代码行数:101,代码来源:main.cpp


示例15: fps_trombone_controls

void fps_trombone_controls(fighter* my_fight, engine& window)
{
    trombone_manager& trombone = my_fight->trombone_manage;

    sf::Keyboard key;

    if(key.isKeyPressed(sf::Keyboard::F10))
        window.request_close();

    vec2f walk_dir = {0,0};

    if(key.isKeyPressed(sf::Keyboard::W))
        walk_dir.v[0] = -1;

    if(key.isKeyPressed(sf::Keyboard::S))
        walk_dir.v[0] = 1;

    if(key.isKeyPressed(sf::Keyboard::A))
        walk_dir.v[1] = -1;

    if(key.isKeyPressed(sf::Keyboard::D))
        walk_dir.v[1] = 1;

    bool crouching = key.isKeyPressed(sf::Keyboard::LControl);

    my_fight->crouch_tick(crouching);

    bool sprint = key.isKeyPressed(sf::Keyboard::LShift);

    if(crouching)
        sprint = false;

    if(my_fight->cube_info)
        walk_dir = my_fight->cube_info->transform_move_dir_no_rot(walk_dir);

    my_fight->walk_dir(walk_dir, sprint);

    my_fight->update_headbob_if_sprinting(sprint);

    if(once<sf::Mouse::Left>())
        trombone.play(my_fight);

    //if(once<sf::Keyboard::Z>())
    my_fight->queue_attack(attacks::TROMBONE);

    if(once<sf::Keyboard::Space>())
        my_fight->try_jump();

    ///this will probably break
    my_fight->set_look({-window.c_rot_keyboard_only.s[0], window.get_mouse_sens_adjusted_x() / 1.f, 0});


    vec2f m;
    m.v[0] = window.get_mouse_sens_adjusted_x();
    m.v[1] = window.get_mouse_sens_adjusted_y();

    float source_m_yaw = 0.0003839723;

    float yout = m.v[0] * source_m_yaw;

    ///ok, so this is essentially c_rot_keyboard_only
    ///ie local
    ///ie we give no fucks anymore because the mouse look scheme is fully consistent from local -> global
    ///ie we can ignore this, just apply the overall matrix rotation and offset to te position
    ///and etc
    my_fight->set_rot_diff({0, -yout, 0.f});

    trombone.set_active(true);
}
开发者ID:20k,项目名称:SwordFight,代码行数:69,代码来源:main.cpp


示例16: fps_controls

void fps_controls(fighter* my_fight, engine& window)
{
    sf::Keyboard key;

    if(key.isKeyPressed(sf::Keyboard::F10))
        window.request_close();

    vec2f walk_dir = {0,0};

    if(key.isKeyPressed(sf::Keyboard::W))
        walk_dir.v[0] = -1;

    if(key.isKeyPressed(sf::Keyboard::S))
        walk_dir.v[0] = 1;

    if(key.isKeyPressed(sf::Keyboard::A))
        walk_dir.v[1] = -1;

    if(key.isKeyPressed(sf::Keyboard::D))
        walk_dir.v[1] = 1;

    bool crouching = key.isKeyPressed(sf::Keyboard::LControl);

    my_fight->crouch_tick(crouching);

    bool sprint = key.isKeyPressed(sf::Keyboard::LShift);

    if(crouching)
        sprint = false;

    if(my_fight->cube_info)
        walk_dir = my_fight->cube_info->transform_move_dir_no_rot(walk_dir);

    my_fight->walk_dir(walk_dir, sprint);

    my_fight->update_headbob_if_sprinting(sprint);

    if(sprint && walk_dir.v[0] < 0)
        my_fight->queue_attack(attacks::SPRINT);

    if(once<sf::Mouse::Left>())
        my_fight->queue_attack(attacks::SLASH);

    if(once<sf::Mouse::Middle>())
        my_fight->queue_attack(attacks::OVERHEAD);

    if(window.get_scrollwheel_delta() > 0.01)
        my_fight->queue_attack(attacks::STAB);

    if(once<sf::Mouse::Right>())
        my_fight->queue_attack(attacks::BLOCK);

    if(once<sf::Mouse::XButton1>())
        my_fight->queue_attack(attacks::SLASH_ALT);

    if(once<sf::Mouse::XButton2>())
        my_fight->queue_attack(attacks::OVERHEAD_ALT);

    if(once<sf::Keyboard::Z>())
        my_fight->queue_attack(attacks::TROMBONE);

    if(once<sf::Keyboard::Q>())
        my_fight->try_feint();

    if(once<sf::Keyboard::Space>())
        my_fight->try_jump();

    //window.c_rot.x = clamp(window.c_rot.x, -M_PI/2.f, M_PI/2.f);

    ///this will probably break
    my_fight->set_look({-window.c_rot_keyboard_only.s[0], window.get_mouse_sens_adjusted_x() / 1.f, 0});


    vec2f m;
    m.v[0] = window.get_mouse_sens_adjusted_x();
    m.v[1] = window.get_mouse_sens_adjusted_y();

    float source_m_yaw = 0.0003839723;

    float yout = m.v[0] * source_m_yaw;

    ///ok, so this is essentially c_rot_keyboard_only
    ///ie local
    ///ie we give no fucks anymore because the mouse look scheme is fully consistent from local -> global
    ///ie we can ignore this, just apply the overall matrix rotation and offset to te position
    ///and etc
    my_fight->set_rot_diff({0, -yout, 0.f});
}
开发者ID:20k,项目名称:SwordFight,代码行数:88,代码来源:main.cpp


示例17: to_actor

	game::actor_ref lua::to_actor(const engine & engine, index_t index) {
		return boost::dynamic_pointer_cast<game::actor>(
			engine.to_proxy(actor_class, index, actor_empty)
		);
	}
开发者ID:Nexuapex,项目名称:Harmony,代码行数:5,代码来源:lua_mark.cpp


示例18: to_mark

	game::mark_ref lua::to_mark(const engine & engine, index_t index) {
		return engine.to_proxy(mark_class, index, mark_empty);
	}
开发者ID:Nexuapex,项目名称:Harmony,代码行数:3,代码来源:lua_mark.cpp


示例19: operator

 T operator() (engine& eng) const
 {
     return (T)eng.uniform(min, max);
 }
开发者ID:93sam,项目名称:opencv,代码行数:4,代码来源:precomp.hpp


示例20: integrator

    integrator_type integrator(const system& sys, const engine& eng) {
      return [&](const dof::velocity& v, math::real dt) { 
	eng.integrate(v, sys.mass * v, dt); 
      };
    }
开发者ID:Jorjor70,项目名称:meuh,代码行数:5,代码来源:integrator.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ engine_studio_api_t类代码示例发布时间:2022-05-31
下一篇:
C++ endpoint_type类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap