From 5d8cdf9c79a070299171271b472d4b2c05c8ed87 Mon Sep 17 00:00:00 2001 From: "DESKTOP-DAVIDE\\Davide" Date: Sun, 7 Jul 2019 16:30:03 +0200 Subject: [PATCH] doxygen --- Arkanoid/Arkanoid.vcxproj.filters | 2 +- Arkanoid/CollisionDetector.h | 3 ++ Arkanoid/GameOverWatcherComponent.h | 4 +++ Arkanoid/GameState.h | 7 ++-- Arkanoid/NullAudio.h | 4 +++ Arkanoid/NullTextureService.h | 4 +++ Arkanoid/PCAudioService.h | 4 +++ Arkanoid/PCTextureService.h | 4 +++ Arkanoid/PaddleBehaviorComponent.cpp | 54 ---------------------------- Arkanoid/PowerUpService.cpp | 2 +- Arkanoid/PowerUpService.h | 3 ++ Arkanoid/PowerUpStickyComponent.h | 4 +++ Arkanoid/ServiceLocator.h | 3 ++ Arkanoid/mainpage.dox | 25 +++++++++++-- Arkanoid/resources/settings.json | 2 +- 15 files changed, 64 insertions(+), 61 deletions(-) diff --git a/Arkanoid/Arkanoid.vcxproj.filters b/Arkanoid/Arkanoid.vcxproj.filters index 1a009a8..ede5f2f 100644 --- a/Arkanoid/Arkanoid.vcxproj.filters +++ b/Arkanoid/Arkanoid.vcxproj.filters @@ -181,7 +181,7 @@ Header Files\Textures - Header Files + Header Files\Textures diff --git a/Arkanoid/CollisionDetector.h b/Arkanoid/CollisionDetector.h index 040c5d2..d92ee29 100644 --- a/Arkanoid/CollisionDetector.h +++ b/Arkanoid/CollisionDetector.h @@ -14,6 +14,9 @@ bool AABBvsAABB(BaseComponent*, BaseComponent*, sf::Vector2f&); bool AABBvsCircle(BaseComponent*, BaseComponent*, sf::Vector2f&); bool CirclevsCircle(BaseComponent*, BaseComponent*, sf::Vector2f&); +/// +/// A utility class that implements a few collision detection algorithms. +/// class CollisionDetector { public: diff --git a/Arkanoid/GameOverWatcherComponent.h b/Arkanoid/GameOverWatcherComponent.h index 6d6d413..40d1f0a 100644 --- a/Arkanoid/GameOverWatcherComponent.h +++ b/Arkanoid/GameOverWatcherComponent.h @@ -5,6 +5,10 @@ #include +/// +/// Component that listens for ball lost and game over messages. +/// +/// class GameOverWatcherComponent : public BaseComponent { diff --git a/Arkanoid/GameState.h b/Arkanoid/GameState.h index 5f5e8c2..f7c2fc4 100644 --- a/Arkanoid/GameState.h +++ b/Arkanoid/GameState.h @@ -69,7 +69,7 @@ class GameState : EntityID createEntity(EntityType type); /// - /// Variadic template funciton that adds a new component. + /// Variadic template function that adds a new component and returns a casted pointer to it. /// /// The type ID of the component. /// The entity identifier. @@ -111,7 +111,7 @@ class GameState : int getPlayerLives() const; /// - /// Games the over. + /// Manages game over changes. /// /// if set to true will be shown a winning text, else a losing text [win]. void gameOver(bool win); @@ -221,6 +221,9 @@ class GameState : /// std::unordered_map mEntityMap; + /// + /// Vector of entities slated for removal at the end of the current update loop + /// std::vector mZombieEntities; PaddleBehaviorComponent* mPaddleBehaviorComp; diff --git a/Arkanoid/NullAudio.h b/Arkanoid/NullAudio.h index 85e3f71..d50a222 100644 --- a/Arkanoid/NullAudio.h +++ b/Arkanoid/NullAudio.h @@ -5,6 +5,10 @@ #include +/// +/// To disable sound. Useful for development. +/// +/// class NullAudioService : public AudioService { diff --git a/Arkanoid/NullTextureService.h b/Arkanoid/NullTextureService.h index 9d1cb05..b38fda3 100644 --- a/Arkanoid/NullTextureService.h +++ b/Arkanoid/NullTextureService.h @@ -3,6 +3,10 @@ #include "TextureService.h" +/// +/// To disable the Texture Service. Useful as a placeholder. +/// +/// class NullTextureService : public TextureService { diff --git a/Arkanoid/PCAudioService.h b/Arkanoid/PCAudioService.h index daa47fb..d3203c1 100644 --- a/Arkanoid/PCAudioService.h +++ b/Arkanoid/PCAudioService.h @@ -12,6 +12,10 @@ using SoundIDFilename = std::pair; using MusicIDFilename = std::pair; +/// +/// Implementation of the Audio Service for PC. +/// +/// class PCAudioService : public AudioService { diff --git a/Arkanoid/PCTextureService.h b/Arkanoid/PCTextureService.h index 05c49c0..5a60441 100644 --- a/Arkanoid/PCTextureService.h +++ b/Arkanoid/PCTextureService.h @@ -8,6 +8,10 @@ using TextureIDFilename = std::tuple; +/// +/// Implements the Texture Service on PC. +/// +/// class PCTextureService : public TextureService { diff --git a/Arkanoid/PaddleBehaviorComponent.cpp b/Arkanoid/PaddleBehaviorComponent.cpp index 200dfe3..de05a94 100644 --- a/Arkanoid/PaddleBehaviorComponent.cpp +++ b/Arkanoid/PaddleBehaviorComponent.cpp @@ -201,60 +201,6 @@ bool PaddleBehaviorComponent::isDisabled() const void PaddleBehaviorComponent::changeState(PaddleState newState) { - std::string currentState, newStateString, prevState; - switch (mState) - { - case PaddleState::STATE_NORMAL: - currentState = "STATE_NORMAL"; - break; - case PaddleState::STATE_STICKY: - currentState = "STATE_STICKY"; - break; - case PaddleState::STATE_DISABLED: - currentState = "STATE_DISABLED"; - break; - case PaddleState::STATE_START: - currentState = "STATE_START"; - break; - } - - switch (newState) - { - case PaddleState::STATE_NORMAL: - newStateString = "STATE_NORMAL"; - break; - case PaddleState::STATE_STICKY: - newStateString = "STATE_STICKY"; - break; - case PaddleState::STATE_DISABLED: - newStateString = "STATE_DISABLED"; - break; - case PaddleState::STATE_START: - newStateString = "STATE_START"; - break; - } - - switch (mPreviousState) - { - case PaddleState::STATE_NORMAL: - prevState = "STATE_NORMAL"; - break; - case PaddleState::STATE_STICKY: - prevState = "STATE_STICKY"; - break; - case PaddleState::STATE_DISABLED: - prevState = "STATE_DISABLED"; - break; - case PaddleState::STATE_START: - prevState = "STATE_START"; - break; - } - - std::cout << "ChangeState" << std::endl; - std::cout << "Current " << currentState << std::endl; - std::cout << "New " << newStateString << std::endl; - std::cout << "Prev " << prevState << std::endl << std::endl; - if (isDisabled() && mPreviousColor != sf::Color::Transparent) { mRenderer->getShape().setFillColor(mPreviousColor); diff --git a/Arkanoid/PowerUpService.cpp b/Arkanoid/PowerUpService.cpp index 3567d6c..3bc6e44 100644 --- a/Arkanoid/PowerUpService.cpp +++ b/Arkanoid/PowerUpService.cpp @@ -33,7 +33,7 @@ void PowerUpService::spawnRandomPU(const sf::Vector2f & pos) { int chancePU = rand() % 100; - if (chancePU > 20) return; + if (chancePU > 25) return; PUType type = (PUType)(rand() % (PUType::PU_COUNT)); diff --git a/Arkanoid/PowerUpService.h b/Arkanoid/PowerUpService.h index 51bcac9..0273d6b 100644 --- a/Arkanoid/PowerUpService.h +++ b/Arkanoid/PowerUpService.h @@ -16,6 +16,9 @@ enum PUType PU_COUNT }; +/// +/// Manages Power Up creation +/// class PowerUpService { public: diff --git a/Arkanoid/PowerUpStickyComponent.h b/Arkanoid/PowerUpStickyComponent.h index cdc1b9a..7b36348 100644 --- a/Arkanoid/PowerUpStickyComponent.h +++ b/Arkanoid/PowerUpStickyComponent.h @@ -5,6 +5,10 @@ class CircleColliderComponent; +/// +/// Power Up that changes the paddle to be sticky for a limited time. +/// +/// class PowerUpStickyComponent : public PowerUpComponent { diff --git a/Arkanoid/ServiceLocator.h b/Arkanoid/ServiceLocator.h index aff7c5b..cb84d0d 100644 --- a/Arkanoid/ServiceLocator.h +++ b/Arkanoid/ServiceLocator.h @@ -6,6 +6,9 @@ #include +/// +/// Acts as a single place to access services. +/// class ServiceLocator { public: diff --git a/Arkanoid/mainpage.dox b/Arkanoid/mainpage.dox index 94ff30e..31c4b4f 100644 --- a/Arkanoid/mainpage.dox +++ b/Arkanoid/mainpage.dox @@ -57,22 +57,43 @@ * The CollionDetector class manages all "physics" calculations for the game, providing collision detection and response for components using the ColliderComponents classes's data, simple collision detection algorithms (AABBvsCircle and the likes) and uses messages to signal callbacks inside colliders. * These callbacks are std::function objects that encapsulate functions of other components of (usually) the same entity. This way the response behavior for collision is personalized to the needs of more "game logic"-focused components. * + * The ServiceLocator class acts as a "phone book" to find services. At the moment, it provides the AudioService and the TextureService, to access Audio functionalities and to get texture references, respectively. + * + * * All components types are mapped by an enumerator ComponentList, which automatically registers to GameState at the beginning of the game. * * Game configuration data is managed using a JSON file, which is read and stored inside a Boost Property Tree's ptree object and retrieved at runtime from this data structure. * The high score of the game is saved on the file. + * + * + * \subsection subsec2 The Game + * + * Initially I planned on having all original power ups and aliens, plus the possibility to select different pre-made levels (I was thinking on building them using Tiled and importing them). + * On top of this, I had thought about a couple possible special bricks and power ups, mostly intended as jokes about characters of Divinity: Original Sin. * + * In the end I ran out of time, since I couldn't dedicate as much time as I tought. + * Of the original power ups, I managed to implement the Sticky (yellow sphere) and the Disruption one (green sphere), plus I implemented one of the original power ups I wanted, the Bomber one (you will recognize it). + * On the brick side, there are 3 types: 1-hit normal, 1-hit with double score and 2-hit bricks. + * + * Sound effects have been done using Bfxr, meanwhile the musics are Creative Commons ones found online. + * + * + * Edit after more work: Added the Bomber power up. + * * \subsection subsec3 Problems during the development * * My main problem has been time. I worked on it during the evenings and in fact I didn't manage to insert as many features as I wanted to have a polished game. * At the moment the main lack is graphics, but also a variety of power ups and bricks. During the incoming weekend I plan on working on it more, to polish it. * On the software architecture side, there is room for improvement on the GameState class, as I think it became too large, unfortunately I didn't have time for a proper refactoring. - * For example the game resources (sounds, textures) should be managed outside the GameState class. + * For example the game resources (sounds, textures) should be managed outside the GameState class. + * Also, a couple of bugs persists on the collisions side. + * + * Edit after more work: Sounds and textures are now implemented as services to other classes, using the Service Locator pattern. * * * \subsection subsec4 Conclusion * - * Thanks for this experience. This was my first time implementing such a system and I must say that it has been a very funny project. Also, it seems to work! :) + * Thanks for this experience. This was my first time implementing such an architecture and I must say that it has been a very funny project. Also, it seems to work! :) * I hope this small guide has been useful. * * Thanks for reading this and have a good day! diff --git a/Arkanoid/resources/settings.json b/Arkanoid/resources/settings.json index 827a000..ba288d9 100644 --- a/Arkanoid/resources/settings.json +++ b/Arkanoid/resources/settings.json @@ -17,7 +17,7 @@ "SCREEN_HEIGHT": "768", "MS_PER_UPDATE": "0.0111", "NUM_LIVES": "3", - "HIGH_SCORE": "11300", + "HIGH_SCORE": "0", "BRICK_POINTS": "100", "PADDLE_MAX_VELOCITY": "1000", "PADDLE_MAX_ACCEL": "10",