Esempio n. 1
0
void RandomGenerateMap()
{
	int trying = 1;
	if (game_load) {
		NewLevel();
		ReadMapData();
	} else {
		NewLevel();
		while (trying) {
		
			trying = !Generate();
		}
	}
	//SaveLevel();
}
Esempio n. 2
0
void RandomGenerateMap()
{
  int trying = 1;
  if (game_load) {
    NewLevel();
    /* FIXME: de-globalise this. */
    read_map_data (&save);
  } else {
    NewLevel();
    while (trying) {
		
      trying = !Generate();
    }
  }
  /* SaveLevel(); */
}
Esempio n. 3
0
File: wad.c Progetto: samboy/Oblige
//
// CreateGLMarker
//
lump_t *CreateGLMarker(void)
{
  lump_t *level = wad.current_level;
  lump_t *cur;

  char name_buf[32];

  if (strlen(level->name) <= 5)
  {
    sprintf(name_buf, "HO_%s", level->name);
  }
  else
  {
    FatalError("Level name too long: '%s'", level->name);
  }

  cur = NewLump(UtilStrDup(name_buf));

  cur->lev_info = NewLevel(LEVEL_IS_GL);

  // link it in
  cur->next = level->next;
  cur->prev = level;

  if (cur->next)
    cur->next->prev = cur;

  level->next = cur;
  level->lev_info->buddy = cur;

  return cur;
}
Esempio n. 4
0
void sphreport(stream ostr, smxptr sm, string options)
{
  bodyptr *bptr = sm->kd->bptr;
  int i, nupd, nlev[MAXLEV+1], *rprof = sm->rprof;
  real rbsum, rbmin, rbmax, flev[MAXLEV+1], flev4, xi[NRPROF-1];

  nupd = 0;
  for (i = 0; i <= MAXLEV; i++)
    nlev[i] = 0;
  rbsum = 0.0;
  for (i = 0; i < sm->kd->ngas; i++) {
    if (Update(bptr[i])) {
      nupd++;
      nlev[NewLevel(bptr[i])]++;
      rbsum += Smooth(bptr[i]);
      rbmin = (nupd == 1 ? Smooth(bptr[i]) : MIN(rbmin, Smooth(bptr[i])));
      rbmax = (nupd == 1 ? Smooth(bptr[i]) : MAX(rbmin, Smooth(bptr[i])));
    }
  }
  flev4 = 0.0;
  for (i = 0; i <= MAXLEV; i++) {
    flev[i] = 100.0 * ((real) nlev[i]) / ((real) nupd);
    if (i >= 4)
      flev4 += flev[i];
  }
  fprintf(ostr, "\n%9s %9s %9s %9s %29s %9s\n",
	  "log hmin", "log havg", "log hmax", "freqavg",
	  "timestep level distribution", "CPUsph"); 
  fprintf(ostr,
	  "%9.4f %9.4f %9.4f %9.2f %5.1f %5.1f %5.1f %5.1f %5.1f %9.3f\n",
	  rlog10(rbmin), rlog10(rbsum / nupd), rlog10(rbmax),
	  sm->freqsum / nupd, flev[0], flev[1], flev[2], flev[3], flev4,
	  cputime() - sm->cpustart);
  if (scanopt(options, "corrfunc")) {
    for (i = 0; i <= NRPROF - 2; i++)
      xi[i] = -1 + rpow(8.0, i/2.0) * (rprof[i] - rprof[i+1]) /
	((1 - rsqrt(0.125)) * rprof[0]);
    fprintf(ostr, "\n     ");
    for (i = NRPROF - 2; i >= 0; i--)
      fprintf(ostr, "   xi%d", i);
    fprintf(ostr, "\n     ");
    for (i = NRPROF - 2; i >= 0; i--)
      fprintf(ostr, "%6.2f", xi[i]);
    fprintf(ostr, "\n");
  }	
  if (scanopt(options, "levelhist")) {
    fprintf(ostr, "\n     ");
    for (i = 0; i <= MAXLEV; i++)
      if (nlev[i] != 0)
	fprintf(ostr, i<10 ? "  lev%d" : " lev%d", i);
    fprintf(ostr, "\n     ");
    for (i = 0; i <= MAXLEV; i++)
      if (nlev[i] != 0)
	fprintf(ostr, "%6d", nlev[i]);
    fprintf(ostr, "\n");
  }	
  fflush(ostr);
}
Esempio n. 5
0
void GameOptions(Game *game,int options)   /*new game, quit, select difficulty*/
{
  Uint8 *keys;
  Sprite *menu;
  int done = 0;
  menu = LoadSprite("images/menu.png",640,480);
  do
  {
    ResetBuffer();
    SDL_PumpEvents();
    MouseThink();
    keys = SDL_GetKeyState(NULL);    
    if(keys[SDLK_ESCAPE] == 1)
    {
        exit(0);
    }
    if(keys[SDLK_RETURN] == 1)
    {
      FreeSprite(menu);
      SDL_PumpEvents();
      return;
    }
    if(keys[SDLK_F2] == 1)
    {
      NewGame(game);
      NewLevel(game,8,4);  /*sets up a new level*/
      done = 1;
      FreeSprite(menu);
    }
    DrawMessages();
    DrawSprite(menu,screen,(screen->w - 640)/2,(screen->h - 480)/2,0);
    DrawText("New Game  : F2",screen,(screen->w - 640)/2 + 50,(screen->h - 480)/2 + 160,IndexColor(LightGreen),F_Medium);
    DrawText("Quit      : Escape",screen,(screen->w - 640)/2 + 50,(screen->h - 480)/2 + 200,IndexColor(LightGreen),F_Medium);
    if(options == 0)
    {
      DrawText("This Menu : F1",screen,(screen->w - 640)/2 + 50,(screen->h - 480)/2 + 180,IndexColor(LightGreen),F_Medium);
    }
    else
    {
      DrawText("Cancel    : Enter",screen,(screen->w - 640)/2 + 50,(screen->h - 480)/2 + 180,IndexColor(LightGreen),F_Medium);
      DrawText("Game Paused",screen,(screen->w / 2) - 80,(screen->h - 480)/2 + 440,IndexColor(LightRed),F_Small);
    }
    DrawMouse();
    NextFrame();
  }while(!done);
  
}
Esempio n. 6
0
void GrownZombie(Game *game)
{
  Sprite *levelup;
  int channel;
  game->NumZombies++;
  game->NumGraves--;
  if((game->NumZombies >= game->NumVillagers)&&(game->NumGraves == 0))
  {
    Mix_HaltMusic();
    levelup = LoadSprite("images/levelup.png",96,96);
    channel = Mix_PlayChannel(-1,gamesounds[0]->sound,0);
    PopUpWindow(levelup,"The Villagers Die!!",IndexColor(LightViolet),0);
    NewLevel(game,(game->level * 4) + 8,(game->level * 3) + 2);  /*sets up a new level*/
    Mix_HaltChannel(channel);
    FreeSprite(levelup);
  }
}
Esempio n. 7
0
void DeadZombie(Game *game)  /*sets the game info to he beone less zombie.. possible game over.*/
{
  Sprite *grave;
  int frame;
  int channel;
  game->NumGraves--;
  if(game->NumGraves + game->NumZombies < game->NumVillagers)
  {
    if(rand()%2 == 1)
    {
      grave = LoadSprite("images/grave1.png",64,96);
      frame = 3;
    }
    else
    {
      grave = LoadSprite("images/skelrise.png",32,48);
      frame = 15;
    }
    Mix_HaltMusic();
    channel = Mix_PlayChannel(-1,gamesounds[1]->sound,0);
    PopUpWindow(grave,"The Villagers live, You LOSE!",IndexColor(Red),frame);
    GameOptions(game,0);
    Mix_HaltChannel(channel);
    FreeSprite(grave);
  }
  else if(game->NumGraves == 0)/*then we must have won already*/
  {
    grave = LoadSprite("images/levelup.png",96,96);
    Mix_HaltMusic();
    channel = Mix_PlayChannel(-1,gamesounds[0]->sound,0);
    PopUpWindow(grave,"The Villagers Die!!",IndexColor(LightViolet),0);
    NewLevel(game,(game->level * 4) + 8,(game->level * 3) + 2);  /*sets up a new level*/
    Mix_HaltChannel(channel);
    FreeSprite(grave);
  }
}
Esempio n. 8
0
static unsigned long
penetrate_draw (Display *dpy, Window window, void *closure)
{
  struct state *st = (struct state *) closure;
  XWindowAttributes xgwa;

  if (st->draw_reset)
    {
      st->draw_reset = 0;
      DrawCities(st, st->draw_xlim, st->draw_ylim);
    }

  XGetWindowAttributes(st->dpy, st->window, &xgwa);
  st->draw_xlim = xgwa.width;
  st->draw_ylim = xgwa.height;

  /* see if just started */
  if (st->loop == 0) {
	 if (st->smart) {
		st->choosypersen = st->econpersen = st->carefulpersen = 100;
		st->lrate = kMinRate; st->aim = 1;
	 }
	 NewLevel(st, st->draw_xlim, st->draw_ylim);
	 DrawScore(st, st->draw_xlim, st->draw_ylim);
  }

  st->loop++;

  if (st->levMissiles == 0) {
	 /* see if anything's still on the screen, to know when to end level */
	 int i;
	 for (i=0;i<kMaxMissiles;i++)
		if (st->missile[i].alive)
		  goto END_CHECK;
	 for (i=0;i<kMaxBooms;i++)
		if (st->boom[i].alive)
		  goto END_CHECK;
	 for (i=0;i<kMaxLasers;i++)
		if (st->laser[i].alive)
		  goto END_CHECK;
	 /* okay, nothing's alive, start end of level countdown */
	 usleep(kLevelPause*1000000);
	 NewLevel(st, st->draw_xlim, st->draw_ylim);
         goto END;
  END_CHECK: ;
  }
  else if ((random() % st->levFreq) == 0) {
	 launch(st, st->draw_xlim, st->draw_ylim, -1);
	 st->levMissiles--;
  }

  if (st->loop - st->lastLaser >= st->lrate) {
	 if (fire(st, st->draw_xlim, st->draw_ylim))
		st->lastLaser = st->loop;
  }

  if ((st->loop & 7) == 0)
    st->draw_reset = 1;

  LoopMissiles(st, st->draw_xlim, st->draw_ylim);
  LoopLasers(st, st->draw_xlim, st->draw_ylim);
  LoopBooms(st, st->draw_xlim, st->draw_ylim);

 END:
  return kSleepTime;
}
Esempio n. 9
0
File: wad.c Progetto: samboy/Oblige
//
// ProcessDirEntry
//
static void ProcessDirEntry(lump_t *lump)
{
  DisplayTicker();

  // ignore previous GL lump info
  if (CheckGLLumpName(lump->name))
  {
#   if DEBUG_DIR
    PrintDebug("Discarding previous GL info: %s\n", lump->name);
#   endif

    FreeLump(lump);
    wad.num_entries--;

    return;
  }

  // --- LEVEL MARKERS ---

  if (CheckLevelName(lump->name))
  {
    /* NOTE !  Level marks can have data (in Hexen anyway) */
    if (cur_info->load_all)
      lump->flags |= LUMP_READ_ME;
    else
      lump->flags |= LUMP_COPY_ME;

    // OK, start a new level

    lump->lev_info = NewLevel(0);

    wad.current_level = lump;

#   if DEBUG_DIR
    PrintDebug("Process dir... %s :\n", lump->name);
#   endif

    // link it in
    lump->next = NULL;
    lump->prev = wad.dir_tail;

    if (wad.dir_tail)
      wad.dir_tail->next = lump;
    else
      wad.dir_head = lump;

    wad.dir_tail = lump;

    return;
  }

  // --- LEVEL LUMPS ---

  if (wad.current_level)
  {
    if (CheckLevelLumpName(lump->name))
    {
      // check for duplicates
      if (FindLevelLump(lump->name))
      {
        PrintWarn("Duplicate entry '%s' ignored in %s\n",
            lump->name, wad.current_level->name);

        FreeLump(lump);
        wad.num_entries--;

        return;
      }

#     if DEBUG_DIR
      PrintDebug("Process dir... |--- %s\n", lump->name);
#     endif

      // mark it to be loaded
      lump->flags |= LUMP_READ_ME;
    
      // link it in
      lump->next = wad.current_level->lev_info->children;
      lump->prev = NULL;

      if (lump->next)
        lump->next->prev = lump;

      wad.current_level->lev_info->children = lump;
      return;
    }
      
    // OK, non-level lump.  End the previous level.

    wad.current_level = NULL;
  }

  // --- ORDINARY LUMPS ---

# if DEBUG_DIR
  PrintDebug("Process dir... %s\n", lump->name);
# endif

  if (CheckLevelLumpName(lump->name))
    PrintWarn("Level lump '%s' found outside any level\n", lump->name);

  // maybe load data
  if (cur_info->load_all)
    lump->flags |= LUMP_READ_ME;
  else
    lump->flags |= LUMP_COPY_ME;

  // link it in
  lump->next = NULL;
  lump->prev = wad.dir_tail;

  if (wad.dir_tail)
    wad.dir_tail->next = lump;
  else
    wad.dir_head = lump;

  wad.dir_tail = lump;
}