Better map uploading algorithm
This commit is contained in:
@@ -45,3 +45,4 @@ void GfxContext_render (GfxContext *self);
|
||||
void GfxContext_free (GfxContext * self);
|
||||
|
||||
void GfxContext_cache_World (GfxContext * self, World * world);
|
||||
void GfxContext_update_Players (GfxContext *self, World * world);
|
||||
|
||||
+8
-5
@@ -65,21 +65,24 @@ World_load_from_file (const char *path)
|
||||
/* NULL is a palette, only used in indexed images. */
|
||||
SDL_GetRGBA (pixel, details, NULL, &r, &g, &b, &a);
|
||||
|
||||
/* The ranges here can be tweaked to work better or
|
||||
worse. */
|
||||
if (b > 196 && r < 50 && g < 50)
|
||||
/* Improved color ranges (handles light blue water better) */
|
||||
if (b > 120 && (b > g || b > r))
|
||||
{
|
||||
/* Water: medium-to-light blues */
|
||||
mt->terrain_type = TERRAIN_WATER;
|
||||
}
|
||||
else if (g > 200)
|
||||
else if (g > 140 && g >= r && g >= b)
|
||||
{
|
||||
/* Green-dominant = flat/grassland */
|
||||
mt->terrain_type = TERRAIN_FLAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise: hills/mountains */
|
||||
mt->terrain_type = TERRAIN_HILL;
|
||||
}
|
||||
|
||||
/* Thanks, ChatGPT! */
|
||||
|
||||
g_array_append_val (self->tiles, mt);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user