Arkanoid Remake  1.0
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ArkanoidRemakeSdl Class Reference

Implementation of ArkanoidRemake using SDL library. More...

#include <ArkanoidRemakeSdl.h>

Inheritance diagram for ArkanoidRemakeSdl:
ArkanoidRemake App

Classes

class  AppEventFunctor
 Functor class for application events. More...
 
struct  Configuration
 Game configuration data structure. It is loaded on startup and saved to disk on exit. More...
 

Public Member Functions

 ArkanoidRemakeSdl ()
 Constructor: initialize members values.
 
App interface

App interface implementation

bool Init ()
 App interface implementation. More...
 
void Start ()
 Initialize the score and go to the first level.
 
void Stop ()
 Stop the application.
 
void CleanUp ()
 Clean up the application and free memory.
 
void Update ()
 Update the application (call it in an iteration loop)
 
- Public Member Functions inherited from ArkanoidRemake
 ArkanoidRemake ()
 Constructor: just initialize data members.
 
- Public Member Functions inherited from App
 App ()
 Constructor.
 
bool Run ()
 Run the application. More...
 

Protected Member Functions

bool InitSdl ()
 Initialize SDL with SDL toolkit.
 
bool LoadFiles ()
 Load images, sounds, etc. with SDL toolkit.
 
bool SetBackground (const std::string &file_name)
 Use the given image file to fill the background.
 
void PlaySound (const std::string &name)
 Play the named sound.
 
bool LoadConfiguration (const std::string &file_path)
 Load the game configuration.
 
bool SaveConfiguration (const std::string &file_path)
 Save the game configuration.
 
Framework-specific implementation

Methods implemented with SDL framework

double GetTime ()
 Get the current time in seconds (definition of the base class abstract method)
 
virtual void HandleEvents ()
 Handle input events.
 
virtual void Frame ()
 Render a frame.
 
Game events management

Game events management redefined to implement sound and graphics

void AddLevel ()
 Add a (the only one foer now) new level. More...
 
bool SetCurrentLevel (unsigned int n)
 Set up the graphics for the current level.
 
void GoToNextLevel ()
 Set up the graphics for the next level.
 
void HitBlock (Block &block, int x, int y)
 Actions implementation. More...
 
void HitShip ()
 The ship hit the ball.
 
void GetBonus (const Bonus &bonus)
 The ship hit a bonus item.
 
bool DropBonus (const std::string &name, const VecXy &pos)
 A bonus item was dropped.
 
void BonusLost (const Bonus &bonus)
 The ship missed a bonus.
 
void BallLost ()
 The ship missed the ball.
 
void AddScore (int n)
 Add the givent points to the score.
 
void UpdateScoreText ()
 Update the GUI text.
 
Drawing game objects

Game objects rendered with graphics

void DrawBall ()
 
void DrawShip ()
 
void DrawBonus ()
 
void DrawText ()
 
void DrawBlocks ()
 
void DrawBackground ()
 
void DrawPlayArea ()
 
- Protected Member Functions inherited from ArkanoidRemake
void MoveBallWithShip ()
 Move the ball along with the ship (when it is attached)
 
void LaunchBall ()
 Launch tha ball (if held by the ship)
 
bool CalculateBallPosition ()
 Calculate the ball position according to its velocity and the play area size.
 
void CalculateBonusPosition ()
 Calculate the bonuses position according to their velocity and the play area size.
 
bool CalculateShipPosition (int x=-1)
 Calculate the ship position according to the play area size.
 
bool CheckBallBlockCollision (const Block &block, int x, int y)
 Check (and manage) the collision between the ball and a block.
 
bool CheckBallCollision (int x, int y)
 Check (and manage) the collision between the ball and the walls.
 

Protected Attributes

double mBkgndScroll
 Value controlling the background scroll.
 
std::string mBlockMatrixName
 Identifier of the container for blocks images.
 
sdltk::SdlApp mSdlApp
 SDL application manager, implementing event management, sound and graphics.
 
unsigned mBkgndColor
 Color used for background if an image is not available.
 
Configuration mConfig
 Configuration loaded from the file (see smDefaultConfig)
 
Drawing surface identifiers
std::string mShipSurf
 
std::string mBallSurf
 
std::string mPlayAreaSurf
 
std::string mBkgndSurf
 
std::string mSnowfallSurf
 
Timing
sdltk::Timer mTimer
 
- Protected Attributes inherited from ArkanoidRemake
PlayArea mPlayArea
 Play area definition.
 
Ball mBall
 Ball object.
 
Ship mShip
 Ship object.
 
unsigned int mCurrLevel
 Index of the active level.
 
BlockMatrix mBlock
 Current blocks configuration.
 
std::vector< LevelmLevel
 List of game levels.
 
std::vector< BonusmBonus
 List of dropped bunuses.
 
std::map< std::string, BonusmBonusDef
 Bonus definitions (templates for bonus creation)
 
std::string mScoreText
 Score text buffer.
 
unsigned int mLevelScore
 Score reached within the current level.
 
unsigned int mTotalScore
 Total game score.
 
unsigned int mBlocksLeft
 Counter for the blocks not yet destroyed.
 
double mPrevTime
 
double mCurrTime
 
- Protected Attributes inherited from App
bool mQuit
 Flag used in the Run() method while calling Update() in a loop.
 

Static Protected Attributes

static Configuration smDefaultConfig
 Default configuration used in case the configuration fila is not readable.
 

Friends

class AppEventFunctor
 Let the functor get the full control of the application.
 

Detailed Description

Implementation of ArkanoidRemake using SDL library.

The ArkanoidRemakeSDL class directly derives from ArkanoidRemake and provides an SDL implementation of that abstract class.

Member Function Documentation

void ArkanoidRemakeSdl::AddLevel ( )
protectedvirtual

Add a (the only one foer now) new level.

Level management

Todo:
implement more game levels
Note
only one level is implemented for now

Reimplemented from ArkanoidRemake.

void ArkanoidRemakeSdl::HitBlock ( Block block,
int  x,
int  y 
)
protectedvirtual

Actions implementation.

A block was hit

Reimplemented from ArkanoidRemake.

bool ArkanoidRemakeSdl::Init ( )
virtual

App interface implementation.

Initialize game level(s) and items data

Reimplemented from ArkanoidRemake.


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