~ubuntu-branches/debian/sid/astromenace/sid

« back to all changes in this revision

Viewing changes to AstroMenaceSource/GraphicFX/GameLvlText/GameLvlText.cpp

  • Committer: Package Import Robot
  • Author(s): Boris Pek
  • Date: 2013-04-09 02:04:25 UTC
  • Revision ID: package-import@ubuntu.com-20130409020425-a7fl9xk4diamw6di
Tags: upstream-1.3.1+repack
Import upstream version 1.3.1+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/************************************************************************************
 
2
 
 
3
        AstroMenace (Hardcore 3D space shooter with spaceship upgrade possibilities)
 
4
        Copyright © 2006-2012 Michael Kurinnoy, Viewizard
 
5
 
 
6
 
 
7
        AstroMenace is free software: you can redistribute it and/or modify
 
8
        it under the terms of the GNU General Public License as published by
 
9
        the Free Software Foundation, either version 3 of the License, or
 
10
        (at your option) any later version.
 
11
 
 
12
        AstroMenace is distributed in the hope that it will be useful,
 
13
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
15
        GNU General Public License for more details.
 
16
 
 
17
        You should have received a copy of the GNU General Public License
 
18
        along with AstroMenace. If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
 
 
21
        Web Site: http://www.viewizard.com/
 
22
        Project: http://sourceforge.net/projects/openastromenace/
 
23
        E-mail: viewizard@viewizard.com
 
24
 
 
25
*************************************************************************************/
 
26
 
 
27
 
 
28
#include "GameLvlText.h"
 
29
 
 
30
 
 
31
 
 
32
//-----------------------------------------------------------------------------
 
33
// инициализация класса
 
34
//-----------------------------------------------------------------------------
 
35
CGameLvlText::CGameLvlText()
 
36
{
 
37
        TimeLastUpdate = -1.0f;
 
38
        Lifetime = -1.0f;
 
39
        DrawText = 0;
 
40
        Color = 0;
 
41
 
 
42
        PosX = PosY = 0;
 
43
 
 
44
        AttachGameLvlText(this);
 
45
 
 
46
}
 
47
 
 
48
 
 
49
//-----------------------------------------------------------------------------
 
50
//      При разрушении класса
 
51
//-----------------------------------------------------------------------------
 
52
CGameLvlText::~CGameLvlText()
 
53
{
 
54
        if (DrawText != 0){delete [] DrawText; DrawText = 0;}
 
55
        DetachGameLvlText(this);
 
56
}
 
57
 
 
58
 
 
59
//-----------------------------------------------------------------------------
 
60
// обновление
 
61
//-----------------------------------------------------------------------------
 
62
bool CGameLvlText::Update(float Time)
 
63
{
 
64
        // первый раз... просто берем время
 
65
        if (TimeLastUpdate == -1.0f) {TimeLastUpdate = Time;return true;}
 
66
 
 
67
        // Time - это абсолютное время, вычисляем дельту
 
68
        float TimeDelta = Time - TimeLastUpdate;
 
69
        // быстро вызвали еще раз... время не изменилось, или почти не изменилось
 
70
        if (TimeDelta == 0.0f) return true;
 
71
 
 
72
        TimeLastUpdate = Time;
 
73
 
 
74
 
 
75
        // проверяем, сколько объекту жить, если нужно...-1.0f  - проверка не нужна
 
76
        if (Lifetime > -1.0f)
 
77
        {
 
78
                // считаем, сколько осталось жить
 
79
                Lifetime -= TimeDelta;
 
80
                // если уже ничего не осталось - его нужно уничтожить
 
81
                if (Lifetime <= 0.0f) return false;
 
82
        }
 
83
 
 
84
 
 
85
        if (DrawText == 0) return false;
 
86
 
 
87
    return true;
 
88
}
 
89
 
 
90
 
 
91
 
 
92
 
 
93
 
 
94
//-----------------------------------------------------------------------------
 
95
// прорисовка
 
96
//-----------------------------------------------------------------------------
 
97
void CGameLvlText::Draw()
 
98
{
 
99
        if (DrawText != 0)
 
100
        {
 
101
                float R=1.0f;
 
102
                float G=1.0f;
 
103
                float B=1.0f;
 
104
 
 
105
                switch (Color)
 
106
                {
 
107
                        case 0: // белый
 
108
                                R=1.0f;G=1.0f;B=1.0f;
 
109
                                break;
 
110
                        case 1: // желтый
 
111
                                R=1.0f;G=1.0f;B=0.0f;
 
112
                                break;
 
113
                        case 2: // красный
 
114
                                R=1.0f;G=0.0f;B=0.0f;
 
115
                                break;
 
116
                        case 3: // зеленый
 
117
                                R=0.0f;G=1.0f;B=0.0f;
 
118
                                break;
 
119
                        case 4: // оранжевый
 
120
                                R=1.0f;G=0.5f;B=0.0f;
 
121
                                break;
 
122
                        case 5: // серый
 
123
                                R=0.5f;G=0.5f;B=0.5f;
 
124
                                break;
 
125
                }
 
126
 
 
127
                vw_DrawFont(PosX, PosY, 0, 0, 1.0f, R,G,B, 1.0f, DrawText);
 
128
        }
 
129
}
 
130
 
 
131
 
 
132
 
 
133
 
 
134
 
 
135
 
 
136
 
 
137
 
 
138