Multi-platform 2D interaction engine
Core2D is the powerhouse used by Maragato マラガト apps, among others. It is the evolution of Videogame, which in turn was the evolution of Quick. In its current form, it adopts JavaScript modules, leveraging the full power of Object-oriented programming.
Apps created with Core2D are made of one or more scenes, which may contain one or more sprites. These objects have properties that can be customized to shape their behavior. It’s that simple.
Download or clone/fork the skeleton project to start building your app. Alternatively, the library can be also installed to your existing/new project:
npm install core2d
The best way to learn is by doing, and you can see what Core2D is capable of through existing open-sourced apps. Check the Hall of Fame below for some source code.
Please consider joining the Discussions for collaboration and support.
Core2D facilitates the organization of your app into one or more scenes, which can be transitioned between. Each scene can contain multiple sprites, which are the basic building blocks for game objects.
The engine provides a simple yet powerful sound system that allows for playing sound effects and background music. It also supports fading out the current theme, which is useful for smooth transitions between different music tracks.
Translated to callbacks, to keep update logic clean.
Assets and their transformations are reused automatically to keep a solid performance.
Core2D provides a set of functions to manipulate images, including rotation, flipping, and colorization. These transformations are cached, so they are only applied once per image.
The Scene
class provides a build
method that allows for creating tile-based scenes from a map. This is useful for creating levels in platformers, RPGs, and other genres that use tile-based graphics.
Human interaction is unified via abstractions, so that apps will just work, regardless of the devices in use.
Gamepads or keyboard. When using a keyboard, sensible defaults (minding accessibility) are used, as seen in KeyMap.mjs.
Mice or touch screen.
Internal geometry frees the app logic from displays, i.e. your app can have an internal logic resolution of 800x600, while running on any display size.
Core2D comes with a set of optional plugins that can be used to extend its functionality. These plugins are located in the src/plugin
directory and can be used by importing them into your project.
Scene.build
method.The core of the library (under src/
) should remain agnostic and lean. Updates to the core library are usually related to technology developments in the platform (web API advances), while staying true to the basic concepts of the library, which are common to all apps.
Opinionated functionality should be implemented in the form of a plugin (under src/plugin/
). Plugins can add features that are domain driven, such as elements that can be reused by multiple apps, but not necessarily by every app.
To contribute to Core2D, you’ll need to set up your development environment.
asdf install
npm install
.vscode/extensions.json
. When you open the project in VS Code, you should be prompted to install them. These extensions will help you with code formatting and linting..prettierrc.json
and eslint.config.js
files, respectively.
To format the code, run:
npm run format
To lint the code, run:
npm run lint
pre-commit
hook is configured to run npm test
before each commit. This ensures that all tests pass and the code is linted before it’s committed. After running npm install
, the hooks will be automatically configured.Apps created with Core2D: