Debian Codegraph @

background.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
19
20 class backgroundClass {
21 private:
22 GLfloat r[4], g[4], b[4], a;
23
24 textureClass tex;
25 bool dir;
26 bool firstTexture;
27 public:
28
29
30 backgroundClass()
31 {
32 firstTexture=1;
33 }
34
35 void init(textureManager & texMgr)
36 {
37 bool l;
38 //Så vi ikke kommer til at slette texture 0 første gang funktionen bliver kaldt
39 if(!firstTexture)
40 glDeleteTextures(1, &tex.prop.texture);
41
42 float t = 0.25 * ((float)player.level+1);
43
44 if(t <= 1.0)
45 l=texMgr.load(useTheme("/gfx/bg/1.jpg",setting.gfxTheme), tex);
46 else if(t <= 2.0)
47 l=texMgr.load(useTheme("/gfx/bg/2.jpg",setting.gfxTheme), tex);
48 else if(t <= 3.0)
49 l=texMgr.load(useTheme("/gfx/bg/3.jpg",setting.gfxTheme), tex);
50 else if(t <= 4.0)
51 l=texMgr.load(useTheme("/gfx/bg/4.jpg",setting.gfxTheme), tex);
52 else if(t <= 5.0)
53 l=texMgr.load(useTheme("/gfx/bg/5.jpg",setting.gfxTheme), tex);
54 else if(t <= 6.0)
55 l=texMgr.load(useTheme("/gfx/bg/6.jpg",setting.gfxTheme), tex);
56 else if(t <= 7.0)
57 l=texMgr.load(useTheme("/gfx/bg/7.jpg",setting.gfxTheme), tex);
58 else if(t <= 8.0)
59 l=texMgr.load(useTheme("/gfx/bg/8.jpg",setting.gfxTheme), tex);
60 else if(t <= 9.0)
61 l=texMgr.load(useTheme("/gfx/bg/9.jpg",setting.gfxTheme), tex);
62 else if(t <= 10.0)
63 l=texMgr.load(useTheme("/gfx/bg/10.jpg",setting.gfxTheme), tex);
64 else if(t <= 11.0)
65 l=texMgr.load(useTheme("/gfx/bg/11.jpg",setting.gfxTheme), tex);
66 else if(t <= 12.0)
67 l=texMgr.load(useTheme("/gfx/bg/12.jpg",setting.gfxTheme), tex);
68 else if(t <= 13.0)
69 l=texMgr.load(useTheme("/gfx/bg/13.jpg",setting.gfxTheme), tex);
70 else if(t <= 14.0)
71 l=texMgr.load(useTheme("/gfx/bg/14.jpg",setting.gfxTheme), tex);
72 else if(t <= 15.0)
73 l=texMgr.load(useTheme("/gfx/bg/15.jpg",setting.gfxTheme), tex);
74 else if(t <= 16.0)
75 l=texMgr.load(useTheme("/gfx/bg/16.jpg",setting.gfxTheme), tex);
76 else if(t <= 17.0)
77 l=texMgr.load(useTheme("/gfx/bg/17.jpg",setting.gfxTheme), tex);
78 else if(t <= 18.0)
79 l=texMgr.load(useTheme("/gfx/bg/18.jpg",setting.gfxTheme), tex);
80 else if(t <= 19.0)
81 l=texMgr.load(useTheme("/gfx/bg/19.jpg",setting.gfxTheme), tex);
82 else if(t <= 20.0)
83 l=texMgr.load(useTheme("/gfx/bg/20.jpg",setting.gfxTheme), tex);
84 else if(t <= 21.0)
85 l=texMgr.load(useTheme("/gfx/bg/21.jpg",setting.gfxTheme), tex);
86 else if(t <= 22.0)
87 l=texMgr.load(useTheme("/gfx/bg/22.jpg",setting.gfxTheme), tex);
88 else if(t <= 23.0)
89 l=texMgr.load(useTheme("/gfx/bg/23.jpg",setting.gfxTheme), tex);
90 else if(t <= 24.0)
91 l=texMgr.load(useTheme("/gfx/bg/24.jpg",setting.gfxTheme), tex);
92 else if(t <= 25.0)
93 l=texMgr.load(useTheme("/gfx/bg/25.jpg",setting.gfxTheme), tex);
94 else
95 l=texMgr.load(useTheme("/gfx/bg/final.jpg",setting.gfxTheme), tex);
96
97 if(!l)
98 {
99 setting.showBg=0;
100 cout << "Backgrounds disabled." << endl;
101 }
102
103 firstTexture=0;
104
105 for(int i = 0; i < 4; i++)
106 {
107 r[i] = rndflt(1,0);
108 g[i] = rndflt(1,0);
109 b[i] = rndflt(1,0);
110 }
111 a = 1;
112
113 }
114
115 void draw()
116 {
117
118 glLoadIdentity();
119 glTranslatef( 0, 0, -3.0 );
120
121 glEnable(GL_TEXTURE_2D);
122 glEnable(GL_BLEND);
123 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
124
125 glBindTexture(GL_TEXTURE_2D, tex.prop.texture);
126
127 glBegin( GL_QUADS );
128 glColor4f(r[0],g[0],b[0],a);
129 glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.66, 1.25, 0.0f );
130 glColor4f(r[1],g[1],b[1],a);
131 glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.66, 1.25, 0.0f );
132 glColor4f(r[2],g[2],b[2],a);
133 glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.66,-1.25, 0.0f );
134 glColor4f(r[3],g[3],b[3],a);
135 glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.66,-1.25, 0.0f );
136 glEnd( );
137 }
138 };