New Hugo site in website/ with prosperon.dev theme (blue/gold/castle aesthetic), docs sidebar navigation, and content pages. Rewrote all doc files to align with the actual codebase: compositor+film2d rendering, use() modules (no global prosperon object), Pit language, script+JSON entity model. Added entities.md, front matter to all 70+ API docs, and updated API index for current module architecture. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
2.0 KiB
Markdown
49 lines
2.0 KiB
Markdown
---
|
|
title: "Resources"
|
|
type: docs
|
|
---
|
|
|
|
# Resources
|
|
|
|
Prosperon uses string paths to reference assets — images, sounds, fonts, scripts. The resource system resolves these paths and caches loaded assets.
|
|
|
|
## Module Resolution
|
|
|
|
`use('path')` loads a module by searching for `path.cm` in this order:
|
|
|
|
1. The current module's directory
|
|
2. Mounted roots (the program's directory is always mounted)
|
|
3. Embedded/native modules if no script file is found
|
|
|
|
Modules compile to bytecode (`.o` files) and are cached after first load. Subsequent `use()` calls return the cached value.
|
|
|
|
## Asset Resolution
|
|
|
|
When you reference an asset like `"player.png"`, the resource system searches mounted paths for a match. Assets should generally be referenced **without** a file extension — the engine tries appropriate extensions based on context:
|
|
|
|
- **Images:** png, qoi, gif, jpg, jpeg, ase
|
|
- **Sounds:** wav, ogg, mp3
|
|
- **Fonts:** ttf
|
|
|
|
Omitting extensions lets the engine swap optimized formats transparently. If you specify an extension, only that exact file is searched for.
|
|
|
|
## Caching
|
|
|
|
All loaded assets are cached. When two sprites reference the same image path, they share one GPU texture. Sound data, fonts, and bytecode are similarly deduplicated.
|
|
|
|
## Mounts
|
|
|
|
Prosperon uses a virtual filesystem. The write directory is set to the folder the engine runs from. That same folder is mounted as a read directory, along with the executable itself (which contains a zip archive of core engine assets).
|
|
|
|
Additional folders or zip archives can be mounted, allowing mods to override specific files:
|
|
|
|
```javascript
|
|
// A mod zip containing sprites/bug.png will override the game's bug.png
|
|
```
|
|
|
|
Because all asset references are string paths resolved through the mount system, modding is straightforward — mount a new archive and its files take priority.
|
|
|
|
## .prosperonignore
|
|
|
|
A `.prosperonignore` file in a mounted directory excludes files from resolution, similar to `.gitignore`. This is useful for keeping source assets (e.g., Aseprite working files) out of the build.
|