/* ************************************************************************* *
SDL-Ball - DX-Ball/Breakout remake with openGL and SDL for Linux
Copyright (C) 2008 Jimmy Christensen ( dusted at dusted dot dk )
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
* ************************************************************************* */
class powerupLoaderClass {
public:
//most common
string chances[4];
int powerups;
int powerupsGiven;
string evilPowerups;
powerupLoaderClass() {
int chance=-1;
powerups=0;
powerupsGiven=0;
string line;
//Which powerups are evil?
evilPowerups = "2H37"; //P
ifstream powerFile(useTheme("/powerups.txt",setting.lvlTheme).data());
if(!powerFile.is_open())
{
cout << " Could not open 'powerups.txt'"<')
{
if(line.substr(0,6) == "> down")
{
var.scrollInfo.dropspeed = atol( line.substr(7,line.length()).data() );
var.scrollInfo.drop = 1;
}
} else {
while(line[ch] != 0)
{
bricks[brick].powerup = line[ch];
bricks[brick].type = line[ch+1];
if(bricks[brick].type == 'D')
{
char rgb[3][5];
sprintf(rgb[0], "0x%c%c", line[ch+2], line[ch+3]);
sprintf(rgb[1], "0x%c%c", line[ch+4], line[ch+5]);
sprintf(rgb[2], "0x%c%c", line[ch+6], line[ch+7]);
bricks[brick].tex.prop.glTexColorInfo[0] = 0.003921569*strtol(rgb[0], NULL, 16);
bricks[brick].tex.prop.glTexColorInfo[1] = 0.003921569*strtol(rgb[1], NULL, 16);
bricks[brick].tex.prop.glTexColorInfo[2] = 0.003921569*strtol(rgb[2], NULL, 16);
bricks[brick].tex.prop.glParColorInfo[0] = 0.003921569*strtol(rgb[0], NULL, 16);
bricks[brick].tex.prop.glParColorInfo[1] = 0.003921569*strtol(rgb[1], NULL, 16);
bricks[brick].tex.prop.glParColorInfo[2] = 0.003921569*strtol(rgb[2], NULL, 16);
bricks[brick].tex.prop.glTexColorInfo[3] = 1.0;
ch +=6;
}
//cout << "Level: " << levelnum << " brick: " << brick << " Powerup: " << line[ch] << " Type: " << line[ch+1]<<"\n";
brick++;
ch +=2;
}
ch=0;
} //Not a command
} //denne level settes op
}
}
}
cout << "Read " << var.numlevels << " levels from '"<< file <<"'" << endl;
levelfile.close();
}
void initlevels(brick bricks[], textureClass texLvl[])
{
int brick;
powerupLoaderClass powerupLoader;
//Temp storage for custom colors
GLfloat tempCol[4], tempParCol[3];
//Set dem op
int row,i;
i=0;
for(row=0;row<23;row++)
{
for(brick=0;brick < 26; brick++)
{
bricks[i].posx = -1.54 + (GLfloat)brick*0.1232;
bricks[i].posy = 0.95+ ((GLfloat)row*0.07)*-1;
if(bricks[i].type != '0')
{
bricks[i].active=1;
bricks[i].collide=1;
bricks[i].isdyingnormally=0;
bricks[i].isexploding=0;
bricks[i].reflect=1;
bricks[i].fade=1.0;
bricks[i].fadespeed=2.0;
bricks[i].zoom=1.0;
bricks[i].zoomspeed=4.0;
bricks[i].width=0.0616;
bricks[i].height=0.035;
bricks[i].score=11;
bricks[i].destroytowin=1;
bricks[i].hitsLeft=1;
bricks[i].powerup = powerupLoader.randomPowerup(bricks[i].powerup);
bricks[i].bricknum=brick;
bricks[i].row=row;
updated_nbrick[row][brick] = i; // This brick is active
//cout<<"Brick:"<< nbrick[row][brick]<