aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-04-07 22:41:17 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-04-07 22:41:17 +0100
commit84408c209bc792d65fa3811f509abba3a0be3863 (patch)
tree17e19061ebb218b804a23db12c6de8f53b3fe3c5 /src
parent12d4a0a5ce85c4034832b7f29c42aaba3101f119 (diff)
downloadArider-84408c209bc792d65fa3811f509abba3a0be3863.tar.gz
Arider-84408c209bc792d65fa3811f509abba3a0be3863.zip
Removed unnecessary files and drawing everything
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp13
-rw-r--r--src/levelloader.cpp22
2 files changed, 21 insertions, 14 deletions
diff --git a/src/game.cpp b/src/game.cpp
index d2aa548..3a34715 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -39,12 +39,12 @@ void Game::initSystems()
initShaders();
player_.create(glm::vec2(0.f, 70.f), glm::vec2(66, 92), glm::vec2(5.f, 5.f));
- player_.animation_.pushFrame(AnimationState::IDLE, "res/textures/Player/p3_front.png");
+ player_.animation_.pushFrame(AnimationState::IDLE, "res/textures/Player/p2_front.png");
for(int i=1; i<=11; ++i)
if(i<10)
- player_.animation_.pushFrame(AnimationState::MOVING, "res/textures/Player/p3_walk/PNG/p3_walk0"+std::to_string(i)+".png");
+ player_.animation_.pushFrame(AnimationState::MOVING, "res/textures/Player/p2_walk/PNG/p2_walk0"+std::to_string(i)+".png");
else
- player_.animation_.pushFrame(AnimationState::MOVING, "res/textures/Player/p3_walk/PNG/p3_walk"+std::to_string(i)+".png");
+ player_.animation_.pushFrame(AnimationState::MOVING, "res/textures/Player/p2_walk/PNG/p2_walk"+std::to_string(i)+".png");
level_.loadLevel("res/levels/level1.txt");
}
@@ -134,13 +134,10 @@ void Game::renderSprites()
level_.drawLevel(sprite_batch_);
// drawing the player
- // player_.renderSprite(sprite_batch_);
+ player_.renderSprite(sprite_batch_);
// drawing the background
- // sprite_batch_.draw(glm::vec4(0.f, 0.f, 2560.f, 2560.f), glm::vec4(0.f, 0.f, 10.f, 10.f), yage::ResourceManager::getTexture("res/textures/bg_castle.png").id, yage::Color(255, 255, 255, 255), -2.f);
- // sprite_batch_.draw(glm::vec4(0.f, 280.f, 700.f, 70.f), glm::vec4(0.f, 0.f, 10.f, 1.f), yage::ResourceManager::getTexture("res/textures/Tiles/grassMid.png").id, yage::Color(255, 255, 255, 255), 0.f);
- // sprite_batch_.draw(glm::vec4(0.f, 0.f, 700.f, 70.f), glm::vec4(0.f, 0.f, 10.f, 1.f), yage::ResourceManager::getTexture("res/textures/Tiles/grassMid.png").id, yage::Color(255, 255, 255, 255), -1.f);
- // sprite_batch_.draw(glm::vec4(700.f, 0.f, 70.f, 70.f), glm::vec4(0.f, 0.f, 1.f, 1.f), yage::ResourceManager::getTexture("res/textures/Tiles/grassCliffRight.png").id, yage::Color(255, 255, 255, 255), -1.f);
+ sprite_batch_.draw(glm::vec4(0.f, 0.f, 2560.f, 2560.f), glm::vec4(0.f, 0.f, 10.f, 10.f), yage::ResourceManager::getTexture("res/textures/bg_castle.png").id, yage::Color(255, 255, 255, 255), -2.f);
sprite_batch_.end();
sprite_batch_.render();
diff --git a/src/levelloader.cpp b/src/levelloader.cpp
index eb4f38e..88a2ba4 100644
--- a/src/levelloader.cpp
+++ b/src/levelloader.cpp
@@ -24,30 +24,40 @@ void Level::loadLevel(const std::string &level_path)
std::string level_line;
while(getline(level_file, level_line))
{
- level_+=level_line;
- if(width_<(int)level_line.length())
- width_=level_line.length();
+ int width=0;
+ for(auto &&character : level_line)
+ if(character!=' ')
+ {
+ level_+=character;
+ ++width;
+ }
+
+ if(width>width_)
+ width_=width;
++height_;
}
}
void Level::drawLevel(yage::SpriteBatch &sprite_batch)
{
+ const float block_size=70.f;
for(int i=0; i<(int)level_.size(); ++i)
{
switch(level_[i])
{
case 'b': // brick
- sprite_batch.draw(glm::vec4(70*(i%width_), 70*(height_-i/width_-1), 70.f, 70.f), glm::vec4(0.f, 0.f, 1.f, 1.f), yage::ResourceManager::getTexture("res/textures/Tiles/stoneMid.png").id, yage::Color(255, 255, 255, 255), 5.f);
+ sprite_batch.draw(glm::vec4(block_size*(i%width_), block_size*(height_-i/width_-1), block_size, block_size), glm::vec4(0.f, 0.f, 1.f, 1.f), yage::ResourceManager::getTexture("res/textures/Tiles/stoneCenter.png").id, yage::Color(255, 255, 255, 255), -1.f);
+ case 't': // top brick
+ sprite_batch.draw(glm::vec4(block_size*(i%width_), block_size*(height_-i/width_-1), block_size, block_size), glm::vec4(0.f, 0.f, 1.f, 1.f), yage::ResourceManager::getTexture("res/textures/Tiles/stoneMid.png").id, yage::Color(255, 255, 255, 255), -1.f);
break;
- case 'e': // empty
+ case '.': // empty
break;
case '@': // player
break;
case ' ':
break;
default:
- throw std::runtime_error("Could not recognize '"+std::to_string(level_[i])+"' in level file");
+ throw std::runtime_error("Could not recognize '"+std::to_string((const char)level_[i])+"' in level file");
}
}
}