76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
|
#ifndef _VIEW_H
|
||
|
#define _VIEW_H
|
||
|
|
||
|
#include "ViewBase.h"
|
||
|
#include "mathlib.h"
|
||
|
#include "Sprite.h"
|
||
|
#include "EntityBase.h"
|
||
|
|
||
|
namespace asteroids {
|
||
|
|
||
|
class MenuOverlay;
|
||
|
struct ShipEntity;
|
||
|
struct AsteroidEntity;
|
||
|
struct RocketEntity;
|
||
|
|
||
|
struct BackgroundStar {
|
||
|
vector3d position;
|
||
|
};
|
||
|
|
||
|
/** \brief Performs the actual drawing based on Camera and Model
|
||
|
*/
|
||
|
class View : public Engine::ViewBase {
|
||
|
protected:
|
||
|
/** \brief Initializes the system */
|
||
|
int OnInit (int argc, char* argv[]);
|
||
|
void OnDestroy ();
|
||
|
|
||
|
/** \brief Updates the camera for further drawing */
|
||
|
virtual void UpdateCamera ();
|
||
|
|
||
|
private:
|
||
|
virtual void DrawWorld ();
|
||
|
void DrawStars ();
|
||
|
|
||
|
void DrawEntity (Engine::EntityBase *entity);
|
||
|
void DrawShip (ShipEntity *ship);
|
||
|
void DrawAsteroid (AsteroidEntity *asteroid);
|
||
|
void DrawRocket (RocketEntity *asteroid);
|
||
|
void DrawShipPart (Engine::EntityBase *entity);
|
||
|
|
||
|
MenuOverlay *mMenuOverlay;
|
||
|
std::vector<BackgroundStar> mBackgroundStars;
|
||
|
|
||
|
std::vector<unsigned int> mShipPartsEntityIds;
|
||
|
|
||
|
Engine::Sprite mAsteroidSprite;
|
||
|
Engine::Sprite mShipSprite;
|
||
|
Engine::Sprite mShipThrustSprite;
|
||
|
Engine::Sprite mShipPartsSprite;
|
||
|
|
||
|
class AccelerateEventHandler : public Engine::EventListenerBase {
|
||
|
public:
|
||
|
explicit AccelerateEventHandler (View *view) : mView (view) {};
|
||
|
virtual bool HandleEvent (const Engine::EventBasePtr &event) const;
|
||
|
private:
|
||
|
View *mView;
|
||
|
};
|
||
|
|
||
|
class ShipExplodeEventHandler : public Engine::EventListenerBase {
|
||
|
public:
|
||
|
explicit ShipExplodeEventHandler (View *view) : mView (view) {};
|
||
|
virtual bool HandleEvent (const Engine::EventBasePtr &event) const;
|
||
|
private:
|
||
|
View *mView;
|
||
|
};
|
||
|
|
||
|
AccelerateEventHandler *mAccelerateEventHandler;
|
||
|
ShipExplodeEventHandler *mShipExplodeEventHandler;
|
||
|
|
||
|
friend class AccelerateEventHandler;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif // _VIEW_H
|