Fixing the 1 frame bug

This commit is contained in:
Ulysse Cura 2024-10-17 20:38:11 +02:00
parent 5db7b6a448
commit 70e3c70d3d
1 changed files with 5 additions and 3 deletions

View File

@ -100,8 +100,8 @@ void TileMap::LoadTileMap(const string &path)
// Erase lasts entities and load news if there are some
std::size_t numberOfEntity {Game::entityManager.getNumberOfEntity()};
for(std::size_t i {1}; i < numberOfEntity; i++) Game::entityManager.erase(i);
for(std::size_t i {1}; i < numberOfEntity; i++) Game::entityManager.destroy(i);
Game::entityManager.refresh();
if(mapData->contains("Entities"))
{
@ -118,7 +118,7 @@ void TileMap::LoadTileMap(const string &path)
pos = pos * TILE_SIZE * TILEMAP_SCALE;
e.addComponent<TransformComponent>(pos, dim, component->at("Scale").get<int>(), component->at("Speed").get<int>());
e.addComponent<TransformComponent>(pos, dim, component->at("Scale").get<int>(), component->at("Speed").get<float>());
}
else if(component->at("Type").get<string>() == "SpriteComponent")
{
@ -160,8 +160,10 @@ void TileMap::LoadTileMap(const string &path)
}
}
}
Game::entityManager.update();
// Texture renderer creating
if(Game::textureRenderer != NULL) SDL_DestroyTexture(Game::textureRenderer);
Game::textureRenderer = SDL_CreateTexture(Game::renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, worldWidth, worldHeight);
if(Game::textureRenderer == NULL)
{