I created an N × N list to store the y-offsets of the parts within the map. These offsets are generated using a noise function, which is then multiplied by other noise values to create greater contrast between the low and high points on the map.
This is how I implemented chance: a random number is generated, and if it falls below a threshold, a special ore is created instead of normal stone. The process works by subtracting the probability of each ore in sequence.
For each part near a generated object, the smallest one’s height is added to the height of the current part. This ensures there are no visible gaps in the mountains, rather than the part’s height staying constant.
This shows a greedy approach to finding the peaks of the mountains: if a point is sufficiently high and taller than its neighbors, it is illuminated as a peak.
Player data is saved within my game, where each player has a file system that stores their data. The system is checked as they leave and updated accordingly.
This checks if a stored value exists for a requested attribute, and if not, it is set to 0 or the default value. This way, if a new data type or upgrade is added, the entire save won’t be wiped.
This is a large table of all the data values needed for the game to function. Each dictionary entry acts as a folder, with specific values stored as strings or floats depending on the entry type.
As stated above, if a value is a string, it becomes a stringValue, which is the method of storing characters. If it’s a numeric entry, it is stored as a 64-bit float. I don’t store any combinations of numbers and letters, so this approach works. dataInit informs the client that all data has been loaded and the GUI can now be displayed for the player.
There are upgrade boards within the game, and all money operations must be handled on the server. The player only sends whether they are buying ‘one’ or ‘max’ and which button they clicked. The server then checks if they have sufficient funds and continues upgrading until they reach their maximum or can no longer afford to upgrade further.
This function ensures that numbers are clean and rounded, eliminating what I consider to be ugly floating-point values. It also converts large numbers, such as 4,595,490,233, into a shorter format, like 4.60B, using the shortScale list.