Hello World

Learn how to create a simple multiplayer game using Hadean Simulate and Hadean Connect.
Open the Hello World completed code from your starter pack, over the following pages we'll discuss the components of a Simulate simulation in detail and demonstrate how to build the project, finishing with running the simulation in the cloud.

Components of a Hadean Simulate project

When creating a project using Simulate and Connect, there are three components that need to be created:

1. The Simulation

Simulate projects are all about creating a simulation. This is where the code for any game logic, scientific models or user interactions will be. The logic you write here will allow you to update the state of entities that exist in your simulation. Entities can have any state you like - maybe they have health and ammunition, or maybe they have an infection status. The two things that entities must have are a unique ID, and a position.
Simulate will use the position to understand which cell the entity belongs to, and from that which workers need to know about the entity. Simulate achieves scale by only letting workers that are simulating cells near an entity know about that entity - no individual worker will have a view of all entities in the simulation. This can sound scary, so Simulate provides a set of APIs to help you out, we'll show you some over the next few pages.

2. The Netcode

Having Simulate simulating all the entities in the world space is great, but normally we want to be able to see and interact with them. Imagine a game with no players - not much fun! But sending millions of entities to every player over the internet is not practical. To allow players to interact with simulations that have millions of entities and thousands of players, Simulate uses Connect. Connect is all about figuring out which entities a player needs to know about. The process of figuring out which entities a player should know about each tick is handled by the netcode.
The netcode is often the secret sauce in making a game run smoothly, and so Connect allows you complete control over what you need. Creating a really smooth, efficient netcode can be a difficult problem, so to help out Connect provides a generic implementation, which you can drop in to start using Connect quickly.

3. The Client

Simulate and Connect together allow you to scale your game to handle millions of entities and thousands of players. But taken on their own your players won't have a great experience - we need a client that can render all the entities and allow users to control their characters. The choice of client is left largely to you - using established game engines such as Unreal Engine or Unity are good choices, or you can use a custom engine.
Whichever engine you decide to use for your client, it must be able to interact with Connect. To help with this, Connect provides a Connect Client library that you can include in your project. This library will allow you to connect to a Connect node, receive entity data and send back messages for player input or state.

Building and running the project

Simulate simulations use CMake as the build tool, and you can use any IDE that supports CMake to interact with the build toolchain, or invoke CMake yourself. The Aether Engine SDK also provides a CLI tool you can use to build your simulation, which invokes CMake for you.
To build the simulation using the CLI, open a terminal (powershell, bash and cmd are all supported).
Bash, cmd.exe
$ cd ./path/to/your/project
$ cmake -B build -G Ninja && ninja -C build
$ cd ./path/to/your/project
$ cmake -B build -G Ninja; ninja -C build
This will build your simulation. If you are using Visual Studio 2019, you can take advantage of the built in support for CMake. In this project we have provided a CMakeSettings.json to enable Visual Studio support.
If you have installed your Aether Engine SDK to a custom location, you will need to update the CMakeSettings.json file to reflect the paths to your SDK installation. You will need to update the BUILD_TOOLS and AETHER_SDK paths, which can be found in the environments section at the start of the CMakeSettings.json file.
If you see an error that says error: 'C:/Program', needed by 'simulation', missing and no known rule to make it, you may be using the wrong version of CMake to build the simulation. You can follow the instructions at it-is-possible-to-get-the-following-error-during-the-build. in order to resolve this issue
Inside Visual Studio, select either AetherSimulationMuxer-Debug or AetherSimulationMuxer-Release as the build configuration, then right click on the CMakeLists.txt file in the solution explorer and click Generate Cache, then right click on the CMakeLists.txt file again and choose Build.
To run the simulation, you must use the Aether Engine SDK aether CLI. To run the project against the local VM, open a terminal (powershell, bash and cmd are all supported).
$ cd ./path/to/your/project
$ aether run
This will start the simulation on your local VM.