Пример #1
0
int main(int argc, char **argv)
{
  aThisApp.start(argc,argv);
  char *fname=(char *)NULL;
  if(aThisApp.argc>1) fname=aThisApp.argv[1];
  if(aThisApp.argc<2) {
    ARequesterFile *ww=new ARequesterFile();
    if(ww) fname=ww->show((char *)"Open file");
    else std::cerr<<"(Didn't get a request window)\n";
    if(ww) delete ww;
    ww=NULL;
  }
  if(!fname) {
    char msg[256];
    sprintf(msg,(char *)"usage: nupac {board filename}",aThisApp.argv[0]);
    ADialogMsg mw((char *)"Error!",msg);
    //return 5;
    return 0;
  }
  char *bname=fname;
  unsigned int t;
  char *temp;
  InitGame();
  for(t=1;t<aThisApp.argc;t++) {
    temp=aThisApp.argv[t];
    if(temp[0]=='-') {
      if(temp[1]=='d') {
        DisplayName=aThisApp.argv[t+1]; t++;  std::cerr<<"Display name is ";
        std::cerr<<DisplayName<<"\n";
      } else
      if(temp[1]=='p') { FOOBAR_PACMOVE=false; } else
      if(temp[1]=='m') { FOOBAR_MONO=1; } else
      if(temp[1]=='s') {
        sscanf(aThisApp.argv[t+1],(char *)"%d",(unsigned int *)&SPEED);
        t++;
        std::cerr<<"New speed is";
        std::cerr<<SPEED<<"\n";
      } else
      std::cerr<<aThisApp.argv[0]<<": bad command option\n";
    }
    else {
      bname=temp;
    }
  }
  std::cerr<<"Initial board is "<<bname<<"\n";
  DoTitle();
  QUITING=false;
  while(!QUITING) {
    std::cerr<<"Looping in main while !QUITING...\n";
    //StartLoading();
    CleanupBitmaps();
    if(bname) ReadBoardFromDisk(bname);
    else boardError=true;
    if(boardError) {
      QUITING=true;
    }
    else {
      ExploreBoard();
      SetupBitmaps();
      if(!QUITING) {
        SetSpriteShapes();
        DrawScreen();
        UpdateScore();  InitRound();
        DIED=true;
        while(DIED) {
          mainloop();
          UpdateScore();  InitRound();
          if(QUITING) DoQuit();
        }
      }
      bname=NextBoard;  boardError=false;
    }
  }
  std::cerr<<"Normal exit\n";
  return 0;
}
Пример #2
0
int main (int argc, char *argv[])
{

	void *mod_data;
	FILE *mod_fd;
	size_t mod_size;

	mod_fd = fopen("GLOS-pope.xm","r");
	fseek(mod_fd, 0, SEEK_END);
	mod_size = ftell(mod_fd);
	fseek(mod_fd, 0, SEEK_SET);
	mod_data = malloc(mod_size);
	fread(mod_data, 1, mod_size, mod_fd);
	fclose(mod_fd);

	ModPlug_Settings cfg;
	ModPlug_GetSettings(&cfg);
	cfg.mChannels = 2;
	cfg.mBits = 16;
	cfg.mFrequency = 48000;
	cfg.mResamplingMode = MODPLUG_RESAMPLE_SPLINE;
	cfg.mFlags = MODPLUG_ENABLE_OVERSAMPLING;
	ModPlug_SetSettings(&cfg);

	module = ModPlug_Load(mod_data, mod_size);

	srandom(0);

	memset(&params, 0, sizeof params);
	params.rate = 48000;
	params.on_speed = 2.0/100.0;
	params.off_speed = 2.0/30.0;
	params.start_wait = 8;
	params.start_dwell = 2;
	params.curve_dwell = 0;
	params.corner_dwell = 2;
	params.curve_angle = cosf(30.0*(M_PI/180.0)); // 30 deg
	params.end_dwell = 2;
	params.end_wait = 1;
	params.snap = 1/100000.0;
	params.flatness = 0.000005;
	params.max_framelen = params.rate / 24;
	params.render_flags = RENDER_GRAYSCALE;

	if(olInit(10, 30000) < 0)
		return 1;
	olSetRenderParams(&params);

	olSetAudioCallback(gen_audio);

	float time = 0;
	float ftime;
	int i,j;

	int frames = 0;

	memset(mbuf, 0, sizeof mbuf);

	font = olGetDefaultFont();

	float xpos = 1.0;

	DoStars(96);
	DoTitle(111);

	DoMetaballs(143);
	DoFire(174);

	DoTunnel(175+32);
	DoCubes(175+32+64);


	DoEuskal();

#if 0

	while(1) {
		int obj;
		float w;

		points_left = cur_draw;
		olPushColor();
		//olMultColor(C_GREY((int)(255.0f * cur_draw / count)));
		olSetVertexShader(cutoff);
		olDrawIlda(ild);
		olSetVertexShader(NULL);
		olPopColor();
/*
		olSetVertexShader(sinescroller);

		w = olDrawString(font, xpos, 0.35, 0.4, C_WHITE, "Hello, World! This is a test message displayed using the OpenLase text functions. Sine scrollers FTW!");
		if (xpos < (-w-1.5))
			xpos = 1.0;

		olSetVertexShader(NULL);*/

/*
		olDrawString(font, -1, 0.35, 0.4, C_WHITE, "Hello, World!");
		olDrawString(font, -1, -0, 0.4, C_WHITE, "How are you?");
		olDrawString(font, -1, -0.35, 0.4, C_WHITE, "    (-;   :-)");*/

		//render_cubes(time);
		//render_metaballs(time);
		//ender_fire();
		/*
		olBegin(OL_BEZIERSTRIP);
		olVertex(0,1,C_WHITE);
		olVertex(1,1,C_WHITE);
		olVertex(1,1,C_WHITE);
		olVertex(1,0,C_WHITE);

		olVertex(1,-1,C_WHITE);
		olVertex(1,-1,C_WHITE);
		olVertex(0,-1,C_WHITE);
		olEnd();*/

		ftime = olRenderFrame(150);
		frames++;
		gbl_time += ftime;
		xpos -= ftime;
		cur_draw += ftime * count / 5.0;
		if (cur_draw > count)
			cur_draw = count;
		printf("Frame time: %f, FPS:%f\n", ftime, frames/time);
	}

#endif

	olShutdown();
	exit (0);
}