https://github.com/pixelomer/libshijima
A shimeji simulation library written in C++
https://github.com/pixelomer/libshijima
cpp cross-platform desktop-pet library
Last synced: about 2 months ago
JSON representation
A shimeji simulation library written in C++
- Host: GitHub
- URL: https://github.com/pixelomer/libshijima
- Owner: pixelomer
- License: gpl-3.0
- Created: 2024-05-01T16:47:02.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-10-22T08:12:00.000Z (8 months ago)
- Last Synced: 2025-10-22T09:12:59.976Z (8 months ago)
- Topics: cpp, cross-platform, desktop-pet, library
- Language: C++
- Homepage:
- Size: 1.35 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libshijima
C++ library for shimeji desktop mascots.
(**Disclaimer:** libshijima is currently not accepting contributions. Any pull requests will be closed without review.)
## Usage
libshijima itself does not implement a GUI. Rather, it provides an easy API for parsing configurations files and interacting with shimeji. For an example usage of libshijima, see [main.cc](main.cc) which implements an SDL application for interacting with shimeji.
The main entry point for libshijima is `shijima::mascot::factory`. An app using libshijima may look something like the following:
```cpp
using namespace shijima;
//pseudocode
std::string ReadFile(std::string const& path);
void SleepForMilliseconds(int ms);
/* ... */
// Create a mascot factory
mascot::factory factory;
factory.script_ctx = std::make_shared();
factory.env = std::make_shared();
// Register mascot templates
mascot::factory::tmpl tmpl;
tmpl.name = "my_mascot";
tmpl.actions_xml = ReadFile("/path/to/shimeji/actions.xml");
tmpl.behaviors_xml = ReadFile("/path/to/shimeji/behaviors.xml");
tmpl.path = "/path/to/shimeji";
factory.register_template(tmpl);
// Spawn shimeji
mascot::manager::initializer init;
init.anchor.x = 100;
init.anchor.y = 100;
mascot::factory::product product = factory.spawn("my_mascot", init);
mascot::manager &shimeji = *product.manager;
// Run loop
while (true) {
// Populate shimeji environment
mascot::environment &env = *factory.env;
const int w=500, h=500;
env.work_area = env.screen = { 0, w, h, 0 };
env.floor = { h-50, 0, w };
env.ceiling = { 0, 0, w };
// Tick
shimeji.tick();
// Render shimeji
/*... platform dependent ...*/
// Shimeji are designed to run at 25 FPS
SleepForMilliseconds(1000 / 25);
}
```