Пример #1
0
void endofgame(void)
{
  Sint4 i;
  bool initflag=FALSE;
  for (i=0;i<diggers;i++)
    addscore(i,0);
  if (playing || !drfvalid)
    return;
  if (gauntlet) {
    cleartopline();
    outtext("TIME UP",120,0,3);
    for (i=0;i<50 && !escape;i++)
      newframe();
    outtext("       ",120,0,3);
  }
  for (i=curplayer;i<curplayer+diggers;i++) {
    scoret=scdat[i].score;
    if (scoret>scorehigh[11]) {
      gclear();
      drawscores();
      strcpy(pldispbuf,"PLAYER ");
      if (i==0)
        strcat(pldispbuf,"1");
      else
        strcat(pldispbuf,"2");
      outtext(pldispbuf,108,0,2);
      outtext(" NEW HIGH SCORE ",64,40,2);
      getinitials();
      shufflehigh();
      savescores();
      initflag=TRUE;
    }
  }
  if (!initflag && !gauntlet) {
    cleartopline();
    outtext("GAME OVER",104,0,3);
    for (i=0;i<50 && !escape;i++)
      newframe();
    outtext("         ",104,0,3);
    setretr(TRUE);
  }
}
Пример #2
0
int main(int argc, char* argv[]) {
    bool finished;
    int ch;
    engine_t engine;
    /* Initialize */
    rand_init();							/* must be called before engine_init () */
    engine_init(&engine, score_function);	/* must be called before using engine.curshape */
    finished = shownext = FALSE;
    memset(shapecount, 0, NUMSHAPES * sizeof(int));
    shapecount[engine.curshape]++;
    parse_options(argc,argv);				/* must be called after initializing variables */
    if (level < MINLEVEL) {
        choose_level();
    }
    io_init();
    drawbackground();
    in_timeout(DELAY);
    /* Main loop */
    do {
        /* draw shape */
        showstatus(&engine);
        drawboard(engine.board);
        out_refresh();
        /* Check if user pressed a key */
        if ((ch = in_getch ()) != ERR) {
            switch (ch) {
            case 'j':
            case KEY_LEFT:
                engine_move(&engine,ACTION_LEFT);
                break;
            case 'k':
            case '\n':
                engine_move(&engine,ACTION_ROTATE);
                break;
            case 'l':
            case KEY_RIGHT:
                engine_move(&engine,ACTION_RIGHT);
                break;
            case ' ':
            case KEY_DOWN:
                engine_move(&engine,ACTION_DROP);
                break;
                /* show next piece */
            case 's':
                shownext = TRUE;
                break;
                /* toggle dotted lines */
            case 'd':
                dottedlines = !dottedlines;
                break;
                /* next level */
            case 'a':
            case KEY_UP:
                if (level < MAXLEVEL) {
                    level++;
                    in_timeout(DELAY);
                }
                else out_beep();
                break;
                /* quit */
            case 'q':
                finished = TRUE;
                break;
                /* pause */
            case 'p':
                out_setcolor(COLOR_WHITE,COLOR_BLACK);
                out_gotoxy((out_width() - 34) / 2,out_height() - 2);
                out_printf("Paused - Press any key to continue");
                while ((ch = in_getch ()) == ERR) ;	/* Wait for a key to be pressed */
                in_flush();							/* Clear keyboard buffer */
                out_gotoxy((out_width() - 34) / 2, out_height() - 2);
                out_printf("                                  ");
                break;
                /* unknown keypress */
            default:
                out_beep();
            }
            in_flush();
        } else {
            switch (engine_evaluate(&engine)) {
            /* game over (board full) */
            case -1:
                if ((level < MAXLEVEL) && ((engine.status.droppedlines / 10) > level)) level++;
                finished = TRUE;
                break;
                /* shape at bottom, next one released */
            case 0:
                if ((level < MAXLEVEL) && ((engine.status.droppedlines / 10) > level)) {
                    level++;
                    in_timeout(DELAY);
                }
                shapecount[engine.curshape]++;
                break;
                /* shape moved down one line */
            case 1:
                break;
            }
        }
    } while (!finished);
    /* Restore console settings and exit */
    io_close();
    /* Don't bother the player if he want's to quit */
    if (ch != 'q') {
        showplayerstats(&engine);
        savescores(GETSCORE(engine.score));
    }
    exit(EXIT_SUCCESS);
}
Пример #3
0
/*     DigiBand (c)2005 Seijinohki PC Services and Software, This code written by Joe Wall with assitance from Velex
*      Loutzenhiser, and respected other parties.  This code is protected under the GPL License.  For any questions
*      regarding this code, please contact Joe @ www.seijinohki.net.
*
*      This software is free software; you can redistribute it and/or
*      modify it under the terms of the GNU Lesser General Public
*      License as published by the Free Software Foundation; either
*      version 2 of the License, or (at your option) any later version.
*
*      This software 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
*      Lesser General Public License for more details.
*
*      You should have received a copy of the GNU Lesser General Public
*      License along with this software;  if not, write to the:
*      Free Software Foundation, Inc.
*      59 Temple Place - Suite 330
*      Boston, MA 02111-1307, USA
*/
void titlescreen(int totalframes){
	#ifdef EXCESSIVE
	printf("titlescreen\n");
	#endif
	if (currscreen!=prevscreen){
		if (presong>-1&&presong<gbsongcount){
			if(songsloaded>0)unloadwaves();
		}
		if (thesong>-1&&thesong<gbsongcount){
			if(songsloaded>0)loadwaves();
		}
		if(prevscreen==13){
			savescores();		
		}
	}
	draw_quad(0,512,384,-9000,640,400,255,255,255,255,0,0,1);
	currstage=1;
	gptscore=0;
	gpg1tscore=0;
	gpg2tscore=0;
	gplifebar=50;
	gpg1lifebar=50;
	gpg2lifebar=50;
	if(!arcademode){
		draw_quad(0,512,384,-5000,640,400,255,255,255,255,0,0,55);
	}else{
		draw_quad(0,512,384,-5000,640,400,255,255,255,255,0,0,2);
	}
	if (!arcademode){
		static char option1[256];
		static char option2[256];
		static char option3[256];
		snprintf(option1,255,"Game Start");
		snprintf(option2,255,"Options");
		snprintf(option3,255,"Quit");
		static drawtext option1d;
		option1d.load(option1,"font.ttf",255,255,255,uivars.title_start_s);
		static drawtext option2d;
		option2d.load(option2,"font.ttf",255,255,255,uivars.title_options_s);
		static drawtext option3d;
		option3d.load(option3,"font.ttf",255,255,255,uivars.title_quit_s);
		if (optionselected<1)optionselected=3;
		if (optionselected>3)optionselected=1;
		if (optionselected!=1){option1d.draw(uivars.title_start_x,uivars.title_start_y,0,255,255,255,255,false,true);}
		else{option1d.draw(uivars.title_start_x,uivars.title_start_y,0,255,128,128,255,true,true);}
		if (optionselected!=2){option2d.draw(uivars.title_options_x,uivars.title_options_y,0,255,255,255,255,false,true);}
		else{option2d.draw(uivars.title_options_x,uivars.title_options_y,0,255,128,128,255,true,true);}
		if (optionselected!=3){option3d.draw(uivars.title_quit_x,uivars.title_quit_y,0,255,255,255,255,false,true);}
		else{option3d.draw(uivars.title_quit_x,uivars.title_quit_y,0,255,128,128,255,true,true);}
	}else{
		static char option1[256];
		snprintf(option1,255,"Coins %i/%i Credits (%i)",coinsinserted,coinsperplay,credits);
		static drawtext option1s;
		option1s.load(option1,"font.ttf",255,255,255,20);
		option1s.draw(400,0,0,255,255,255,255,false,true);
	}
	//version
	static char theversion[256];
	snprintf(theversion,255,"Version %s",VERSION);
	static drawtext theversiont;
	theversiont.load(theversion,"font.ttf",255,255,255,uivars.title_version_s);
	theversiont.draw(uivars.title_version_x,uivars.title_version_y,0,255,255,255,255,false,true);
	//YAY!!! ADD!!	
	if (arcademode){
		if (menucountertime>0){
			static long timer=0;
			if (currscreen!=prevscreen)
				timer=SDL_GetTicks();
			#ifndef EXCESSIVE
			int timeleft=int(double(40)-((double(SDL_GetTicks())-double(timer))/1000.0));
			#else
			int timeleft=int(double(5)-((double(SDL_GetTicks())-double(timer))/1000.0));
			#endif
			char disptime[10];
			snprintf(disptime,9,"%i",timeleft);
			if (timeleft==0){
				nextscreen=20;
				screenfaddingout=true;
				screenchangenow=false;
				screenfaddingin=false;
			}
		}
	}
}
Пример #4
0
int main (int argc,char *argv[])
  {
  int count;
  int flags;
  const char *temp;

#ifdef DATAPATH
  chdir(DATAPATH);
#endif

  checkbigendian();

  loadconfig();
  loadscores();
  loadplayers();

  flags=SDL_INIT_VIDEO|SDL_INIT_TIMER;
  if (config.joystick)
    flags|=SDL_INIT_JOYSTICK;

  SDL_Init(flags);

  sdlvideoinfo=SDL_GetVideoInfo();
  sdlpixelformat=sdlvideoinfo->vfmt;
  if (sdlpixelformat->BitsPerPixel==16)
    config.bitsperpixel=16;

  for (count=1;count<argc;count++)
    {
    if (strcmp("-nosound",argv[count])==0)
      {
      config.sound=0;
      option.sound=0;
      option.music=0;
      }
    if (strcmp("-sound",argv[count])==0)
      config.sound=1;
    if (strcmp("-nomusic",argv[count])==0)
      option.music=0;
    }

  saveconfig();

  SDL_ShowCursor(SDL_DISABLE);

  listvideomodes();

  SDL_WM_SetCaption("Gish","SDL");
  SDL_WM_SetIcon(SDL_LoadBMP("gish.bmp"),iconmask);

  if (windowinfo.bitsperpixel==16)
    {
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,6);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,5);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,0);
    }
  if (windowinfo.bitsperpixel==32)
    {
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8);
    }
  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,windowinfo.depthbits);
  SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,windowinfo.stencilbits);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);

  if (windowinfo.fullscreen)
    SDL_SetVideoMode(windowinfo.resolutionx,windowinfo.resolutiony,windowinfo.bitsperpixel,SDL_OPENGL|SDL_FULLSCREEN);
  else
    SDL_SetVideoMode(windowinfo.resolutionx,windowinfo.resolutiony,windowinfo.bitsperpixel,SDL_OPENGL);

  loadglextentions();

  for (count=0;count<2048;count++)
    glGenTextures(1,&texture[count].glname);

  glDisable(GL_DEPTH_TEST);
  glDepthMask(GL_FALSE);

  if (config.joystick)
    {
    numofjoysticks=SDL_NumJoysticks();
    for (count=0;count<numofjoysticks;count++)
      {
      joy[count]=SDL_JoystickOpen(count);
      temp=SDL_JoystickName(count);
      strcpy(joystick[count].name,temp);
      joystick[count].numofbuttons=SDL_JoystickNumButtons(joy[count]);
      joystick[count].numofhats=SDL_JoystickNumHats(joy[count]);
      }

    SDL_JoystickEventState(SDL_IGNORE);
    }

  font.texturenum=0;
  font.cursornum=0;
  font.sizex=640;
  font.sizey=480;

  loadtexture(1000,"font00.png",0,GL_CLAMP,GL_CLAMP,GL_LINEAR,GL_LINEAR);
  loadtexture(1001,"font01.png",0,GL_CLAMP,GL_CLAMP,GL_LINEAR,GL_LINEAR);

  loadtexture(768,"mouse00.png",0,GL_CLAMP,GL_CLAMP,GL_LINEAR,GL_LINEAR);
  loadtexture(769,"mouse00.png",0,GL_CLAMP,GL_CLAMP,GL_LINEAR,GL_LINEAR);

  setupmenuitems();

  if (!glext.multitexture)
    {
    notsupportedmenu();

    SDL_WM_IconifyWindow();
    SDL_Quit();
    return(0);
    }
    
  if (config.sound)
    setupaudio();

  mainmenu();

  saveconfig();
  savescores();
  saveplayers();

  if (config.sound)
    shutdownaudio();

  SDL_WM_IconifyWindow();

  SDL_Quit();

  return(0);
  }