201 lines
4.4 KiB
Markdown
201 lines
4.4 KiB
Markdown
# Simian
|
|
|
|
**Simian** is a Raylib + AngelScript test project on Windows and Linux.
|
|
It demonstrates how to integrate **Raylib** for graphics and **AngelScript** for scripting, including the `scriptstdstring` add-on.
|
|
|
|
## Refactored Architecture
|
|
|
|
The project has been refactored from a single `main.cpp` file into a more maintainable modular structure:
|
|
|
|
### Core Components
|
|
- **Application** (`Application.h/cpp`) - Main application lifecycle and game loop
|
|
- **ScriptEngine** (`ScriptEngine.h/cpp`) - AngelScript engine management and script compilation
|
|
- **ScriptBindings** (`ScriptBindings.h/cpp`) - C++ to AngelScript function bindings
|
|
- **HotReload** (`HotReload.h/cpp`) - File monitoring for automatic script reloading
|
|
- **main.cpp** - Minimal entry point
|
|
|
|
### Directory Structure
|
|
```
|
|
Simian/
|
|
├─ include/ # Header files
|
|
│ ├─ Application.h
|
|
│ ├─ ScriptEngine.h
|
|
│ ├─ ScriptBindings.h
|
|
│ └─ HotReload.h
|
|
├─ src/ # Source files
|
|
│ ├─ Application.cpp
|
|
│ ├─ ScriptEngine.cpp
|
|
│ ├─ ScriptBindings.cpp
|
|
│ └─ HotReload.cpp
|
|
├─ external/ # Dependencies
|
|
├─ scripts/ # AngelScript files
|
|
├─ main.cpp # Entry point
|
|
└─ CMakeLists.txt # Build configuration
|
|
```
|
|
|
|
---
|
|
|
|
## Requirements
|
|
|
|
### Windows
|
|
- Windows 10/11 (tested)
|
|
- [Visual Studio 2022](https://visualstudio.microsoft.com/) with **Desktop development with C++** workload
|
|
- [CMake 3.25+](https://cmake.org/download/)
|
|
- Git
|
|
- Optional: VSCode for editing
|
|
|
|
### Linux
|
|
- Ubuntu 20.04+ or equivalent Linux distribution
|
|
- GCC 9+ or Clang 10+
|
|
- [CMake 3.25+](https://cmake.org/download/)
|
|
- Git
|
|
- Development libraries: `sudo apt install build-essential cmake git`
|
|
|
|
---
|
|
|
|
## Getting Started
|
|
|
|
### 1. Clone the repository with submodules
|
|
|
|
```bash
|
|
git clone --recurse-submodules <your-repo-url>
|
|
cd Simian
|
|
```
|
|
|
|
If you forgot `--recurse-submodules`, run:
|
|
|
|
```bash
|
|
git submodule update --init --recursive
|
|
```
|
|
|
|
This will pull **Raylib** and **AngelScript** into `external/`.
|
|
|
|
---
|
|
|
|
### 2. Build with CMake
|
|
|
|
#### Windows (Visual Studio)
|
|
|
|
```bash
|
|
# Create build folder
|
|
mkdir build
|
|
cd build
|
|
|
|
# Generate Visual Studio solution (64-bit)
|
|
cmake -G "Visual Studio 17 2022" -A x64 ..
|
|
|
|
# Build Release version
|
|
cmake --build . --config Release
|
|
```
|
|
|
|
After building, the executable will be at:
|
|
|
|
```
|
|
build\Release\simian.exe
|
|
```
|
|
|
|
#### Linux (Unix Makefiles)
|
|
|
|
```bash
|
|
# Create build folder
|
|
mkdir build
|
|
cd build
|
|
|
|
# Generate Unix Makefiles
|
|
cmake -G "Unix Makefiles" ..
|
|
|
|
# Build
|
|
cmake --build .
|
|
```
|
|
|
|
After building, the executable will be at:
|
|
|
|
```
|
|
build/simian
|
|
```
|
|
|
|
---
|
|
|
|
### 3. Run the project
|
|
|
|
#### Windows
|
|
```bash
|
|
build\Release\simian.exe
|
|
```
|
|
|
|
#### Linux
|
|
```bash
|
|
./build/simian
|
|
```
|
|
|
|
You should see a **Raylib window** open and the console will output:
|
|
|
|
```
|
|
[Script] Hello from AngelScript!
|
|
```
|
|
|
|
---
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
Simian/
|
|
├─ external/
|
|
│ ├─ raylib/ # Git submodule
|
|
│ └─ angelscript/ # Git submodule (includes scriptstdstring add-on)
|
|
├─ scripts/ # Optional: .as scripts to be loaded at runtime
|
|
├─ main.cpp # Entry point (Raylib + AngelScript)
|
|
├─ CMakeLists.txt # Build configuration
|
|
└─ README.md
|
|
```
|
|
|
|
---
|
|
|
|
## Notes
|
|
|
|
* **AngelScript `string` support** is enabled via `scriptstdstring` add-on.
|
|
* **Hot-reloading scripts** can be implemented by loading `.as` files from the `scripts/` folder.
|
|
* Update submodules with:
|
|
|
|
```bash
|
|
cd external/raylib
|
|
git pull origin master
|
|
cd ../angelscript
|
|
git pull origin master
|
|
cd ../..
|
|
git add external/raylib external/angelscript
|
|
git commit -m "Update submodules"
|
|
```
|
|
|
|
---
|
|
|
|
## CMake Targets
|
|
|
|
* `simian` — main executable
|
|
* `raylib` — static library submodule
|
|
* `angelscript` — static library submodule
|
|
* `scriptstdstring` — static library add-on for AngelScript
|
|
|
|
---
|
|
|
|
## Tips
|
|
|
|
#### Windows
|
|
* Always use **VS2022 Developer Command Prompt** or VSCode terminal configured for MSVC.
|
|
|
|
#### Linux
|
|
* Make sure you have the required development packages installed.
|
|
* On some distributions you may need additional X11 development libraries.
|
|
|
|
#### General
|
|
* Pin submodules to specific commits for reproducible builds.
|
|
* To clean build: delete the `build/` folder and regenerate with CMake.
|
|
|
|
---
|
|
|
|
## License
|
|
|
|
* Raylib: [Zlib License](https://github.com/raysan5/raylib#license)
|
|
* AngelScript: [MIT License](https://github.com/angelcode/angelscript/blob/master/license.txt)
|
|
* Simian: Not open source (Yet)
|