.. role:: raw-html-m2r(raw)
:format: html
Game scene creation
===================
This documentation provides a quick review on how the game scene is created
Map creation
------------
Querying the server
^^^^^^^^^^^^^^^^^^^
Once the player has selected a location, a request is made to the server with the coordinates of the zone that will be displayed. The servers returns then a 64x64 giving information about ground type and altitude from Copernicus Land Use data
Another query is done to get the climate code of the zone, which will be used to do the reprensentation
Map generation
^^^^^^^^^^^^^^
Coordinate retrieval is handled by several functions that detect the scene that sent them, then convert them to EPSG3857 if required.\ :raw-html-m2r:`
`
If there is a problem loading the scene, an error message is displayed and the *scene_choice.tscn* is loaded again.
``func set_tile(osm_data, climate_code, data_dict)``
This function creates the game scene using Godot Tilemap object.\ :raw-html-m2r:`
`
This function traverses the matrix *osm_data*\ , returned by the server, containing the classification of each part of the treated area. For each element of the matrix, one or more tiles (depending on terrain elevation) of the type corresponding to the given class and climate, with *climate_code* and *data_dict*\ , are created.\ :raw-html-m2r:`
`
Finally, depending on the class of the tile, an element such as a tree, building, etc. is added.\ :raw-html-m2r:`
`
When, at a given position, the number of tiles created exceeds a certain level, a mountain is placed in its place.
``func add_points_of_interest()``
This function displays points of interest in the scene (water, forest, city, farmland, etc.).\ :raw-html-m2r:`
`
These points of interest are buttons that display an information popup when the user clicks on them. This popup contains various pieces of information about forests, towns, fields, etc. Their text changes as the game progresses.
To display these points of interest, we first scan the scene to detect groups of objects (a group of trees represents a forest, for example). To do this, for each object, we collect the positions around it and count the number of objects of the same type. If the number of identical objects around it exceeds a certain percentage, its position is saved. Then choose a position at random from those recorded. If no group exists for an object type, then the point of interest is considered unrepresentative.\ :raw-html-m2r:`
`
This procedure is repeated for each type of object.
Map updates
-----------
For each step, after clicking on a bubble that provides the player with information about the environment (points of interest), the player is presented with a choice of actions by Desty. The player can only choose one action. These actions directly affect the amount of CO2 released into the atmosphere, which will change the scene over the course of the game.\ :raw-html-m2r:`
`
An environmental indicators panel is located in the top right corner of the screen, providing various information such as the temperature difference compared to the pre-industrial era, sea level rise, local temperature, and other indicators in Mystery mode.\ :raw-html-m2r:`
`
For the CO2 calculation, we assume we start in the worst-case scenario from the IPCC. At each step, we add the impact of the player's action to the current scenario forecast for the next 20 years, then we compare this value to the forecasts of all scenarios and select as the reference scenario for the next step the one with the CO2 value closest to it.\ :raw-html-m2r:`
`
The map is then regenerated to simulate the consequences of the player’s actions. As the temperature rises, the colors of the area slightly yellow. To achieve this result, our tileset has been designed so that the columns are repetitions of the previous columns but with a yellowed hue. We then choose the column with the variable temp_offset, which is equal to the floor of the temperature difference between the current world and the pre-industrial world. The temperature also affects the density of trees in the area; as it increases, more trees disappear.\ :raw-html-m2r:`
`