diff --git a/SimpleGame/src/Include/GameData.hpp b/SimpleGame/src/Include/GameData.hpp index b56f9ab..3f8a489 100644 --- a/SimpleGame/src/Include/GameData.hpp +++ b/SimpleGame/src/Include/GameData.hpp @@ -11,6 +11,7 @@ static constexpr unsigned int MIDDLE_HEIGHT = SCREEN_HEIGHT / 2; static constexpr unsigned int NOTE_PLACE_X_POS[3] = { SCREEN_WIDTH * 6 / 10, SCREEN_WIDTH * 7 / 10, SCREEN_WIDTH * 8 / 10}; +static constexpr unsigned int FLOWER_SIZE = SCREEN_WIDTH * 0.05; namespace sf { class Texture; }; diff --git a/SimpleGame/src/Source/NoteSprite.cpp b/SimpleGame/src/Source/NoteSprite.cpp index e4623b3..8aa3540 100644 --- a/SimpleGame/src/Source/NoteSprite.cpp +++ b/SimpleGame/src/Source/NoteSprite.cpp @@ -1,11 +1,12 @@ #include "NoteSprite.hpp" +#include "GameData.hpp" #include #include #include #include #include #include -//#include +// #include #include sf::Texture NoteSprite::texture; @@ -15,11 +16,6 @@ bool NoteSprite::loadTexture(const std::string &filename) { } NoteSprite::NoteSprite() : sprite(sf::Sprite(texture)), fall_speed(0.f) {}; -NoteSprite::NoteSprite(sf::Vector2f start_pos, float fall_speed) - : fall_speed(fall_speed), sprite(sf::Sprite(NoteSprite::texture)) { - sprite.setPosition(start_pos); // sprite position c'est le left up corner - sprite.setColor(sf::Color::Yellow); -}; void NoteSprite::update(float dtime, sf::RenderWindow &window) { sprite.move(sf::Vector2f(0, fall_speed * dtime)); diff --git a/SimpleGame/src/Source/NoteTile.cpp b/SimpleGame/src/Source/NoteTile.cpp index 9864737..6fc12c3 100644 --- a/SimpleGame/src/Source/NoteTile.cpp +++ b/SimpleGame/src/Source/NoteTile.cpp @@ -1,6 +1,7 @@ #include "NoteTile.hpp" #include "GameData.hpp" #include "NoteSprite.hpp" +#include #include #include #include @@ -16,7 +17,10 @@ NoteTile::NoteTile(float play_time, float good_interval, NotePlaceEnum place, note_sprite.sprite.setPosition(sf::Vector2f( NOTE_PLACE_X_POS[place], NOTE_PRESS_HEIGHT - note_sprite.fall_speed * (play_time - current_time))); -} + + float s = FLOWER_SIZE / note_sprite.sprite.getTexture().getSize().x; + note_sprite.sprite.setScale(sf::Vector2f(s, s)); +}; // public void NoteTile::create(float play_time, float good_interval, NotePlaceEnum place,