Back to index

extremetuxracer  0.5beta
hud.h
Go to the documentation of this file.
00001 /* 
00002  * Tux Racer 
00003  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _HUD_H_
00021 #define _HUD_H_
00022 
00023 #include "player.h"
00024 #include "textures.h"
00025 #include "ppgltk/font.h"
00026 
00027 #define HUD_MAX_ITEMS 32
00028 
00029 class HUD
00030 {
00031 public:
00032        HUD(void);
00033 
00034        struct Element{
00035               Element();
00036               int type;
00037               int x,y;
00038               pp::Font *font;
00039               GLuint texture;
00040               GLuint texture2;
00041               int width,height,size;
00042               std::string string;
00043               wchar_t u_string[16];
00044               int angle;
00045        };     
00046 
00047        void draw(Player& plyr);
00048        void reset(void);
00049        bool add(Element newElement);                    
00050        bool update(const int i, Element newElement);
00051               
00052 
00053 private:
00054               
00055        Element m_element[HUD_MAX_ITEMS];
00056        int m_numElements;
00057        
00058        void text(const int i);
00059        void fps(const int i);
00060        void herring(const int i, const int herring_count);
00061        void image(const int i);
00062        void time(const int i);
00063        void speed(const int i, const double speed);
00064        void gauge(const int i, const double speed, const double energy);
00065        void bar(const int i, double percentage);
00066        void coursePercentage(const int i);
00067     void objectives_time(const int i, bool outline_font);
00068     void objectives_herring(const int i, bool outline_font);
00069        void icon_time(const int i);
00070        void icon_herring(const int i);
00071               
00072        void draw_partial_tri_fan(const double fraction);
00073        pp::Vec2d calc_new_fan_pt(const double angle);
00074        void start_tri_fan(void);
00075 
00076        void fix_xy(int &x, int &y, const int asc=0, const int width=0);
00077        void initGauge();
00078        
00079        GLuint m_energymaskTex;
00080        GLuint m_speedmaskTex;
00081        GLuint m_outlineTex; 
00082 };
00083 
00084 extern HUD HUD1;
00085 
00086 
00087 #endif // _HUD_H_