Debian Codegraph @

scoreboard.cpp

raw symbols SCIP
1 /* ************************************************************************* *
2 SDL-Ball - DX-Ball/Breakout remake with openGL and SDL for Linux
3 Copyright (C) 2008 Jimmy Christensen ( dusted at dusted dot dk )
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * ************************************************************************* */
18 // #include <list>
19
20
21 class glScoreBoard
22 {
23 private:
24 unsigned int lastScoreTick;
25 uint tempScore;
26 uint score;
27 char tempText[255];
28
29 public:
30
31 glScoreBoard()
32 {
33 init();
34 }
35
36 void init()
37 {
38 tempScore=1;
39 score=0;
40 lastScoreTick = SDL_GetTicks();
41 }
42
43 void update(int point)
44 {
45 score=point;
46 }
47
48 void draw()
49 {
50 int dif=score - tempScore;
51
52 if(tempScore != score )
53 {
54 if(lastScoreTick + 50 < SDL_GetTicks())
55 {
56 tempScore+= (float)dif/7.0 +1; ;
57 if(tempScore > score)
58 tempScore=score;
59 lastScoreTick = SDL_GetTicks();
60
61 sprintf(tempText, "%i", tempScore);
62 }
63 }
64
65 glLoadIdentity();
66 glTranslatef(-1.55, 1.24-(glText->getHeight(FONT_HIGHSCORE)/2.0), -3.0);
67
68 glColor4f(1.0,1.0,1.0,1.0);
69 glText->write(tempText, FONT_HIGHSCORE, 0, 1.0, 0.0, 0.0);
70
71 }
72 };
73