Exemplo n.º 1
0
	ZeldaGame::ZeldaGame(Application& app, const std::string& fileName, const sf::Transform& pixelToWorld)
		: Game(app)
		, mPlayerID(-1)
		, mpCamera(nullptr)
	{
		setPixelToWorldTransform(pixelToWorld);
		getTextureManager().loadSpritesheet("src/Zelda/textures/inigo_spritesheet.xml");
		getTextureManager().loadAnimations("src/Zelda/textures/inigo_animation.xml");
		getTextureManager().loadSpritesheet("assets/spritesheets/hero/hero.xml");
		getTextureManager().loadSpritesheet("assets/spritesheets/priest/priest.xml");
		loadMap(fileName);
	}
Exemplo n.º 2
0
	void ZeldaGame::loadMap(const std::string& fileName)
	{
		TMX tmx(fileName);

		TMX::Object* pPlayer = nullptr;
		int playerSortOrder = 0;
		std::vector<TMX::ObjectGroup> objectGroups = tmx.getObjectGroups();
		for (auto& objectGroup : objectGroups)
		{
			for (auto& object : objectGroup.objects)
			{
				if (object.name == "Player")
				{
					if (pPlayer != nullptr) { throw std::runtime_error("Multiple Player objects found."); }
					pPlayer = &object;
					playerSortOrder = objectGroup.index;
				}
			}
		}
		if (pPlayer == nullptr) { throw std::runtime_error("No Player object found."); }

		auto upPlayer = Player::make(*this, *pPlayer);
		upPlayer->setDrawOrder(playerSortOrder);
		mPlayerID = upPlayer->getID();
		getSceneGraph().attachNode(std::move(upPlayer));

		mpCamera = std::make_unique<Camera>(getEntityManager(), mPlayerID, sf::Vector2f(16 * 24.f, 9 * 24.f));

		setTileMap(TileMap::make(*this, getTextureManager(), std::move(tmx)));
		getMap().setDrawColliderEnabled(true);
		getMap().setDrawNavGraphEnabled(true);

		// TODO: DELETE SECOND MAP
		auto upMap2 = TileMap::make(*this, getTextureManager(), TMX{fileName});
		upMap2->setDrawColliderEnabled(true);
		upMap2->setDrawNavGraphEnabled(true);
		getMap().stitch(sf::Vector2i{ 0, 0 }, *upMap2, sf::Vector2i{ 0, 20 });
		auto* pMap = upMap2.get();
		getMap().attachNode(std::move(upMap2));

		auto upMap3 = TileMap::make(*this, getTextureManager(), TMX{fileName});
		pMap->stitch({ 0, 0 }, *upMap3, { 30, 0 });
		getMap().attachNode(std::move(upMap3));

		//getMap().move({ -4, 0 });
	}
Exemplo n.º 3
0
void Chunk::refreshBlend()
{
	//refreshVB_();
	if (AlphaMapTexture_ == NULL)
	{
		AlphaMapTexture_ = getTextureManager()->createTexture(tAlphaMapUnCompressedSize, tAlphaMapUnCompressedSize, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED);
	}
	AlphaMapTexture_->setSubData(0, 0, tAlphaMapUnCompressedSize, tAlphaMapUnCompressedSize, &AlphaMapUnCompressed_[0], D3DFMT_A8R8G8B8, tAlphaMapUnCompressedSize*sizeof(u32));
}
Exemplo n.º 4
0
void VoxelView::init()
{
  VOXELHEIGHT=h;
  int x,y;
  Color c;

  calcShadow();

  for(x=0;x<w;x++)
    for(y=0;y<h;y++)
      {
        Pos2D p2(x,y);
        c=trace(p2);
        if(c.a>=0)
          {
            sge_PutPixel(s,x,y,c.toColor(s));

          }
      }
  mSurface=getSurfaceManager()->fromSDL(s);
  mTexture=new AGTexture(getTextureManager()->makeTexture(mSurface));
  return;
}
Exemplo n.º 5
0
void Chunk::setLayer( eTerrainLayer e, const tstring & resourceID)
{
	layers_[e] = getTextureManager()->getTexture(resourceID);
}