Skip to content

jsonxr/blockworld

Repository files navigation

BlockWorld clone

Following along with the YouTube series.

Setup

Install

  • direnv brew install direnv

  • cmake brew install cmake

  • emscripten

    # Install
    cd /opt
    git clone https://github.com/emscripten-core/emsdk.git
    cd /opt/emsdk
    # Update to latest version
    cd /opt/emsdk
    git pull
    ./emsdk install latest
    ./emsdk activate latest
    # .zprofile
    export EMSDK_HOME=/opt/emsdk
    source $EMSDK_HOME/emsdk_env.sh > /dev/null 2>&1
  • Conan package manager - brew install conan

  • Copy minecraft files...

    # Show available versions of minecraft on a mac
    bin/minecraft-extract
    # Extract specific version of minecraft
    bin/minecraft-extract 1.18.1

Compile

# libc++ vs stdlibc++ might depend on platform...
# https://stackoverflow.com/questions/14972425/should-i-use-libc-or-libstdc
# Install
conan install . -s build_type=Debug -s compiler.libcxx=libc++ -s cppstd=20 --install-folder=build --build missing
cd build && cmake .. && cmake --build .

# optional...
# This will use the assets in the project instead of relying on cmake to copy.
# This avoids being confused when you change a shader and nothing happens.
# BLOCKWORLD_ASSETS_PATH=$(pwd)/client/assets

# Run app...
bin/blockworld

# Release dependencies
# conan install . -s build_type=Release -s compiler.libcxx=libc++ -s cppstd=20 --install-folder=cmake-build-release --build missing

Wasm

Uses Experimental Features: WebAssembly Roadmap

  • Exceptions (Chrome, In progress: Firefox, No: Safari) - We just have to deal with crashes until this is supported
  • Threads and atomics (Chrome, Firefox, In progress: Safari) - Not used yet, but we will want to...
  • WebGPU
conan install . -s build_type=Debug -s compiler.libcxx=libc++ -s cppstd=20 --install-folder=build-wasm --build missing
cd build-wasm && emcmake cmake .. && cmake --build .

# Run app...
npx http-server bin  # This assumes node is installed...
open http://127.0.0.1:8080/blockworld.html

#emcc src/main.cpp -o cmake-build-wasm/index.html -Iinclude -s USE_WEBGL2=1 -s USE_GLFW=3 -s WASM=1 -std=c++20 -fwasm-exceptions

wasm cmake dependencies

Exceptions

CLion

# Install conan dependencies
conan install . -s build_type=Debug --install-folder=build-cmake-debug --build missing
# dont do below, click on that conan install at the bottom and then reload the cmake project in the ide
#cd cmake-build-debug && cmake ..

VSCode

Install the following plugins, then follow compile directions.

Resources

C++ Standard

https://en.cppreference.com/w/cpp/compiler_support

Libraries

TODO

WebGL2

  • TextureArray (Bug in m1 mac that causes it to fail)

Noise

Ambient Lighting

Serialization

About

Clone of popular block placing game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published