Arkanoid Remake  1.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ArkanoidRemake Class Referenceabstract

Base class for an implementation of a remake of the old game Arkanoid. More...

#include <ArkanoidRemake.h>

Inheritance diagram for ArkanoidRemake:
App ArkanoidRemakeSdl

Public Member Functions

 ArkanoidRemake ()
 Constructor: just initialize data members.
 
virtual bool Init ()
 App interface implementation. More...
 
virtual void Start ()
 Initialize the score and go to the first level.
 
virtual void Update ()
 Update the application (call it in an iteration loop)
 
Framework-specific implementation

Abstract methods to be implemented according to the chosen framework

virtual double GetTime ()=0
 Get the current time in seconds.
 
virtual void HandleEvents ()=0
 Handle input events.
 
virtual void Frame ()=0
 Render a frame.
 
virtual void HitBlock (Block &block, int x, int y)
 Actions implementation. More...
 
virtual void HitShip ()
 The ship hit the ball.
 
virtual void GetBonus (const Bonus &bonus)
 The ship hit a bonus item.
 
virtual bool DropBonus (const std::string &name, const VecXy &pos)
 A bonus item was dropped.
 
virtual void BonusLost (const Bonus &bonus)
 The ship missed a bonus.
 
virtual void BallLost ()
 The ship missed the ball.
 
- Public Member Functions inherited from App
 App ()
 Constructor.
 
virtual void Stop ()
 Stop the application.
 
virtual void CleanUp ()
 Clean up the application and free memory.
 
bool Run ()
 Run the application. More...
 

Protected Member Functions

virtual void AddScore (int n)
 Add the givent points to the score.
 
virtual void UpdateScoreText ()
 Update the score text.
 
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.
 
virtual void AddLevel ()
 Add a (the only one foer now) new level. More...
 
virtual bool SetCurrentLevel (unsigned int n)
 Set the current level.
 
virtual void GoToNextLevel ()
 Go to the next level.
 

Protected Attributes

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.
 
Timing
double mPrevTime
 
double mCurrTime
 
- Protected Attributes inherited from App
bool mQuit
 Flag used in the Run() method while calling Update() in a loop.
 

Detailed Description

Base class for an implementation of a remake of the old game Arkanoid.

The ArkanoidRemake class implements the generic App interface, basic functions and the logic of the game. This class must be specialized to implement the visualization on a specific platform. This class in an abstract class, because there are some pure virtual methods that must be defined by specific implementations (e.g. for graphics, sound, input, ...). These pure virtual methods (see the section Framework-specific implementation) represent the missing implementation that must be added by more specialized classes (see ArkanoidRemakeSDL). The virtual methods must be overridden, calling the base class version and adding the specific implementation. Some of these methods are pure virtual methods (see section "Framework-specific implementation").

Note
The origin of the coordinates is assumed to be at the lower left corner of the screen.
The coordinates of the game objects (ship, ball, blocks) are relative to the play area.

Even if some libraries provide specific implementations for some features that are needed by this game, like collision check, bouncing calculation, etc. in this class a simplified implementation is provided. Anyway it could be partially or entirely replaced by more specialized classes.

Member Function Documentation

virtual void ArkanoidRemake::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 in ArkanoidRemakeSdl.

virtual void ArkanoidRemake::HitBlock ( Block block,
int  x,
int  y 
)
virtual

Actions implementation.

A block was hit

Reimplemented in ArkanoidRemakeSdl.

virtual bool ArkanoidRemake::Init ( )
virtual

App interface implementation.

Initialize game level(s) and items data

Reimplemented from App.

Reimplemented in ArkanoidRemakeSdl.


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