|
@@ -29,15 +29,44 @@ int main()
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
SDL_Surface* grass = SDL_LoadBMP("textures/grass.bmp");
|
|
|
SDL_Surface* water = SDL_LoadBMP("textures/water.bmp");
|
|
|
SDL_Surface* desert = SDL_LoadBMP("textures/desert.bmp");
|
|
|
SDL_Surface* mountain = SDL_LoadBMP("textures/mountain.bmp");
|
|
|
SDL_Surface* pawn = SDL_LoadBMP("textures/pawn.bmp");
|
|
|
+
|
|
|
+
|
|
|
SDL_Rect pos({0, 0, 0, 0});
|
|
|
SDL_Rect pawnPos({0, 0, 0, 0});
|
|
|
|
|
|
+
|
|
|
+ const int blocTotal = 4;
|
|
|
+ enum blocType {WATER, MOUNTAIN, GRASS, DESERT};
|
|
|
+ float world[height][width][blocTotal];
|
|
|
+
|
|
|
+
|
|
|
+ for (int j(0); j < height; j++)
|
|
|
+ for (int i(0); i < width; i++)
|
|
|
+ for (int t(0); t < blocTotal; t++)
|
|
|
+ world[j][i][t] = 0.0f;
|
|
|
+
|
|
|
+
|
|
|
+ const int waterLevel = 0.01f;
|
|
|
+ for (int j(0); j < height; j++)
|
|
|
+ for (int i(0); i < width; i++)
|
|
|
+ world[j][i][WATER] = waterLevel;
|
|
|
+
|
|
|
+
|
|
|
+ const int mountainLevel = 10.0f;
|
|
|
+ for (int j(0); j < height; j++)
|
|
|
+ for (int i(0); i < width; i++)
|
|
|
+ world[j][i][MOUNTAIN] = mountainLevel / (1 + j);
|
|
|
+
|
|
|
+
|
|
|
+ SDL_Surface* select;
|
|
|
+ SDL_Surface* tileSet[blocTotal] = {water, mountain, grass, desert};
|
|
|
+
|
|
|
|
|
|
bool done(false);
|
|
|
while (!done)
|
|
@@ -70,9 +99,16 @@ int main()
|
|
|
|
|
|
for (int y(0); y < height; y++)
|
|
|
for (int x(0); x < width; x++) {
|
|
|
+ select = tileSet[0];
|
|
|
pos.x = x * blocSize;
|
|
|
pos.y = y * blocSize;
|
|
|
- SDL_BlitSurface(water, NULL, screen, &pos);
|
|
|
+
|
|
|
+
|
|
|
+ for (int k(1); k < blocTotal; k++)
|
|
|
+ if (world[y][x][k] > world[y][x][k - 1])
|
|
|
+ select = tileSet[k];
|
|
|
+
|
|
|
+ SDL_BlitSurface(select, NULL, screen, &pos);
|
|
|
}
|
|
|
|
|
|
SDL_BlitSurface(pawn, NULL, screen, &pawnPos);
|