Skip to content

SomePersonFromMars/WeirdSpace

Repository files navigation

WeirdSpace

huge_mountains_2-final.mp4
Nice landscape from the game.


The concept for this game is to create it "by hand", meaning no game engine is used. My goal is to write code optimized specifically for this game, minimizing the use of external code. When external code is used, it is highly specific and unlikely to need further optimization.

For now, this is a simple voxel-based, Minecraft-like early version of an open-world adventure game. A fairly good map (planet) generator has also been implemented.

I have many plans for the game's content, but I prefer not to reveal too much until I have time to implement them, as I develop this code in my spare time.

All I can say for now is that the space in this game is going to be weird.



Contents



Showcase of Implemented Features

Currently, the world consists only of deserts. Basic lighting and a fog effect have been implemented.

Each chunk is preprocessed before rendering in such a way that only potentially visible block faces are sent to the GPU. Such batch of faces is drawn using instancing to minimize data transfer. A chunk is rendered only if it fits within the view frustum.

Example worlds.



One of the weird concepts of this game is to mix 3D with 2D, so the player moves only in the XY plane.

walking_and_collisions.mp4
Player movement and collisions.



The map generator can create maps with many continents of variable shapes and sizes using Voronoi Diagrams. The landscapes are varied thanks to Fractal Brownian Motion. River networks are also present. Humidity and temperature values are calculated using parameters like altitude, latitude, and distance from oceans and rivers. These values will help determine biomes in the future.

Maps are cyclic in the X-axis, allowing them to be projected onto a cylinder. This feature aligns with the weird concept of mixing 2D and 3D.

Note: Many map generator features are not yet reflected in the rendered world.


Examples of maps generated by the multicore CPU map generator. Note the varying continents, landscape shapes, and river networks.
The humidity map is also shown.




Similar examples as before, but with temperature maps.




Examples of maps generated by the faster GPU map generator. River networks, humidity, and temperature have not yet been implemented.



It is planned that the player will move not just in an XY plane but along a curve, as visualized in the generator playground, making the game even weirder:

continents_with_rivers_1.mp4
Player moving along a predefined curve.



Generating maps on a GPU, instead of a CPU, allows for interesting features like dynamically evolving maps. This enables the creation of worlds that gradually change throughout gameplay (weird, isn't it?).

evolving_GPU_continents1.mp4


evolving_GPU_continents2.mp4

Map dynamically evolving due to GPU map generation.



Do not hesitate to try some features yourself! A GUI tool is available in the executables to tweak the settings. There are predefined presets with interesting settings and maps. Some settings are best viewed in the weird_space executable and others in the generator_playground executable, although both are compatible with both executables.

Temporary debug GUI showcase.



How to Run This Code

All binaries for both Linux and Windows are available on the Releases page (note that the Windows binary requires a runtime to be installed as described there).



How to Build It

First, clone the repository:

git clone --recurse-submodules https://github.com/SomePersonFromMars/WeirdSpace.git
cd WeirdSpace

Then follow the platform-specific instructions.

Debian-Based Linux Distros

# Required dependencies:
sudo apt-get install cmake make g++ libx11-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxrandr-dev libxext-dev libxcursor-dev libxinerama-dev libxi-dev

# Generate Makefiles:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..

To build and run the game:

cd game
make # Append -j for faster multicore compilation
./weird_space

To build and run the generator playground:

cd tools/generator_playground
make # Append -j for faster multicore compilation
./generator_playground

Windows

Enable Symbolic Links Support

As the repository uses symbolic links for compilation simplicity, you need to enable them:

  1. Enable "Developer Mode" in Windows 10/11 - this gives mklink permissions.
  2. Inside the repository directory, execute:
    git config core.symlinks true
    git reset --hard

Required Software

Install Visual Studio 2022 with the "Desktop development with C++" packages.

Compilation

Open the "x64 Native Tools Command Prompt for VS 2022" app and then:

  1. Navigate to the cloned repository.
  2. Create a build directory: mkdir build
  3. Enter the build directory: cd build
  4. Generate project files: cmake -G "Visual Studio 17 2022" ..
  5. Open the Visual Studio Solution file: start WeirdSpace.sln
  6. In the Solution Explorer, right-click on the weird_space or generator_playground target and click "Set as Startup Project."
  7. You can now build the executable or build and run it.

Other OSes/IDEs/Platforms

Instructions from this tutorial will probably work.



Credits

External Libraries Used in This Project

Sources of Knowledge and Code Samples Used in This Project



Copyright (C) 2024, Kacper Orszulak
GNU General Public License v3.0+ (see LICENSE.txt or https://www.gnu.org/licenses/gpl-3.0.txt)