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


C++ TileMap::draw方法代码示例

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


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

示例1: main

int main(int argc, char** argv)
{
  // create main window
	sf::RenderWindow window(sf::VideoMode(800,600,32), "Hello World - SFML");

	sf::Clock clock;
   TileMap tmap;
   tmap.init("map.txt");

   Player player;
   player.init();
   player.setTileMap(&tmap);

	while (window.isOpen())
	{
		sf::Time dt = clock.restart();
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
		player.handleInput();
		player.update(dt.asSeconds());
		tmap.update(dt.asSeconds());
		window.clear();
		tmap.draw(window);
		player.draw(window);
		window.display();
	}

  // Done.
  return 0;
}
开发者ID:WentingTan,项目名称:SetRising,代码行数:34,代码来源:main.cpp

示例2: TileMap

TileMap *create_bubble( std::vector<TileMap*> &landChunks )
{
	int ndx = ((float)rand() / (float)RAND_MAX) * landChunks.size();
	TileMap *bub = new TileMap( landChunks[ndx]->m_size );
	bub->bub_age = (float)rand() / (float)RAND_MAX;

	bub->paste( landChunks[ndx], 0, 0 );

	int sz = bub->m_size * 12;
	BITMAP *tmpBmp = create_bitmap( sz, sz );
	rectfill( tmpBmp, 0, 0, sz, sz, makecol( 0xff, 0x00, 0xff) );

	bub->draw( tmpBmp, 0, 0, emptyObjs );

	bub->bub_bmp = create_bitmap( 20, 20 );
	stretch_blit( tmpBmp, bub->bub_bmp, 0, 0, 
	  		  	  tmpBmp->w, tmpBmp->h, 0, 0, 
				bub->bub_bmp->w, bub->bub_bmp->h );
	destroy_bitmap( tmpBmp );

	circle( bub->bub_bmp, 10, 10, 9, makecol( 0x66, 0xee, 0xff ) );
	circlefill( bub->bub_bmp, 6, 6, 2, makecol( 0xff, 0xff, 0xff ) );

	hline( bub->bub_bmp, 2, 17, 18, makecol( 155, 193, 212 ) );
	hline( bub->bub_bmp, 2, 18, 18, makecol( 0xff, 0x00, 0xff ) );
	hline( bub->bub_bmp, 2, 19, 18, makecol( 0xff, 0x00, 0xff ) );

	return bub;
}
开发者ID:bradparks,项目名称:ld48jovoc_food_fight_3d_luxe,代码行数:29,代码来源:wander_main.cpp

示例3: R_draw

void R_draw(HDC hDC)
{
	glGetUniformLocation(NULL,NULL);
	rt_back.Clear(0.2941f, 0.2941f, 0.2941f, 1.0f);
	rt_scene.Clear(0.3921f, 0.3921f, 0.3921f, 1.0f);
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);

	glBindFramebuffer(GL_FRAMEBUFFER, rt_scene.fbo);
	glViewport(0, 0, rt_scene.width, rt_scene.height);
	camera.setOrthoMatrix();

	if(bdrawbglayer01)
		tilemap_back.draw(&camera);
	if(bdrawbglayer02)
		tilemap_front.draw(&camera);
	if(bdrawbglayer03 && tilemap_back.has_c_Map)
		DrawCollisionMap();

	R_drawWorldDebug();

	glViewport(0, 0, client_rect.w, client_rect.h);
	R_setScreenOrtho();
	s_srcRect = ScreenRect(lmenuw/client_rect.w,0,1.0 - ((lmenuw + rmenuw)/client_rect.w),1);
	s_dstRect = ScreenRect(lmenuw, 0, client_rect.w - (lmenuw + rmenuw), client_rect.h);
	DrawQuadDS(rt_back, rt_scene,&s_dstRect,&s_srcRect, NULL);

	glViewport(0, 0, client_rect.w, client_rect.h);
	glBindFramebuffer(GL_FRAMEBUFFER, debug_rendertarget.fbo);
	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	R_setScreenOrtho();

	DrawLeftPanel();
	DrawRightPanel();	
	DrawClientBorder();

	R_setPostProcessingOrtho();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	DrawFullscreenQuad(rt_back, debug_rendertarget, NULL);

	glFlush();
	bdoublebuffer ? SwapBuffers( hDC ) : glDrawBuffer(GL_FRONT);
}
开发者ID:arrosado,项目名称:2d-engine,代码行数:45,代码来源:main.cpp

示例4: main

int main(int argc, char **argv)
{
	bool done = false;
	SDL_Event event;

	// init graphics
	gfx_init(WINDOW_X, WINDOW_Y, false);
	// get key state array
	keyStates = SDL_GetKeyState(NULL);

#define SPRITE_CNT 1
	Sprite *sprites[SPRITE_CNT+1];
	sprites[0] = NULL;
	sprites[1] = new Sprite();
	sprites[1]->init("1.bmp", false, 255, 255, 255);

	Sprite backGround;
	backGround.init("background.bmp", true);

	// load from file
	TileMap map;
	map.loadMap(MAPFILE_NAME);

	Player player(&map, "player.bmp", 0, 0, 0);

	Uint32 frameStart;
	while(!done)
	{
		frameStart = SDL_GetTicks();
		// event processing
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_QUIT:
				done = true;
			default:
				break;
			}
		}
		// player think
		player.think();

		// draw
		backGround.draw(0, 0);
		map.draw((const Sprite **)sprites, NULL);
		player.draw();

		// flip buffer
		SDL_Flip(screen);

		// Key to have smooth moving and jump animation
		while(SDL_GetTicks() - frameStart < FRAME_DURATION);
	}

	return 0;
}
开发者ID:D3Hunter,项目名称:first-game,代码行数:57,代码来源:game.cpp

示例5: run

void Game::run()
{
	quit = false;

	DisplayWindowDescription desc;
	desc.set_title("ClanLib TileMap Example");
	desc.set_size(Size(640, 480), true);
	desc.set_allow_resize(false);

	DisplayWindow window(desc);

	Slot slot_quit = window.sig_window_close().connect(this, &Game::on_window_close);
	Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &Game::on_input_up);

	Canvas canvas(window);

	clan::XMLResourceDocument xml_resource_document("resources.xml");
	ResourceManager resources = clan::XMLResourceManager::create(xml_resource_document);

	TileMap map;
	map.load(canvas, "tavern", resources, xml_resource_document);

	// Run until someone presses escape, or closes the window
	while (!quit)
	{
		int x = window.get_ic().get_mouse().get_x() - canvas.get_width();
		int y = window.get_ic().get_mouse().get_y() - canvas.get_height();

		// ** Enable these 3 lines to display the example magnified **
		//Mat4f matrix = Mat4f::scale( 2.0f, 2.0f, 1.0f);
		//x /= 2; y /= 2;
		//canvas.set_modelview(matrix);

		map.set_scroll(x, y);

		canvas.clear(Colorf::black);

		map.draw(canvas);


		// Flip the display, showing on the screen what we have drawed since last call to flip()
		window.flip(1);

		// This call processes user input and other events
		KeepAlive::process(0);
	}
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:47,代码来源:game.cpp


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