summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2024-11-30 15:26:03 +0100
committerAldrik Ramaekers <aldrikboy@gmail.com>2024-11-30 15:26:03 +0100
commit5603b2b4d767d03859299a1615819297cea8a900 (patch)
tree0731036f7af20b387dda491d9cf5fb22d892e351
parent69264dd20ec917c738d56431cd4a85dcacee9a40 (diff)
locations
-rw-r--r--data/world/locations.json246
-rw-r--r--src/world.c45
2 files changed, 281 insertions, 10 deletions
diff --git a/data/world/locations.json b/data/world/locations.json
index a7e1a92..0a05d43 100644
--- a/data/world/locations.json
+++ b/data/world/locations.json
@@ -60,15 +60,15 @@
"size": 1
},
{
- "latitude": 52.5069386,
- "longitude": 12.2599279,
+ "latitude": 51.652176,
+ "longitude": 11.653534,
"name": "Berlin",
"size": 1
},
{
"latitude": 48.1549958,
"longitude": 11.4594358,
- "name": "München",
+ "name": "Munich",
"size": 1
},
{
@@ -430,5 +430,245 @@
"longitude": -127.173752,
"name": "Vancouver",
"size": 1
+ },
+ {
+ "latitude": 21.000008,
+ "longitude": -92.052528,
+ "name": "merida",
+ "size": 1
+ },
+ {
+ "latitude": 17.170219,
+ "longitude": -95.642960,
+ "name": "Tuxtla Gutiérrez",
+ "size": 1
+ },
+ {
+ "latitude": 20.148941,
+ "longitude": -102.584450,
+ "name": "Mexico City",
+ "size": 1
+ },
+ {
+ "latitude": 27.382984,
+ "longitude": -104.020615,
+ "name": "Monterrey",
+ "size": 1
+ },
+ {
+ "latitude": 24.829788,
+ "longitude": -109.047211,
+ "name": "Durango",
+ "size": 1
+ },
+ {
+ "latitude": 28.659580,
+ "longitude": -112.637642,
+ "name": "Hermosillo",
+ "size": 1
+ },
+ {
+ "latitude": 15.468086,
+ "longitude": -93.249344,
+ "name": "Guatamala City",
+ "size": 1
+ },
+ {
+ "latitude": 15.042557,
+ "longitude": -92.291885,
+ "name": "San Salvador",
+ "size": 1
+ },
+ {
+ "latitude": 22.182793,
+ "longitude": -106.805443,
+ "name": "Guadalajara",
+ "size": 1
+ },
+ {
+ "latitude": 41.652172,
+ "longitude": 13.120926,
+ "name": "Rome",
+ "size": 1
+ },
+ {
+ "latitude": 44.043480,
+ "longitude": 11.653534,
+ "name": "Bologna",
+ "size": 1
+ },
+ {
+ "latitude": 45.782608,
+ "longitude": 8.718750,
+ "name": "Milan",
+ "size": 1
+ },
+ {
+ "latitude": 51.434784,
+ "longitude": 19.724182,
+ "name": "Warsaw",
+ "size": 1
+ },
+ {
+ "latitude": 53.608700,
+ "longitude": 18.501358,
+ "name": "Gdańsk",
+ "size": 1
+ },
+ {
+ "latitude": 48.582417,
+ "longitude": 14.529190,
+ "name": "Vienna",
+ "size": 1
+ },
+ {
+ "latitude": 50.120880,
+ "longitude": 13.540176,
+ "name": "Prague",
+ "size": 1
+ },
+ {
+ "latitude": 49.666668,
+ "longitude": 17.468750,
+ "name": "krakow",
+ "size": 1
+ },
+ {
+ "latitude": 47.404495,
+ "longitude": 17.440659,
+ "name": "Budapest",
+ "size": 1
+ },
+ {
+ "latitude": 44.333332,
+ "longitude": 17.968750,
+ "name": "Serajevo",
+ "size": 1
+ },
+ {
+ "latitude": 42.910110,
+ "longitude": 19.463135,
+ "name": "Podgorica",
+ "size": 1
+ },
+ {
+ "latitude": 41.681820,
+ "longitude": 21.247162,
+ "name": "Skopje",
+ "size": 1
+ },
+ {
+ "latitude": 42.590908,
+ "longitude": 23.803970,
+ "name": "Sofia",
+ "size": 1
+ },
+ {
+ "latitude": 40.090908,
+ "longitude": 29.428970,
+ "name": "Istanbul",
+ "size": 1
+ },
+ {
+ "latitude": 45.772728,
+ "longitude": 12.298294,
+ "name": "Venice",
+ "size": 1
+ },
+ {
+ "latitude": 38.764706,
+ "longitude": 42.733459,
+ "name": "Van",
+ "size": 1
+ },
+ {
+ "latitude": 40.655174,
+ "longitude": 50.485992,
+ "name": "Baku",
+ "size": 1
+ },
+ {
+ "latitude": 35.883720,
+ "longitude": 52.148987,
+ "name": "Tehran",
+ "size": 1
+ },
+ {
+ "latitude": 33.298851,
+ "longitude": 46.606674,
+ "name": "Baghdad",
+ "size": 1
+ },
+ {
+ "latitude": 33.298851,
+ "longitude": 38.072205,
+ "name": "Damascus",
+ "size": 1
+ },
+ {
+ "latitude": 31.919540,
+ "longitude": 36.779099,
+ "name": "Amman",
+ "size": 1
+ },
+ {
+ "latitude": 37.823528,
+ "longitude": 46.704041,
+ "name": "Tabriz",
+ "size": 1
+ },
+ {
+ "latitude": 33.469135,
+ "longitude": 41.635422,
+ "name": "Rutba",
+ "size": 1
+ },
+ {
+ "latitude": 36.185184,
+ "longitude": 40.524307,
+ "name": "Al Hasakah",
+ "size": 1
+ },
+ {
+ "latitude": 55.750000,
+ "longitude": 42.187500,
+ "name": "Moscow",
+ "size": 1
+ },
+ {
+ "latitude": 53.278481,
+ "longitude": 27.943436,
+ "name": "Minsk",
+ "size": 1
+ },
+ {
+ "latitude": 47.338028,
+ "longitude": 45.320862,
+ "name": "Volgograd",
+ "size": 1
+ },
+ {
+ "latitude": 31.000000,
+ "longitude": 48.664398,
+ "name": "Kuwait",
+ "size": 1
+ },
+ {
+ "latitude": 26.942028,
+ "longitude": 50.620926,
+ "name": "Dammam",
+ "size": 1
+ },
+ {
+ "latitude": 39.695652,
+ "longitude": 66.925278,
+ "name": "Dushanbe",
+ "size": 1
+ },
+ {
+ "latitude": 29.036678,
+ "longitude": 32.189560,
+ "name": "Cairo",
+ "size": 1
}
] \ No newline at end of file
diff --git a/src/world.c b/src/world.c
index e8024a7..2892246 100644
--- a/src/world.c
+++ b/src/world.c
@@ -102,8 +102,45 @@ static world_location world_create_location(u8 size, double latitude, double lon
return location;
}
+static world_location* world_get_location_by_name(world* world, char* str)
+{
+ for (s32 i = 0; i < world->locations.length; i++)
+ {
+ world_location* source = array_at(&world->locations, i);
+ if (strcmp(source->name, str) == 0) return source;
+ }
+ return 0;
+}
+
+static void connect_locations(world* world, char* str1, char* str2)
+{
+ world_location* loc1 = world_get_location_by_name(world, str1);
+ world_location* loc2 = world_get_location_by_name(world, str2);
+
+ array_push(&loc1->connections, &loc2);
+}
+
+static void world_create_manual_connections(world* world)
+{
+ connect_locations(world, "Minsk", "Warsaw");
+ connect_locations(world, "Moscow", "Volgograd");
+ connect_locations(world, "Volgograd", "Baku");
+ connect_locations(world, "Mexico City", "Tuxtla Gutiérrez");
+ connect_locations(world, "Sofia", "Istanbul");
+ connect_locations(world, "Istanbul", "Van");
+ connect_locations(world, "Tabriz", "Tehran");
+ connect_locations(world, "Baghdad", "Tehran");
+ connect_locations(world, "Baghdad", "Rutba");
+ connect_locations(world, "Tehran", "Dushanbe");
+ connect_locations(world, "Tabriz", "Baku");
+ connect_locations(world, "Kuwait", "Dammam");
+ connect_locations(world, "Cairo", "Amman");
+}
+
static void world_create_connections(world* world)
{
+ world_create_manual_connections(world);
+
double max_distance = 410;
for (s32 i = 0; i < world->locations.length; i++)
{
@@ -123,8 +160,6 @@ static void world_create_connections(world* world)
printf("%s %s -> %f\n", source->name, destination->name, distance_between_location(source, destination));
#endif
-
-
if (total_dist < max_distance) {
array_push(&source->connections, &destination);
}
@@ -135,10 +170,6 @@ static void world_create_connections(world* world)
}
}
}
-
- if (source->connections.length <= ((source->longitude < -90) ? 1 : 0) && closest_loc != 0) {
- array_push(&source->connections, &closest_loc);
- }
}
}
@@ -1379,7 +1410,7 @@ world_update_result world_render(platform_window* window, world* world)
s32 circle_x = location->map_position_x - dotsize/2;
s32 circle_y = location->map_position_y - dotsize/2;
bool hovered = mouse_interacts(circle_x, circle_y, dotsize, dotsize);
- location->is_accessible = world_check_location_accessibility(location, location, 1, 0);
+ location->is_accessible = true;//world_check_location_accessibility(location, location, 1, 0);
location->is_hovered = hovered;
if (hovered && location->is_accessible) {