background
This commit is contained in:
parent
785453b009
commit
b5a253a865
5 changed files with 35 additions and 12 deletions
|
@ -6,6 +6,8 @@
|
|||
#include "TilePattern.hpp"
|
||||
#include <SFML/Graphics/Color.hpp>
|
||||
#include <SFML/Graphics/RectangleShape.hpp>
|
||||
#include <SFML/Graphics/Sprite.hpp>
|
||||
#include <SFML/Graphics/Texture.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/Window/Keyboard.hpp>
|
||||
#include <format>
|
||||
|
@ -14,8 +16,9 @@
|
|||
#include <string>
|
||||
|
||||
const sf::Time Game::TimePerFrame = sf::seconds(1.f / 60.f);
|
||||
sf::Texture bgTexture;
|
||||
|
||||
Game::Game() {
|
||||
Game::Game() : backGround(placeHolder) {
|
||||
assert(mFont.openFromFile("media/Sansation.ttf"));
|
||||
mStatisticsText.setPosition({5.f, 5.f});
|
||||
mStatisticsText.setCharacterSize(10);
|
||||
|
@ -41,6 +44,14 @@ Game::Game() {
|
|||
ScoreMultiplierText.setPosition({SCREEN_WIDTH - 200, 25});
|
||||
ScoreMultiplierText.setFillColor(sf::Color::Black);
|
||||
ScoreMultiplierText.setCharacterSize(20);
|
||||
|
||||
if (!bgTexture.loadFromFile("media/sprites/bureau.png")) {
|
||||
printf("sprite bureau not loaded\n");
|
||||
}
|
||||
backGround.setTexture(bgTexture, true);
|
||||
float sx = backGround.getTexture().getSize().x;
|
||||
float sy = backGround.getTexture().getSize().y;
|
||||
backGround.setScale(sf::Vector2f(SCREEN_WIDTH / sx, SCREEN_HEIGHT / sy));
|
||||
}
|
||||
|
||||
void generateTilePatternAndMusic(AudioEmitter &audio_emitter) {
|
||||
|
@ -109,6 +120,7 @@ void Game::update(const sf::Time elapsedTime) {}
|
|||
|
||||
void Game::render() {
|
||||
mWindow.clear(sf::Color::Yellow);
|
||||
mWindow.draw(backGround);
|
||||
mWindow.draw(leftPressZone);
|
||||
mWindow.draw(middlePressZone);
|
||||
mWindow.draw(rightPressZone);
|
||||
|
@ -139,6 +151,4 @@ void Game::update_scores(bool good_action) {
|
|||
ScoreText.setString(std::format("Score = {}", score));
|
||||
ScoreMultiplierText.setString(
|
||||
std::format("ScoreMultiplier = {}", score_multiplier));
|
||||
printf("good action : %d\n score %d\n score_multiplier %d\n ", good_action,
|
||||
score, score_multiplier);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue