コード例 #1
0
ファイル: levels.c プロジェクト: manolaz/Wizznic
void makeUserLevelList()
{
   //List userlevels
  userLevelFiles = initList();
  int i=0;

  levelInfo_t* tl;
  char* buf = malloc(sizeof(char)*256);
  while(1)
  {
    sprintf(buf, "%s/level%03i.wzp", getUserLevelDir(), i);

    tl=mkLevelInfo( buf );
    if( tl )
    {
      listAddData(userLevelFiles, (void*)tl);
    } else {
      break;
    }
    i++;
  }

  numUserLevels=listSize(userLevelFiles);
  free(buf);
}
コード例 #2
0
ファイル: leveleditor.c プロジェクト: revcozmo/Wizznic
void editorLoad(const char* fn, SDL_Surface* screen)
{
  //Set filename
  editorFileName(fn);

  //Init cursor
  initCursor(&cur);
  //Read info's for level.
  pf.levelInfo = mkLevelInfo( fn );
  //Load field
  loadField(&pf, fileName);

  initDraw(pf.levelInfo, screen);
  SDL_FreeSurface(stealGfxPtr()->boardImg);
  stealGfxPtr()->boardImg = loadImg( DATADIR"data/editbg.png" );

  selBrickBG = loadImg( DATADIR"data/editselbrick.png" );

  saveBtnBG = loadImg( DATADIR"data/edit-save.png" );
  saveBtnSprite = cutSprite( saveBtnBG, 0,0, saveBtnBG->w, saveBtnBG->h );

  changed=0;
  selBrick=BRICKSBEGIN;

  teleState=0;

  fieldRect.x = HSCREENW -  74;
  fieldRect.y = HSCREENH - 114;
  fieldRect.w = HSCREENW + 154;
  fieldRect.h = HSCREENH + 114;
}
コード例 #3
0
ファイル: levels.c プロジェクト: manolaz/Wizznic
void makeLevelList(listItem** list, const char* dir)
{
  int i=0;
  char* buf = malloc(sizeof(char)*1024);

  //Init the list to hold the filenames
  *list = initList();
  levelInfo_t* tl;

  //List all levels in dir.
  while(1)
  {
    sprintf(buf, "%s/levels/level%03i.wzp",dir, i);
    tl=mkLevelInfo( buf );
    if(tl)
    {
      listAddData(*list, (void*)tl);
    } else {
      break;
    }
    i++; //Increment file-number.
  }

  // Add a "Completed" level at the very end of the list
  tl=malloc(sizeof(levelInfo_t));
  memset(tl, 0, sizeof(levelInfo_t));

  sprintf( buf, packGetFile(".","complete.png"),dir );
  tl->imgFile = malloc( sizeof(char)*(strlen(buf)+1) );
  strcpy(tl->imgFile, buf);

  listAddData(*list, (void*)tl);

  free(buf);
  buf=0;

}
コード例 #4
0
ファイル: levels.c プロジェクト: manolaz/Wizznic
//Adds the level to list if it's not allready there.
void addUserLevel(const char* fn)
{
  levelInfo_t* tl;
  listItem* l=userLevelFiles;
  //Check if it's there
  while( (l=l->next) )
  {
    if(strcmp( ((levelInfo_t*)l->data)->file, fn )==0)
    {
      return;
    }
  }


  tl=mkLevelInfo(fn);

  if(tl)
  {
    listAddData(userLevelFiles, (void*)tl);
    numUserLevels=listSize(userLevelFiles);
  } else {
    printf("Strange error, couldn't open saved level.\n");
  }
}
コード例 #5
0
ファイル: game.c プロジェクト: DusteDdk/Wizznic
int initGame(SDL_Surface* screen)
{
    if(player()->gameStarted)
    {
      printf("ERROR: Called init when a game was running\n");
      return(0);
    }

	//Only load the back-image once.
    if( !ptrRestart )
    {
    	ptrRestart = loadImg( DATADIR"data/ptr-restart.png" );
    	ptrRestartRect.x=HSCREENW-160;
    	ptrRestartRect.w=ptrRestartRect.x+ptrRestart->w;

    	ptrRestartRect.y=HSCREENH+120-ptrRestart->h;
    	ptrRestartRect.h=ptrRestartRect.y+ptrRestart->h;
    }

    debugNumInit++;
    initCursor(&cur);
    restartConfirm=0;

    //Read info's for level. (this is done instead of using the one in packInfo so it don't need resetting)
    pf.levelInfo = mkLevelInfo( player()->levelFile );

    if(!loadField(&pf, player()->levelFile ))
    {
      printf("Error: Couldn't init playfield.\n");
      return(0);
    }


    if(!initDraw(pf.levelInfo,screen))
    {
      printf("Error: Couldn't init graphics.\n");
      return(0);
    }

    char* buf = malloc(sizeof(char)*128);
    sprintf(buf, "themes/%s",pf.levelInfo->soundDir);
    loadSamples( buf, levelInfo( player()->level)->musicFile ); //Load samples from sounddir, note we use the levelInfo from packInfo for the music since the playlist is hacked onto that.
    free(buf);

    txtLoadGameCharSet( pf.levelInfo->fontName );

    pf.levelInfo->time *= 1000; //Convert seconds to ms
    countdown=500;
    countdownSeconds=3;
    gameState=GAMESTATECOUNTDOWN;
    player()->gameStarted=1;

    //Clear player stats
    memset( &player()->hsEntry, 0, sizeof( hsEntry_t ) );

    //Set the levelNum
    player()->hsEntry.levelNum = player()->level;

    startStopImg=0;

    if(pf.levelInfo->startImg)
    {
      gameState=GAMESTATESTARTIMAGE;
    }

    //We also simulate the first switch tick here so all looks right at the countdown.
    switchUpdateAll( &pf );

    justWon=0;

    return(1);
}