Skip to content

Commit

Permalink
doxygen
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhrack committed Jul 7, 2019
1 parent 4c34580 commit 5d8cdf9
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Arkanoid/Arkanoid.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
<Filter>Header Files\Textures</Filter>
</ClInclude>
<ClInclude Include="NullTextureService.h">
<Filter>Header Files</Filter>
<Filter>Header Files\Textures</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions Arkanoid/CollisionDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ bool AABBvsAABB(BaseComponent*, BaseComponent*, sf::Vector2f&);
bool AABBvsCircle(BaseComponent*, BaseComponent*, sf::Vector2f&);
bool CirclevsCircle(BaseComponent*, BaseComponent*, sf::Vector2f&);

/// <summary>
/// A utility class that implements a few collision detection algorithms.
/// </summary>
class CollisionDetector
{
public:
Expand Down
4 changes: 4 additions & 0 deletions Arkanoid/GameOverWatcherComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include <SFML/Audio.hpp>

/// <summary>
/// Component that listens for ball lost and game over messages.
/// </summary>
/// <seealso cref="BaseComponent" />
class GameOverWatcherComponent :
public BaseComponent
{
Expand Down
7 changes: 5 additions & 2 deletions Arkanoid/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class GameState :
EntityID createEntity(EntityType type);

/// <summary>
/// Variadic template funciton that adds a new component.
/// Variadic template function that adds a new component and returns a casted pointer to it.
/// </summary>
/// <param name="type">The type ID of the component.</param>
/// <param name="entityID">The entity identifier.</param>
Expand Down Expand Up @@ -111,7 +111,7 @@ class GameState :
int getPlayerLives() const;

/// <summary>
/// Games the over.
/// Manages game over changes.
/// </summary>
/// <param name="win">if set to <c>true</c> will be shown a winning text, else a losing text [win].</param>
void gameOver(bool win);
Expand Down Expand Up @@ -221,6 +221,9 @@ class GameState :
/// </summary>
std::unordered_map<EntityID, EntityType> mEntityMap;

/// <summary>
/// Vector of entities slated for removal at the end of the current update loop
/// </summary>
std::vector<EntityID> mZombieEntities;

PaddleBehaviorComponent* mPaddleBehaviorComp;
Expand Down
4 changes: 4 additions & 0 deletions Arkanoid/NullAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include <SFML/Audio.hpp>

/// <summary>
/// To disable sound. Useful for development.
/// </summary>
/// <seealso cref="AudioService" />
class NullAudioService :
public AudioService
{
Expand Down
4 changes: 4 additions & 0 deletions Arkanoid/NullTextureService.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "TextureService.h"

/// <summary>
/// To disable the Texture Service. Useful as a placeholder.
/// </summary>
/// <seealso cref="TextureService" />
class NullTextureService :
public TextureService
{
Expand Down
4 changes: 4 additions & 0 deletions Arkanoid/PCAudioService.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
using SoundIDFilename = std::pair<SoundID, std::string>;
using MusicIDFilename = std::pair<MusicID, std::string>;

/// <summary>
/// Implementation of the Audio Service for PC.
/// </summary>
/// <seealso cref="AudioService" />
class PCAudioService :
public AudioService
{
Expand Down
4 changes: 4 additions & 0 deletions Arkanoid/PCTextureService.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

using TextureIDFilename = std::tuple<TextureID, std::string, sf::IntRect>;

/// <summary>
/// Implements the Texture Service on PC.
/// </summary>
/// <seealso cref="TextureService" />
class PCTextureService :
public TextureService
{
Expand Down
54 changes: 0 additions & 54 deletions Arkanoid/PaddleBehaviorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Arkanoid/PowerUpService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
3 changes: 3 additions & 0 deletions Arkanoid/PowerUpService.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ enum PUType
PU_COUNT
};

/// <summary>
/// Manages Power Up creation
/// </summary>
class PowerUpService
{
public:
Expand Down
4 changes: 4 additions & 0 deletions Arkanoid/PowerUpStickyComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

class CircleColliderComponent;

/// <summary>
/// Power Up that changes the paddle to be sticky for a limited time.
/// </summary>
/// <seealso cref="PowerUpComponent" />
class PowerUpStickyComponent :
public PowerUpComponent
{
Expand Down
3 changes: 3 additions & 0 deletions Arkanoid/ServiceLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

#include <memory>

/// <summary>
/// Acts as a single place to access services.
/// </summary>
class ServiceLocator
{
public:
Expand Down
25 changes: 23 additions & 2 deletions Arkanoid/mainpage.dox
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion Arkanoid/resources/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5d8cdf9

Please sign in to comment.