C++ API for Screeps RTS
Find a file
2021-06-13 23:27:06 +03:00
example Add example application. 2021-06-13 22:46:43 +03:00
include Naive implementation of MemoryObject. 2021-06-13 22:33:34 +03:00
src Naive implementation of MemoryObject. 2021-06-13 22:33:34 +03:00
tools Add example application. 2021-06-13 22:46:43 +03:00
.clang-format Upload sources. 2021-05-30 01:14:25 +03:00
.gitignore Add example application. 2021-06-13 22:46:43 +03:00
CMakeLists.txt Add example application. 2021-06-13 22:46:43 +03:00
LICENSE Initial commit 2021-05-29 23:25:36 +03:00
README.md Add README. 2021-06-13 23:27:06 +03:00

screepsxx

screepsxx is a C++ library for Screeps API. It provides wrappers for the majority of classes in Screeps API.

Requirements

  • Emscripten toolchain
  • CMake 3.16+
  • Ninja build system
  • (Optional) Python 3 interpreter for artifacts uploading

Building

git clone https://github.com/UltraCoderRU/screepsxx.git
cd screepsxx
mkdir build
cd build
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=<path_to_emsdk>/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
# Add -DSCREEPSXX_BUILD_EXAMPLE=ON to build example application (see 'example' directory)

Using library in CMake project

The simplest way to use screepsxx library is to add it to your project with add_subdirectory():

cmake_minimum_required(VERSION 3.16)

project(MyProject CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s STRICT=0 -s ASSERTIONS=0 -s ALLOW_MEMORY_GROWTH=1 -s ENVIRONMENT=shell -s MALLOC=emmalloc --cache ${CMAKE_BINARY_DIR}/cache")

add_subdirectory(screepsxx)

add_executable(myapp loop.cpp)
target_link_libraries(myapp screepsxx)
target_link_options(myapp PUBLIC -sMODULARIZE=1 --no-entry --bind)

Compiled WASM-module (myapp.wasm) and corresponding JavaScript module (myapp.js) will appear in your build directory (CMAKE_BINARY_DIR). To use them inside Screeps, you need two additional JavaScript modules located in js directory. Put all four files into one directory and upload them to Screeps server. You can use Python script tools\upload.py, see example/CMakeLists.txt for details.