⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scoreboard.cpp

📁 SDL-Ball这款经典的弹球游戏克隆自arkanoid、dxball、breakout
💻 CPP
字号:
/* ************************************************************************* *     SDL-Ball - DX-Ball/Breakout remake with openGL and SDL for Linux     Copyright (C) 2008 DusteD.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 <http://www.gnu.org/licenses/>.  * ************************************************************************* */class glScoreBoard{  private:  unsigned int lastScoreTick;  GLuint texScore,dl; //ren gl texture, displaylist  SDL_Color scoreColor;  char txt[256];    uint tempScore;    GLfloat rad,x,y;    public:  uint score;  glScoreBoard()  {    //Fix textur    //texMgr.alloc(&texScore);    //texScore = texMgr.tex[texScore];    glGenTextures(1, &texScore);    //Byg fin displaylist    dl=glGenLists(1);    glNewList(dl, GL_COMPILE);    glEnable( GL_TEXTURE_2D );    glBindTexture( GL_TEXTURE_2D, texScore);      glBegin( GL_QUADS );        glTexCoord2f(0.0, 0.0); glVertex3f(-1.6, 1.24, 0.0);        glTexCoord2f(1.0, 0.0); glVertex3f(0.2, 1.24, 0.0);        glTexCoord2f(1.0, 0.11); glVertex3f(0.2, 1.1, 0.0);        glTexCoord2f(0.0, 0.11); glVertex3f(-1.6, 1.1, 0.0);      glEnd( );    glEndList( );        init();  }    void init()  {    SDL_Color temp = { 255,255,255 };    scoreColor = temp;    tempScore=0;    lastScoreTick = SDL_GetTicks();    writeTxt(fonts[1],scoreColor,"Score: 0",texScore,0);  }    void update(int point)  {    //Det gør vi her så vi kan sætte den igang med at tælle op og "ryste"    score=point;  }    void draw()  {    int dif=score - tempScore;        if(tempScore != score )    {      if(lastScoreTick + 50 < SDL_GetTicks())      {        if(setting.eyeCandy)        {          tempScore+= (float)dif/5.0 +1; ;          if(tempScore >= score)            tempScore=score;          lastScoreTick = SDL_GetTicks();        } else {          tempScore = score;        }        sprintf(txt,"Score: %i",tempScore);        writeTxt(fonts[1],scoreColor,txt,texScore,0);      }    }            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);    if(setting.eyeCandy)    {      if(dif == 0)        dif=1;        else        dif /=3.0f;      rad += globalMilliTicks;            if(rad > 6.283185)        rad=0.0;            x=sin(rad)/100.0;      y=cos(rad)/100.0;            glLoadIdentity();      glTranslatef((x*dif)*-1,y*-1,-3.0);      glColor4f(1.0, 0.0, 0.0, 0.6);      glCallList(dl);      glLoadIdentity();      glTranslatef(y,x*dif,-3.0);      glColor4f(0.0, 1.0, 0.0, 0.6);      glCallList(dl);            glLoadIdentity();      glTranslatef(x*dif,y,-3.0); // ;)      glColor4f(0.0, 0.0, 1.0, 0.6);      glCallList(dl);      glLoadIdentity();      glTranslatef((y*(dif/20))*-1, (x*(dif/30))*-1,-3.0);      glColor4f(1.0, 1.0, 1.0, 1.0);    } //eyecandy    else    {      glLoadIdentity();      glTranslatef(0.0,0.0,-3.0);      glColor4f(1.0, 1.0, 1.0, 1.0);    }    glCallList(dl);    }};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -