@evitcastudio/kit
v3.0.1
Published
A single-player/multiplayer framework for the Vylocity Game Engine.
Maintainers
Readme
Kit
Kit is a lightweight, extensible 2D framework for game development in the Vylocity Game Engine. Designed to be simple and modular, Kit empowers developers to build complex projects quickly through a robust plugin-driven architecture.
Installation
bun install -g @evitcastudio/kitNote: The
-gflag ensures thekitCLI tool is globally available in your PATH.
Scaffolding a New Project
The kit init command provides an interactive walkthrough to quickly scaffold a new project for the Vylocity Game Engine.
# Start the interactive walkthrough
kit init
# Or scaffold a project with flags
kit init <project-name> --single # For single-player
kit init <project-name> --multi # For multiplayerThe command will create a structured directory for your project, including pre-configured package.json, essential Vylocity files, and a local development environment.
After scaffolding, follow these steps to get started:
cd <project-name>bun installbun run build
Building the Project
Note: This process is preconfigured for you if you used
kit init
The kit build command locates all Vylocity engine-related resources in your source directory, anonymizes them, and moves them to a deploy-ready output directory.
kit build -i ./<in-dir> -o ./<out-dir># To learn more about this command
kit build --helpExecuting this command automatically generates a resource.json map in your project's directory.
Best Practice: Exclude resource.json from version control (.gitignore), as it is a build artifact.
Runtime Resource Loading
Note: This process is preconfigured for you if you used
kit init
Kit.setResources()should be called beforeVYLO.load().
import resourceJSON from 'resource.json';
// Initialize the engine with mapped resources
await Kit.setResources(resourceJSON);Local Development & Testing
Once your project is scaffolded and dependencies are installed and the project has been built, you can run your game locally.
Running the Game
# For Single-Player or Multiplayer games
bun run hostAccessing the Game
The server will be available at the following locations after being hosted:
Singleplayer
http://localhost:8090 defined in./bun-serve.ts
Multiplayer or Singleplayer & Multiplayer
http://localhost:30000 defined in./src/server/settings.json
Plugin Architecture
import { Plugin } from 'custom-plugin';
// Register a single plugin
const plugin = Kit.registerPlugin(Plugin);// Register multiple plugins
import { Plugin1 } from 'custom-plugin1';
import { Plugin2 } from 'custom-plugin2';
const plugins = Kit.registerPlugins([Plugin1, Plugin2]);
// After being registered, kit can find the plugin by name.
const plugin1 = Kit.getPlugin('plugin1-name');
const plugin2 = Kit.getPlugin('plugin2-name');Listening for plugin events
Plugins emit events, this is how they pass relevant data to other plugins or the main thread. By listening to these events you can act on this data.
const listener = (pEvent: EmitterEvent) => {
const { data, timestamp } = pEvent;
// Here you can use the data that the event sent down.
}
// Choose to listen to specific event from a plugin
Kit.on('plugin-name', 'event-name', listener);
// You can also stop listening for an event
Kit.off('plugin-name', 'event-name', listener);For more information check out the wiki
