diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-06-13 17:44:22 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-06-13 17:44:22 +0100 |
commit | 7004d04c37b88c6764d856f4cd77787d84991b1c (patch) | |
tree | abc2d935501f0e05a88d9213ed18c56111e7ac2e | |
parent | adabce14530863b2d51156de1e415e7fc0226bc9 (diff) | |
download | Arider-7004d04c37b88c6764d856f4cd77787d84991b1c.tar.gz Arider-7004d04c37b88c6764d856f4cd77787d84991b1c.zip |
Fixing game engine
-rw-r--r-- | CMakeLists.txt | 3 | ||||
m--------- | YAGE | 0 | ||||
-rw-r--r-- | src/level.cpp | 78 | ||||
-rw-r--r-- | src/particle.cpp | 4 |
4 files changed, 44 insertions, 41 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d9b3b3a..f54204d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,8 @@ set(ARIDER_TEST_DIR ${CMAKE_SOURCE_DIR}/test) # setting right output directory set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) -set(YAGE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/YAGE/include/) +set(YAGE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/YAGE/include/ + ${CMAKE_SOURCE_DIR}/YAGE/include/YAGE/) set(YAGE_LIBRARIES yage) # setting up configuration header diff --git a/YAGE b/YAGE -Subproject 15255aa1b763590e97f0795039868e2b9fb599e +Subproject 61e7d329c6bafaf269a619ffb2bb80a24b1fb21 diff --git a/src/level.cpp b/src/level.cpp index f3219a8..9d4176d 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -11,53 +11,53 @@ void Level::loadLevel(const std::string &level_path) { - std::ifstream level_file(level_path); + std::ifstream level_file(level_path); - if(!level_file.is_open()) - throw std::runtime_error("Could not load level: '"+level_path+"'"); + if(!level_file.is_open()) + throw std::runtime_error("Could not load level: '"+level_path+"'"); - // initialize inputs to be empty - level_=""; - width_=0; - height_=0; + // initialize inputs to be empty + level_=""; + width_=0; + height_=0; - std::string level_line; - while(getline(level_file, level_line)) - { - int width=0; - for(auto &&character : level_line) - if(character!=' ') - { - level_+=character; - ++width; - } + std::string level_line; + while(getline(level_file, level_line)) + { + int width=0; + for(auto &&character : level_line) + if(character!=' ') + { + level_+=character; + ++width; + } - if(width>width_) - width_=width; - ++height_; - } + 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]) + const float block_size=70.f; + for(int i=0; i<(int)level_.size(); ++i) { - case 'b': // 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/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 '.': // empty - break; - case '@': // player - break; - case ' ': - break; - default: - throw std::runtime_error("Could not recognize '"+std::to_string((const char)level_[i])+"' in level file"); + switch(level_[i]) + { + case 'b': // 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/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/grassMid.png").id, yage::Color(255, 255, 255, 255), -1.f); + break; + case '.': // empty + break; + case '@': // player + break; + case ' ': + break; + default: + throw std::runtime_error("Could not recognize '"+std::to_string((const char)level_[i])+"' in level file"); + } } - } } diff --git a/src/particle.cpp b/src/particle.cpp index f968f73..236c83c 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -1,8 +1,10 @@ #include "particle.hpp" +#include <YAGE/Math/vector2d.hpp> + #include <YAGE/resourcemanager.hpp> -Particle::Particle() : particle_body_(glm::vec2(200.f/70.f, 600.f/70.f)) +Particle::Particle() : particle_body_(yage::Vector2D(200.f/70.f, 600.f/70.f)) {} Particle::~Particle() |