r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
gme::Game Class Referencefinal

Game solo scene. More...

#include <Game.hpp>

+ Inheritance diagram for gme::Game:
+ Collaboration diagram for gme::Game:

Public Member Functions

 Game (eng::id assignedId, const std::shared_ptr< eng::IRenderer > &renderer, const std::shared_ptr< eng::IAudio > &audio, bool &showDebug, int skinIndex=0, const std::string &playerName="Player")
 
 ~Game () override=default
 
 Game (const Game &other)=delete
 
Gameoperator= (const Game &other)=delete
 
 Game (Game &&other)=delete
 
Gameoperator= (Game &&other)=delete
 
void update (float dt, const eng::WindowSize &size) override
 
void event (const eng::Event &event) override
 
bool & playMusic ()
 
- Public Member Functions inherited from eng::AScene
 AScene (const id assignedId)
 
 ~AScene () override=default
 
 AScene (const AScene &other)=delete
 
 AScene (AScene &&other)=delete
 
ASceneoperator= (const AScene &other)=delete
 
ASceneoperator= (AScene &&other)=delete
 
std::string & getName () override
 
id getId () const override
 
ecs::RegistrygetRegistry () override
 
void setName (const std::string &newName) override
 
void addSystem (std::unique_ptr< ecs::ISystem > system) override
 
void updateSystems (const float dt) override
 
- Public Member Functions inherited from eng::IScene
virtual ~IScene ()=default
 

Private Member Functions

ecs::Entity createPlayer (ecs::Registry &registry)
 
std::pair< ecs::Entity, ecs::EntitycreatePipePair (ecs::Registry &registry, float x, float gapY) const
 
void resetGame ()
 
bool checkCircleCollision (float x1, float y1, float r1, float x2, float y2, float r2) const
 
bool checkCircleRectCollision (float circleX, float circleY, float circleR, float rectX, float rectY, float rectW, float rectH) const
 
void checkCollisions (ecs::Registry &registry)
 
void checkScore (ecs::Registry &registry)
 
void drawDebugRectangles (ecs::Registry &registry) const
 

Private Attributes

const std::shared_ptr< eng::IRenderer > & m_renderer
 
const std::shared_ptr< eng::IAudio > & m_audio
 
std::unordered_map< eng::Key, bool > m_keysPressed
 
ecs::Entity m_playerEntity
 
ecs::Entity m_playerNameEntity
 
ecs::Entity m_looseText
 
ecs::Entity m_flapSound
 
ecs::Entity m_looseSound
 
ecs::Entity m_scoreEntity
 
std::vector< std::pair< ecs::Entity, ecs::Entity > > m_pipes
 
std::vector< bool > m_pipeScored
 
bool & m_showDebug
 
bool m_playMusic = false
 
bool m_gameOver = false
 
bool m_gameOverShown = false
 
int m_score = 0
 
int m_skinIndex
 
std::string m_playerName
 

Additional Inherited Members

- Protected Attributes inherited from eng::AScene
utl::EventBusm_eventBus = utl::EventBus::getInstance()
 
std::uint32_t m_eventComponentId = 0
 

Detailed Description

Game solo scene.

Definition at line 22 of file Game.hpp.

Constructor & Destructor Documentation

◆ Game() [1/3]

gme::Game::Game ( eng::id assignedId,
const std::shared_ptr< eng::IRenderer > & renderer,
const std::shared_ptr< eng::IAudio > & audio,
bool & showDebug,
int skinIndex = 0,
const std::string & playerName = "Player" )

◆ ~Game()

gme::Game::~Game ( )
overridedefault

◆ Game() [2/3]

gme::Game::Game ( const Game & other)
delete

◆ Game() [3/3]

gme::Game::Game ( Game && other)
delete

Member Function Documentation

◆ checkCircleCollision()

bool gme::Game::checkCircleCollision ( float x1,
float y1,
float r1,
float x2,
float y2,
float r2 ) const
private

Definition at line 404 of file game.cpp.

◆ checkCircleRectCollision()

bool gme::Game::checkCircleRectCollision ( float circleX,
float circleY,
float circleR,
float rectX,
float rectY,
float rectW,
float rectH ) const
private

Definition at line 414 of file game.cpp.

◆ checkCollisions()

void gme::Game::checkCollisions ( ecs::Registry & registry)
private

Definition at line 426 of file game.cpp.

References ecs::Registry::getComponent(), ecs::Transform::x, and ecs::Transform::y.

+ Here is the call graph for this function:

◆ checkScore()

void gme::Game::checkScore ( ecs::Registry & registry)
private

Definition at line 475 of file game.cpp.

References ecs::Registry::getComponent(), and ecs::Transform::x.

+ Here is the call graph for this function:

◆ createPipePair()

std::pair< ecs::Entity, ecs::Entity > gme::Game::createPipePair ( ecs::Registry & registry,
float x,
float gapY ) const
private

Definition at line 319 of file game.cpp.

References ecs::Registry::createEntity(), and ecs::Registry::EntityBuilder::with().

Referenced by Game().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createPlayer()

ecs::Entity gme::Game::createPlayer ( ecs::Registry & registry)
private

◆ drawDebugRectangles()

void gme::Game::drawDebugRectangles ( ecs::Registry & registry) const
private

Definition at line 513 of file game.cpp.

References ecs::Registry::getComponent(), eng::Color::r, ecs::Transform::x, and ecs::Transform::y.

+ Here is the call graph for this function:

◆ event()

void gme::Game::event ( const eng::Event & event)
overridevirtual

Implements eng::IScene.

Definition at line 278 of file game.cpp.

References eng::Event::key, eng::KeyPressed, ecs::Audio::play, eng::R, eng::Space, and eng::Event::type.

◆ operator=() [1/2]

Game & gme::Game::operator= ( const Game & other)
delete

◆ operator=() [2/2]

Game & gme::Game::operator= ( Game && other)
delete

◆ playMusic()

bool & gme::Game::playMusic ( )
inline

Definition at line 37 of file Game.hpp.

References m_playMusic.

◆ resetGame()

void gme::Game::resetGame ( )
private

Definition at line 354 of file game.cpp.

References getGapSize(), randomPipeType(), and ecs::Transform::x.

+ Here is the call graph for this function:

◆ update()

void gme::Game::update ( float dt,
const eng::WindowSize & size )
overridevirtual

Implements eng::IScene.

Definition at line 178 of file game.cpp.

References getGapSize(), eng::WindowSize::height, randomPipeType(), eng::WindowSize::width, ecs::Transform::x, ecs::Velocity::x, ecs::Transform::y, and ecs::Velocity::y.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_audio

const std::shared_ptr<eng::IAudio>& gme::Game::m_audio
private

Definition at line 50 of file Game.hpp.

◆ m_flapSound

ecs::Entity gme::Game::m_flapSound
private

Definition at line 55 of file Game.hpp.

Referenced by Game().

◆ m_gameOver

bool gme::Game::m_gameOver = false
private

Definition at line 62 of file Game.hpp.

◆ m_gameOverShown

bool gme::Game::m_gameOverShown = false
private

Definition at line 63 of file Game.hpp.

◆ m_keysPressed

std::unordered_map<eng::Key, bool> gme::Game::m_keysPressed
private

Definition at line 51 of file Game.hpp.

◆ m_looseSound

ecs::Entity gme::Game::m_looseSound
private

Definition at line 56 of file Game.hpp.

Referenced by Game().

◆ m_looseText

ecs::Entity gme::Game::m_looseText
private

Definition at line 54 of file Game.hpp.

Referenced by Game().

◆ m_pipes

std::vector<std::pair<ecs::Entity, ecs::Entity> > gme::Game::m_pipes
private

Definition at line 58 of file Game.hpp.

Referenced by Game().

◆ m_pipeScored

std::vector<bool> gme::Game::m_pipeScored
private

Definition at line 59 of file Game.hpp.

Referenced by Game().

◆ m_playerEntity

ecs::Entity gme::Game::m_playerEntity
private

Definition at line 52 of file Game.hpp.

Referenced by Game().

◆ m_playerName

std::string gme::Game::m_playerName
private

Definition at line 66 of file Game.hpp.

Referenced by Game().

◆ m_playerNameEntity

ecs::Entity gme::Game::m_playerNameEntity
private

Definition at line 53 of file Game.hpp.

Referenced by Game().

◆ m_playMusic

bool gme::Game::m_playMusic = false
private

Definition at line 61 of file Game.hpp.

Referenced by playMusic().

◆ m_renderer

const std::shared_ptr<eng::IRenderer>& gme::Game::m_renderer
private

Definition at line 49 of file Game.hpp.

Referenced by Game().

◆ m_score

int gme::Game::m_score = 0
private

Definition at line 64 of file Game.hpp.

◆ m_scoreEntity

ecs::Entity gme::Game::m_scoreEntity
private

Definition at line 57 of file Game.hpp.

Referenced by Game().

◆ m_showDebug

bool& gme::Game::m_showDebug
private

Definition at line 60 of file Game.hpp.

◆ m_skinIndex

int gme::Game::m_skinIndex
private

Definition at line 65 of file Game.hpp.


The documentation for this class was generated from the following files: