コード例 #1
0
//----------------------------------------------------------------------------------
bool loadWarehouse(SDL_Renderer* ren)
{  //load seedling 
    CEntity* ent = new CSeedlingW;
	if(ent->OnLoad("../tilesets/farmsheet.png", 82, 82, 1, ren)  == false) {
		return false;}
	ent->Y = 0;
	ent->X = TILE_SIZE*(3);
	ent->AnimState = 11;
	CEntity::EntityList.push_back(ent);
}
コード例 #2
0
//----------------------------------------------------------------------------------
bool loadStable(SDL_Renderer* ren, char* filename)
{
	FILE* fp = fopen(filename,"r");
	if(fp == NULL) printf("not farming");
	int i=0,j=0; char ch;
	while(fp && i<FARM_HEIGHT)
	{
		ch = fgetc(fp);
		if(feof(fp)) break;
		if(ch == '\n') {++i; j=0; continue;}
		
		CPlant::farm[i][j] = ch-48;
		++j;
	}
	fclose(fp);


	for (i = FARM_i; i < FARM_HEIGHT+FARM_i; ++i)
	{ for(j=FARM_j; j<FARM_WIDTH+FARM_j; ++j)
	  {  
		  if(CPlant::farm[i-FARM_i][j-FARM_j] == 0) {printf("0"); continue;}
		  if(CPlant::farm[i-FARM_i][j-FARM_j] == 3) {printf("3"); continue;}
		  printf("%d",CPlant::farm[i-FARM_i][j-FARM_j]);
		CEntity* ent = new CPlant;
		if(ent->OnLoad("../tilesets/weedsheet.png", 82, 82, 8, ren)  == 0) {  printf("\nnot farming 2\n");
		return false;
		}

		ent->Y = i*TILE_SIZE+TILE_SIZE/2 - ent->getCenter().second;
		ent->X = j*TILE_SIZE+TILE_SIZE/2 - ent->getCenter().first;
		CEntity::EntityList.push_back(ent);
	  }
	printf("\n");
	}
	return true;
}