TapestryEngine

A 2D Platformer Game Engine
Log | Files | Refs

7f8982949b71a09adccee27078bffa1c36d31d03.svn-base (1377B)


      1 #ifndef HUD_H
      2 #define HUD_H
      3 
      4 #include "Utils.h"
      5 #include "Console.h"
      6 #include "Actor.h"
      7 #include "MiscDraw.h"
      8 #include "Event.h"
      9 
     10 
     11 struct WidgetElement
     12 {
     13 	SDL_Rect pos;
     14 	SDL_Texture* img;
     15 };
     16 
     17 class Widget
     18 {
     19 public:
     20 
     21 	Widget() {}
     22 
     23 	Widget(SDL_Renderer* ren, SDL_Rect pos) : mPos(pos), mren(ren), mDisplay(true)
     24 	{
     25 	}
     26 
     27 	SDL_Rect* GetPos()
     28 	{
     29 		return &mPos;
     30 	}
     31 
     32 	virtual bool WidgetUpdate() = 0;
     33 
     34 	virtual bool WidgetDraw() = 0;
     35 
     36 protected:
     37 
     38 	bool mDisplay;
     39 	SDL_Renderer* mren;
     40 	SDL_Rect mPos;
     41 
     42 };
     43 
     44 SDL_Rect CalcElementScreenPosition(Widget* wid, SDL_Rect elementRect);
     45 
     46 class LifeMeter : public Widget
     47 {
     48 public:
     49 
     50 	LifeMeter() {}
     51 
     52 	LifeMeter(Player* target, SDL_Rect pos, SDL_Renderer* ren, char* life_base, char* life_bar);
     53 
     54 	bool WidgetUpdate();
     55 
     56 	bool WidgetDraw();
     57 
     58 protected:
     59 
     60 	int* mHP;
     61 	int* mHPmax;
     62 	WidgetElement mBase;
     63 	WidgetElement mLifebar;
     64 
     65 };
     66 
     67 class Fader : public Widget, public EventReceiver //Must Subscribe to the player
     68 {
     69 public:
     70 	Fader() {}
     71 
     72 	Fader(SDL_Renderer* ren, char* black);
     73 
     74 	void PlayFade(int duration);
     75 
     76 	bool WidgetUpdate();
     77 
     78 	bool WidgetDraw();
     79 
     80 	bool EventProcess(Event eve);
     81 
     82 protected:
     83 
     84 	WidgetElement mBlack;
     85 
     86 	int mOpacity;
     87 
     88 	int mFadeTime;
     89 
     90 	int mTimer;
     91 };
     92 
     93 class HUD
     94 {
     95 public:
     96 
     97 	HUD() : mIndex(0) {}
     98 
     99 	bool LogWidget(Widget* wid);
    100 
    101 	bool UpdateWidgets();
    102 
    103 	bool DrawWidgets();
    104 
    105 protected:
    106 
    107 	Widget* mWidgets[10];
    108 	int mIndex;
    109 };
    110 
    111 
    112 
    113 #endif