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

C++ TileMap类代码示例

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

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



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

示例1: p

void
Player::update_walk_stand()
{
  if (controller.get_axis_state(Y_AXIS) > 0) {
    TileMap* tilemap = Sector::current()->get_tilemap2();
    if (tilemap)
      {
        Point p(int(pos.x)/32, (int(pos.y)/32 + 1));
        unsigned int col = tilemap->get_pixel(p.x, p.y);

        if ((col & TILE_STAIRS) && (get_direction() == WEST && (col & TILE_LEFT) ||
                                    get_direction() == EAST && (col & TILE_RIGHT)))
          {
            delete contact;
            contact = new StairContact(tilemap, p);

            std::cout << "Stair mode" << std::endl;
            state = STAIRS_DOWN;
            //c_object->get_check_domains() & (~CollisionObject::DOMAIN_TILEMAP));
            Sector::current()->get_collision_engine()->remove(c_object);
            z_pos = -10.0f;
            return;
          }
        else
          {
            set_ducking();
            return;
          }
      }
  } else if (controller.get_axis_state(Y_AXIS) < 0) {
    TileMap* tilemap = Sector::current()->get_tilemap2();
    if (tilemap)
      {
        Point p(int(pos.x)/32 + ((get_direction() == WEST) ? -1 : +1), (int(pos.y)/32));
        unsigned int col = tilemap->get_pixel(p.x, p.y);

        if ((col & TILE_STAIRS) && (get_direction() == EAST && (col & TILE_LEFT) ||
                                    get_direction() == WEST && (col & TILE_RIGHT)))
          {
            delete contact;
            contact = new StairContact(tilemap, p);

            state = STAIRS_UP;
            //c_object->get_check_domains() & (~CollisionObject::DOMAIN_TILEMAP));
            Sector::current()->get_collision_engine()->remove(c_object);
            z_pos = -10.0f;
            return;
          }
      }    
  }

  if(state == STAND)
    update_stand();
  else
    update_walk();
}
开发者ID:BackupTheBerlios,项目名称:windstille-svn,代码行数:56,代码来源:player.cpp


示例2:

float
Sector::get_width() const
{
  float width = 0;
  for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
    TileMap* solids = *i;
    if ((solids->get_width() * 32 + solids->get_x_offset()) > width) width = (solids->get_width() * 32 + solids->get_x_offset());
  }
  return width;
}
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:10,代码来源:sector.cpp


示例3:

float
Sector::get_width() const
{
  float width = 0;
  for(auto i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
    TileMap* solids = *i;
    width = std::max(width, solids->get_bbox().get_right());
  }

  return width;
}
开发者ID:hongtaox,项目名称:supertux,代码行数:11,代码来源:sector.cpp


示例4: file

TileMap *
TileMap::createCSV( std::string fileName )
{
    std::fstream file( fileName, std::ios::in );
    if(! file.good() ) return nullptr;
    file.close();

    TileMap *tileMap = new TileMap;
    tileMap->fromCSV( fileName );
    return tileMap;
}
开发者ID:enetheru,项目名称:smf_tools,代码行数:11,代码来源:tilemap.cpp


示例5: tokenize

TileMap *RoomLoader::loadTileMap(const std::string& filename)
{
	std::cout << "Loading tilemap " + filename + "...";
    std::vector<std::string> data = tokenize(loadFile(filename), "\n", true);

	int width = 0;
	int height = 0;
	int row;
    int col;

	for (row = 0; row < (int)data.size(); row++)
	{
		if (row == 0)
            width = data[row].size();
		height++;
	}
	height = (height - 1) / 2;

	TileMap* tileMap = new TileMap(width, height);
	tileMap->clear(0,0);

	// Load solidities 
	for (row = 0; row < height; row++)
	{
		for (col = 0; col < width; col++)
		{
			char c = data.at(row).at(col);
			if (c == '.')
			{
				tileMap->setFlags(col, row, 0);
			}
			else if (c == '#')
			{
				tileMap->setFlags(col, row, TileMap::FLAG_SOLID);
			} 
		}
	}

	// Load tiles
	for (row = height; row < height*2; row++)
	{
		for (col = 0; col < width; col++)
		{
			char c = data.at(row).at(col);
			int tile = c - ((c >= 'a')? 'a' - 10 : '0');
			tileMap->setTile(col, row - height, tile);
		}
	}

	//std::cout << tileMap->toString() << std::endl;

    std::cout << " Done!" << std::endl;
	return tileMap;
}
开发者ID:olofn,项目名称:db_public,代码行数:54,代码来源:roomloader.cpp


示例6: test_both

int test_both(const std::string& map, const std::string& anim_name)
{
	TMXLoader loader_anim(anim_name);
	std::vector<Animation*> anim = loader_anim.ExtractAsAnimation(); 
	for(int i=0; i<anim.size();i++)
	{
		anim[i]->SetFrameTime(0.07);
	}
	AnimatedSprite MyCharacter(anim[2], true, true);
	MyCharacter.SetPosition(308,224);
	
	TMXLoader loader_map(map);
	TileMap* tilemap = loader_map.ExtractAsMap();
	sf::RenderWindow App(sf::VideoMode(640,480), "TMX_Renderer");
	sf::View map_view = App.GetDefaultView();
	sf::View anim_view = App.GetDefaultView();
	anim_view.Zoom(2.0);

	const sf::Input& Input = App.GetInput();
	float speed = 120.0;
	App.SetFramerateLimit(60);
	while (App.IsOpened())
	{
		sf::Event Event;
		while (App.GetEvent(Event))
		{
			if (Event.Type == sf::Event::Closed)
				App.Close();
			if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Left ))	MyCharacter.SetAnim(anim[3]);
			if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Right))	MyCharacter.SetAnim(anim[1]);
			if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Up   ))	MyCharacter.SetAnim(anim[0]);
			if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Down ))	MyCharacter.SetAnim(anim[2]);
			
		}
		
		if(Input.IsKeyDown(sf::Key::Left ))	map_view.Move(-App.GetFrameTime()*speed, 0.0);
		if(Input.IsKeyDown(sf::Key::Right))	map_view.Move( App.GetFrameTime()*speed, 0.0);
		if(Input.IsKeyDown(sf::Key::Up   ))	map_view.Move( 0.0, -App.GetFrameTime()*speed);
		if(Input.IsKeyDown(sf::Key::Down ))	map_view.Move( 0.0, App.GetFrameTime()*speed);
		MyCharacter.update(App.GetFrameTime());
		
		
		App.Clear();
		App.SetView(map_view);
		tilemap->renderMap(App,map_view.GetRect());
		App.SetView(anim_view);
		App.Draw(MyCharacter);
		
		App.Display();
	}
	return 1;
	
}
开发者ID:Canadadry,项目名称:TMX_Renderer,代码行数:53,代码来源:main.cpp


示例7: beautify

// Once the Map is parsed, we can automaticaly choose the right tiles
void Mapper::beautify(TileMap& tiles)
{
    for (size_t y=0; y <tiles.size(); y++)
    {
        for (size_t x=0; x < tiles[y].size(); x++)
        {
            if (tiles[y][x])
            {
                if ((y >= 1 && !tiles[y-1][x]) || y == 0)
                {
                    tiles[y][x]->addSide(TileSide::TOP);
                }

                if ((y < tiles.size()-1 && !tiles[y+1][x]) || y == tiles.size()-1)
                {
                    tiles[y][x]->addSide(TileSide::BOTTOM);
                }

                if ((x >= 1 && !tiles[y][x-1]) || x == 0)
                {
                    tiles[y][x]->addSide(TileSide::LEFT);
                }

                if ((x < tiles[y].size()-1 && !tiles[y][x+1]) || x == tiles[y].size()-1)
                {
                    tiles[y][x]->addSide(TileSide::RIGHT);
                }

                if ((x >= 1 && y >= 1 && !tiles[y-1][x-1]) || (x == 0 && y == 0))
                {
                    tiles[y][x]->addSide(TileSide::TOP_LEFT);
                }

                if ((x < tiles[y].size()-1 && y >= 1 && !tiles[y-1][x+1]) || (x == tiles[y].size()-1 && y == 0))
                {
                    tiles[y][x]->addSide(TileSide::TOP_RIGHT);
                }

                if ((x >= 1 && y < tiles.size()-1 && !tiles[y+1][x-1]) || (x == 0 && y == tiles.size()-1))
                {
                    tiles[y][x]->addSide(TileSide::BOTTOM_LEFT);
                }

                if ((x < tiles[y].size()-1 && y < tiles.size()-1 && !tiles[y+1][x+1]) || (x == tiles[y].size()-1 && y == tiles.size()-1))
                {
                    tiles[y][x]->addSide(TileSide::BOTTOM_RIGHT);
                }
            }
        }
    }
}
开发者ID:BinaryBrain,项目名称:Elodie-Dream,代码行数:52,代码来源:Mapper.cpp


示例8: main

int main() {
	// SFML window init
	sf::Vector2u res{ 1024, 768 };
	sf::RenderWindow window{ sf::VideoMode(res.x, res.y), "SFML Window" };
	window.setFramerateLimit(60);
	
	sf::Vector2u tileSize{ 16, 16 };
	std::string tileSet{ "square16_8.png" }; 

	Galaxy g;
	TileMap map;
	
	if (!map.load(tileSet, tileSize, g.numStarSystems, g.numStarSystems, g)) 
		return -1;
	
	sf::View gameView{ sf::Vector2f(4000, 4000), sf::Vector2f(res.x, res.y) };
	sf::View minimapView{ sf::Vector2f(4000, 4000), sf::Vector2f(4000, 4000) };
	
	// the game view (full window)
	gameView.setViewport(sf::FloatRect(0, 0, 1, 1));

	// mini-map (upper-right corner)
	minimapView.setViewport(sf::FloatRect(0.75f, 0, 0.25f, 0.25f));
	
	sf::RectangleShape miniback; // We want to draw a rectangle behind the minimap
	miniback.setPosition(0, 0);
	miniback.setSize(sf::Vector2f(8000, 8000));
	miniback.setFillColor(sf::Color::Black);

	// SFML Event loop
	while (window.isOpen()) {
		sf::Event event;
		while (window.pollEvent(event)) {
			if (event.type == sf::Event::Closed)
				window.close();
		}
		
		// Game loop goes here
		window.clear();
		window.setView(gameView);
		window.draw(map);
		
		window.setView(minimapView);
		window.draw(miniback);
		window.draw(map);
		
		window.display();
	}
	
	return 0;
}
开发者ID:dqnx,项目名称:ideal-adventure,代码行数:51,代码来源:main.cpp


示例9: checker

int TileMapBinder::shift(lua_State* L)
{
	StackChecker checker(L, "TileMapBinder::shift", 0);
	
	Binder binder(L);
	TileMap* tilemap = static_cast<TileMap*>(binder.getInstance("TileMap", 1));	

	int dx = luaL_checkinteger(L, 2);
	int dy = luaL_checkinteger(L, 3);

	tilemap->shift(dx, dy);

	return 0;
}
开发者ID:andysdesigns,项目名称:giderosdev,代码行数:14,代码来源:tilemapbinder.cpp


示例10: props

void
Sector::add_object(const std::string& name, const lisp::Lisp* lisp)
{
  lisp::Properties props(lisp);

  if(name == "tilemap") {
    TileMap* tilemap = new TileMap(props);
    add(tilemap);
    if (tilemap->get_name() == "interactive")
      interactive_tilemap = tilemap;
    else if (tilemap->get_name() == "interactivebackground")
      interactivebackground_tilemap = tilemap;
  } else if(name == "background") {
    // TODO
  } else if (name == "background-gradient") {
    add(new BackgroundGradient(props));
  } else if(name == "trigger") {
    add(new Trigger(props));
  } else if(name == "box") {
    add(new Box(props));
  } else if(name == "shockwave") {
    add(new Shockwave(props));
  } else if(name == "elevator") {
    add(new Elevator(props));
  } else if(name == "character") {    
    add(new Character(props));
  } else if(name == "spider-mine") {
    add(new SpiderMine(props));
  } else if(name == "hedgehog") {
    add(new Hedgehog(props));
  } else if(name == "test-object") {
    add(new TestObject(props));
  } else if (name == "nightvision") {
    add(new Nightvision(props));
  } else if (name == "particle-system") {
    add(new ParticleSystem(props));
  } else if(name == "scriptable-object") {    
    add(new ScriptableObject(props));
  } else if (name == "vrdummy") {
    add(new VRDummy(props));
  } else if (name == "swarm") {
    add(new Swarm(props));
  } else if (name == "laserpointer") {
    add(new LaserPointer());
  } else if (name == "liquid") {
    add(new Liquid(props));
  } else {
    std::cout << "Skipping unknown Object: " << name << "\n";
  }
}
开发者ID:BackupTheBerlios,项目名称:windstille-svn,代码行数:50,代码来源:sector.cpp


示例11: StringLines

Map *ParseMap(const std::string &data) {
    auto lines = StringLines(data);

    TileMap tiles;
    for(auto &line : lines) {
        TileLine tileLine;
        for(auto &ch : StringChars(line)) {
            tileLine.push_back(CharToTile(ch));
        }
        tiles.push_back(tileLine);
    }

    return new Map(tiles);
}
开发者ID:ShaneO23,项目名称:mario-game,代码行数:14,代码来源:map.cpp


示例12: loadTileMap

Room *RoomLoader::loadRoom(const std::string& filename)
{
	TileMap* tileMap = loadTileMap(filename);

	std::cout << "Loading room " + filename + "...";
    std::vector<std::string> data = tokenize(loadFile(filename), "\n", true);

	std::vector<std::string> tileSetInfo = tokenize(data[data.size()-1], " ");

	if (tileSetInfo.size() == 0)
	{
		throw DB_EXCEPTION("Tilset info is missing in file " + filename);
	}

	std::string tileSetFileName = "graphics/" + tileSetInfo[0];
	int numTiles = fromString<int>(tileSetInfo[1]);

	Room* room = new Room(tileMap, new Animation(tileSetFileName, numTiles));	

	int width = 0;
	int height = 0;
	int row;
    int col;

	// Load entities 
	int x = 0;
	int y = 0;
	for (row = 0; row < tileMap->getHeight(); row++)
	{
		for (col = 0; col < tileMap->getWidth(); col++)
		{
			char c = data[row].at(col);
			// Ignore solidities.
			if (c != '.' && c != '#')
			{
				Entity* entity = createEntity(c, x * TileMap::TILE_SIZE, y * TileMap::TILE_SIZE, Random::get());
				room->addEntity(entity);
			}
	
			x++;
		}
		x = 0;
		y++;
	}

    std::cout << " Done!" << std::endl;

	return room;
}
开发者ID:olofn,项目名称:db_public,代码行数:49,代码来源:roomloader.cpp


示例13:

bool 
CoordArg::load( BitBuffer& buf, TileMap& tileMap,
                const TileFeatureArg* /*prevArg*/ ) 
{
   // XXX: Doesn't use relative coordinates yet.
   buf.alignToByte();
   int16 diffLat = buf.readNextBAShort();
   int16 diffLon = buf.readNextBAShort();
   int32 lat = diffLat * tileMap.getMC2Scale() + 
      tileMap.getReferenceCoord().getLat();
   int32 lon = diffLon * tileMap.getMC2Scale() + 
      tileMap.getReferenceCoord().getLon();
   m_coord.setCoord( lat, lon );
   return true;
}
开发者ID:VLjs,项目名称:Wayfinder-S60-Navigator,代码行数:15,代码来源:TileFeatureArg.cpp


示例14:

void
TileCell::Draw(Bitmap* bitmap, GFX::rect *rect, bool advanceFrame, bool full)
{
	MapOverlay* overlayZero = fOverlays[0];
	if (overlayZero == NULL)
		return;

	TileMap* tileMapZero = overlayZero->TileMapForTileCell(fNumber);
	if (tileMapZero == NULL) {
		std::cerr << "Tilemap Zero is NULL!" << std::endl;
		return;
	}
	const int8 mask = tileMapZero->Mask();
	int maxOverlay = full ? fNumOverlays : 1;
	for (int i = maxOverlay - 1; i >= 0; i--) {
		if (!ShouldDrawOverlay(i, mask))
			continue;
	    MapOverlay *overlay = fOverlays[i];
		TileMap *map = overlay->TileMapForTileCell(i == 0 ? fNumber : 0);
		if (map == NULL)
			continue;

		int16 index = map->TileIndex(advanceFrame);
		if (fDoor != NULL && !fDoor->Opened()) {
			int16 secondaryIndex = map->SecondaryTileIndex();
			if (secondaryIndex != -1)
				index = secondaryIndex;
			else
				std::cerr << "TileCell::Draw(): secondary index is -1. BUG?." << std::endl;
		}

		TISResource *tis = gResManager->GetTIS(overlay->TileSet());
		Bitmap *cell = tis->TileAt(index);
		assert(cell != NULL);

		gResManager->ReleaseResource(tis);

		GFX::Color *color = NULL;
		if (i == 0 && mask != 0) {
			color = &sTransparentColor;
			//color = &cell->format->palette->colors[255];
		}

		_DrawOverlay(bitmap, cell, *rect, color);

		cell->Release();
	}
}
开发者ID:,项目名称:,代码行数:48,代码来源:


示例15: checkProjectileCollision

Collision Projectile::checkProjectileCollision(TileMap &map)
{
	if (!this->tileObject)
	{
		// It's possible the projectile reached the end of it's lifetime this frame
		// so ignore stuff without a tile
		return {};
	}

	sp<TileObject> ignoredObject = nullptr;
	if (ownerInvulnerableTicks > 0)
	{
		if (firerVehicle)
		{
			ignoredObject = firerVehicle->tileObject;
		}
		else if (firerUnit)
		{
			ignoredObject = firerUnit->tileObject;
		}
	}
	Collision c = map.findCollision(this->previousPosition, this->position, {}, ignoredObject);
	if (!c)
		return {};

	c.projectile = shared_from_this();
	return c;
}
开发者ID:,项目名称:,代码行数:28,代码来源:


示例16: snapToCoord

/// Snap to tilemap coords and remove duplicates.
static bool
snapToCoord( coordVectVect_t& polygons,
             const TileMap& tilemap )
{
   bool changedAnything = false;
   for ( uint32 i = 0; i < polygons.size(); ++i ) {
      vector<MC2Coordinate>& coords = polygons[ i ];

      for ( uint32 j = 0; j < coords.size(); ++j ) {
         TileMapCoord currCoord = coords[ j ];
         tilemap.snapCoordToPixel( currCoord );
         if ( currCoord != coords[ j ] ) {
            coords[ j ] = currCoord;
            changedAnything = true;
         }
      }
      // Remove consequtive identical coordinates.
      uint32 size = coords.size();
      coords.resize( std::distance( coords.begin(), 
                        std::unique( coords.begin(), coords.end() ) ) );
      if ( coords.size() != size ) {
         changedAnything = true;
      }
   }

   return changedAnything;
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:28,代码来源:TileMapCreator.cpp


示例17: window

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


示例18: if

void
Sector::collision_tilemap(collision::Constraints* constraints,
                          const Vector& movement, const Rectf& dest,
                          MovingObject& object) const
{
  // calculate rectangle where the object will move
  float x1 = dest.get_left();
  float x2 = dest.get_right();
  float y1 = dest.get_top();
  float y2 = dest.get_bottom();

  for(auto i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
    TileMap* solids = *i;

    // test with all tiles in this rectangle
    Rect test_tiles = solids->get_tiles_overlapping(Rectf(x1, y1, x2, y2));

    for(int x = test_tiles.left; x < test_tiles.right; ++x) {
      for(int y = test_tiles.top; y < test_tiles.bottom; ++y) {
        const Tile* tile = solids->get_tile(x, y);
        if(!tile)
          continue;
        // skip non-solid tiles
        if(!tile->is_solid ())
          continue;
        Rectf tile_bbox = solids->get_tile_bbox(x, y);

        /* If the tile is a unisolid tile, the "is_solid()" function above
         * didn't do a thorough check. Calculate the position and (relative)
         * movement of the object and determine whether or not the tile is
         * solid with regard to those parameters. */
        if(tile->is_unisolid ()) {
          Vector relative_movement = movement
            - solids->get_movement(/* actual = */ true);

          if (!tile->is_solid (tile_bbox, object.get_bbox(), relative_movement))
            continue;
        } /* if (tile->is_unisolid ()) */

        if(tile->is_slope ()) { // slope tile
          AATriangle triangle;
          int slope_data = tile->getData();
          if (solids->get_drawing_effect() & VERTICAL_FLIP)
            slope_data = AATriangle::vertical_flip(slope_data);
          triangle = AATriangle(tile_bbox, slope_data);

          collision::rectangle_aatriangle(constraints, dest, triangle,
              solids->get_movement(/* actual = */ false));
        } else { // normal rectangular tile
          check_collisions(constraints, movement, dest, tile_bbox, NULL, NULL,
              solids->get_movement(/* actual = */ false));
        }
      }
    }
  }
}
开发者ID:hongtaox,项目名称:supertux,代码行数:56,代码来源:sector.cpp


示例19: while

void RoomGenerator::placeDoor(Room *room, const std::string &targetDungeon, int targetLevel, bool down, Random &random)
{
	TileMap *tm = room->getTileMap();

	while(true)
	{
		int x = random.getInt(tm->getWidth());
		int y = random.getInt(tm->getHeight());
		
		bool ok = false;

		while(true)
		{
			if (y < 0 || y >= tm->getHeight())
			{
				break;
			}

			if (tm->isSolid(x, y + 1))
			{
				y++;
			}
			else if (!tm->isSolid(x, y))
			{
				y--;
			}
			else if (tm->isSolid(x - 1, y) && tm->isSolid(x + 1, y))
			{
				ok = tm->isSolid(x, y - 1);
				break;
			}
			else
			{
				break;
			}
		}

		if (ok)
		{
			tm->setFlags(x, y, 0);
			room->addEntity(new Door(x * TileMap::TILE_SIZE, y * TileMap::TILE_SIZE, down, targetDungeon, targetLevel, false));
			break;
		}
	}
}
开发者ID:olofn,项目名称:db_public,代码行数:45,代码来源:roomgenerator.cpp


示例20: GenerateVertexArray

sf::VertexArray GenerateVertexArray(TileSet &tileSet, TileMap &tileMap)
{
    sf::VertexArray vertexArray(sf::Quads);
    int tileWidth = tileSet.tileSize.x;
    int tileHeight = tileSet.tileSize.y;

    if(tileSet.IsDirty())
        return vertexArray;

    for(int layer = 0; layer < 3; layer++)
    {
        for(int col = 0; col < tileMap.GetColumnsCount(); col++)
        {
            for(int row = 0; row < tileMap.GetRowsCount(); row++)
            {
                TileTextureCoords coords;
                if(tileMap.GetTile(layer, col, row) != -1)
                {
                    coords = tileSet.GetTileTextureCoords(tileMap.GetTile(layer, col, row));
                }
                else
                {
                    coords = tileSet.GetTileTextureCoords(0);
                }

                {
                    sf::Vertex vertex(sf::Vector2f(col * tileWidth, row * tileHeight), coords.topLeft);
                    if(tileMap.GetTile(layer, col, row) == -1)
                        vertex.color.a = 0;
                    vertexArray.append(vertex);
                }
                {
                    sf::Vertex vertex(sf::Vector2f(col * tileWidth, (row + 1) * tileHeight), coords.bottomLeft);
                    if(tileMap.GetTile(layer, col, row) == -1)
                        vertex.color.a = 0;
                    vertexArray.append(vertex);
                }
                {
                    sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, (row + 1) * tileHeight), coords.bottomRight);
                    if(tileMap.GetTile(layer, col, row) == -1)
                        vertex.color.a = 0;
                    vertexArray.append(vertex);
                }
                {
                    sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, row * tileHeight), coords.topRight);
                    if(tileMap.GetTile(layer, col, row) == -1)
                        vertex.color.a = 0;
                    vertexArray.append(vertex);
                }
            }
        }
    }

    return vertexArray;
}
开发者ID:bran921007,项目名称:GD,代码行数:55,代码来源:TileMapTools.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ TileNode类代码示例发布时间:2022-05-31
下一篇:
C++ TileLayer类代码示例发布时间: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