Skip to content

Commit

Permalink
finished t3
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-tomas committed Jun 30, 2022
1 parent c76c559 commit 516d57f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions header/TileMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TileMap : public Component {
bool Is(const char* type);
void Render();
void RenderLayer(int layer, int cameraX = 0, int cameraY = 0);
~TileMap();
int GetWidth();
int GetHeight();
int GetDepth();
Expand Down
2 changes: 1 addition & 1 deletion src/Face.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void Face::Damage(int damage)
cout << "HP is " << hitpoints << endl;
}

// @TODO: como face e uma classe temporaria, o request delete foi
// Como face e uma classe temporaria, o request delete foi
// movido de damage para update para melhorar o funcionamento do jogo.
void Face::Update(float dt)
{
Expand Down
7 changes: 3 additions & 4 deletions src/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ SDL_Texture* Resources::GetImage(const char* file)

else
{
imageTable.insert(make_pair(file, texture));
// imageTable[file] = texture; // @TODO: possible solution?
imageTable[file] = texture;
cout << "\nTexture " << file << " loaded successfully!" << endl;
return imageTable[file];
}
Expand All @@ -44,7 +43,7 @@ Mix_Music* Resources::GetMusic(const char* file)

else
{
musicTable.insert(make_pair(file, music));
musicTable[file] = music;
cout << "\nMusic " << file << " loaded successfully!" << endl;
return musicTable[file];
}
Expand All @@ -66,7 +65,7 @@ Mix_Chunk* Resources::GetSound(const char* file)

else
{
soundTable.insert(make_pair(file, chunk));
soundTable[file] = chunk;
cout << "\nSound " << file << " loaded successfully!" << endl;
return soundTable[file];
}
Expand Down
2 changes: 1 addition & 1 deletion src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ State::State() :
{
// Tileset & Tilemap
GameObject* tileGo = new GameObject();
TileSet* tileSet = new TileSet(64, 64, "./assets/image/tileset.png"); // @TODO: delete tileset when finished
TileSet* tileSet = new TileSet(64, 64, "./assets/image/tileset.png");
TileMap* tileMap = new TileMap(*tileGo, "./assets/map/tileMap.txt", tileSet);

tileGo->box.x = 0;
Expand Down
11 changes: 7 additions & 4 deletions src/TileMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,11 @@ void TileMap::SetTileSet(TileSet* tileSet)

int& TileMap::At(int x, int y, int z)
{
// @TODO: check
// Index = (W * H * Z) + (W * Y) + X
unsigned index = x + (mapWidth * y) + (mapWidth * mapHeight * z);
return tileMatrix[index];
}

// @TODO: check
void TileMap::RenderLayer(int layer, int cameraX, int cameraY)
{
unsigned startPos = mapWidth * mapHeight * layer;
Expand All @@ -91,8 +89,6 @@ void TileMap::RenderLayer(int layer, int cameraX, int cameraY)
}
}

// @TODO: why use the box?
// RenderLayer(i, associated.box.x, associated.box.y);
void TileMap::Render()
{
for (auto i = 0; i < mapDepth; i++)
Expand All @@ -110,6 +106,13 @@ bool TileMap::Is(const char* type)
return (str_type == "TileMap");
}

// @TODO: needs to be changed when using multiple tilemaps for the same tileset!
TileMap::~TileMap()
{
delete tileSet;
cout << "TileSet deleted successfully!" << endl;
}

int TileMap::GetWidth()
{
return mapWidth;
Expand Down

0 comments on commit 516d57f

Please sign in to comment.