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 core2dThe 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.
- BaseTile: A basic tile sprite that can be used with the
Scene.buildmethod. - ClickableSprite: A sprite that can be clicked or tapped.
- ControllableSprite: A sprite that can be controlled by a gamepad or keyboard.
- CursorSprite: A sprite that follows the pointer.
- Fog: A simple fog effect.
- FontSprite: A sprite that displays text using a custom font.
- JumperSprite: A sprite that can jump.
- RandomRectTransition: A transition that fills the screen with random rectangles.
- Starfield: A simple starfield effect.
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.
- Version Management:
This project uses asdf to manage the Node.js version. To install the correct version, run:
asdf install
- Install Dependencies:
npm install
- Recommended VS Code Extensions:
This project includes a list of recommended VS Code extensions in
.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. - Formatting and Linting:
This project uses Prettier for code formatting and ESLint for linting. The configuration for these tools is in the
.prettierrc.jsonandeslint.config.jsfiles, respectively. To format the code, run:To lint the code, run:npm run format
npm run lint
- Git Hooks:
This project uses husky to manage Git hooks. A
pre-commithook is configured to runnpm testbefore each commit. This ensures that all tests pass and the code is linted before it's committed. After runningnpm install, the hooks will be automatically configured.
Apps created with Core2D:
- Asteroids Remake (source)
- Cityscape - Single-player arcade survival game
- Cucurbita's Halloween
- Dragonfire (source)
- Missile Commander (source)
- Ms. Starship - Multi-player arcade shoot'em up
- Mythology - Single-player arcade pinball
- Raycaster (source)
- Starship - Single-player arcade shoot'em up
- Super Breakout Bros. (source)
- Tower Defense (source)


