aboutsummaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-03-21 14:52:18 +0100
committerCharles <sircharlesaze@gmail.com>2020-03-21 14:52:18 +0100
commit0cebd4ae751e0554f948389654fe4ad7e92943f0 (patch)
tree462aecb04faebfda04a56c93c820a32df6cdac23 /src/graphics.cpp
parentad8ae988ba1928af5063ca1dc7375356e467979b (diff)
downloadmario_sokoban-0cebd4ae751e0554f948389654fe4ad7e92943f0.tar.gz
mario_sokoban-0cebd4ae751e0554f948389654fe4ad7e92943f0.tar.bz2
mario_sokoban-0cebd4ae751e0554f948389654fe4ad7e92943f0.zip
Game logic finished (moving player, crates, checking win)
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 734fd12..b773827 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -13,6 +13,7 @@ Graphics::Graphics(Game &game, std::string title, int width, int height):
error();
m_wallTex = loadImage("sprite/wall.jpg");
m_crateTex = loadImage("sprite/crate.jpg");
+ m_crateSolvedTex = loadImage("sprite/crate_solved.jpg");
m_payloadTex = loadImage("sprite/payload.png");
m_playerTex = loadImage("sprite/mario_down.gif");
}
@@ -21,6 +22,7 @@ Graphics::~Graphics()
{
SDL_DestroyTexture(m_playerTex);
SDL_DestroyTexture(m_payloadTex);
+ SDL_DestroyTexture(m_crateSolvedTex);
SDL_DestroyTexture(m_crateTex);
SDL_DestroyTexture(m_wallTex);
SDL_DestroyRenderer(m_renderer);
@@ -72,6 +74,9 @@ void Graphics::drawCell(Game::Cell cell, int y, int x)
case Game::CellCrate:
putImage(m_crateTex, &r);
break;
+ case Game::CellCrateSolved:
+ putImage(m_crateSolvedTex, &r);
+ break;
case Game::CellPayload:
SDL_SetRenderDrawColor(m_renderer, 100, 100, 100, 255);
SDL_RenderFillRect(m_renderer, &r);
@@ -93,7 +98,6 @@ void Graphics::drawPlayer()
r.w = m_width / m_game.getWidth();
r.h = m_height / m_game.getHeight();
putImage(m_playerTex, &r);
-
}
void Graphics::handleEvent()
@@ -123,6 +127,8 @@ void Graphics::handleEvent()
m_game.move(Game::DirectionRight);
break;
}
+ if (m_game.won())
+ m_running = false;
}
}
}