This commit is contained in:
Crizomb 2025-06-10 17:40:16 +02:00
commit f698a38c7e
585 changed files with 118338 additions and 0 deletions

View file

@ -0,0 +1,34 @@
#include <fmod.hpp>
#include <fmod_errors.h>
#include <memory>
#include <vector>
class AudioEmitter {
private:
std::unique_ptr<FMOD::System> system;
FMOD::Channel* timer{ nullptr };
std::vector <std::unique_ptr<FMOD::Sound>> chords;
std::vector<std::unique_ptr<FMOD::Sound>> drums;
std::vector<std::unique_ptr<FMOD::Sound>> notes;
int tempo{ 170 };
std::vector<std::vector<float>> markov_matrix_chords;
std::vector<std::vector<float>> markov_matrix_melody;
int nbr_melo_max{ 4 };
int current_beat{ 0 };
std::vector<std::vector<float>> rythmes;
int index_note;
std::vector<int> chordProgression;
std::vector<FMOD::Channel*> activeChannels;
public:
AudioEmitter();
void generateMusic();
void audioUpdate();
void audioEnd();
int firstChord();
int nextChord(int currentChord);
int firstNote();
int nextNote(int currentNote);
int noteSecondaire(int note);
float getTime();
float timeBeforeNewGeneration{ 0.2f };
};

View file

@ -0,0 +1,34 @@
#ifndef BOOK_GAME_HPP
#define BOOK_GAME_HPP
#include "RoundTarget.hpp"
#include <SFML/Graphics.hpp>
#include "AudioEmitter.hpp"
class Game {
public:
Game();
Game(const Game &) = delete;
Game &operator=(const Game &) = delete;
void run();
private:
void processEvents(AudioEmitter& audioEmitter);
void update(sf::Time elapsedTime);
void render();
void updateStatistics(AudioEmitter& audioEmitter);
static const sf::Time TimePerFrame;
sf::RenderWindow mWindow{sf::VideoMode({640, 480}), "SFML Application"};
sf::Texture mTexture;
RoundTarget mTarget{35.f, sf::Color::Red, 320.f, 300.f};
sf::Font mFont;
sf::Text mStatisticsText{mFont};
sf::Time mStatisticsUpdateTime;
std::size_t mStatisticsNumFrames{0};
};
#endif // BOOK_GAME_HPP

View file

@ -0,0 +1,22 @@
#ifndef SIMPLE_GAME_ROUND_TARGET_H
#define SIMPLE_GAME_ROUND_TARGET_H
#include <SFML/Graphics.hpp>
class RoundTarget {
public:
RoundTarget(float radius, sf::Color color, float x, float y);
void drawCurrent(sf::RenderWindow &window) const;
void handlePlayerInput(const sf::Keyboard::Key &key, const bool &isPressed);
void update(const sf::Time &elapsedTime);
private:
static constexpr float TargetSpeed{100.f};
bool mIsMovingUp{false};
bool mIsMovingDown{false};
bool mIsMovingRight{false};
bool mIsMovingLeft{false};
sf::CircleShape mShape;
};
#endif // SIMPLE_GAME_ROUND_TARGET_H