onut. A little framework to make games in C++ or JavaScript
Commonly called "onut". Game engine focused on rapid development. Aimed at Game Jams.
var texture = getTexture("image.png");
function render() {
// Begin a batch
SpriteBatch.begin();
// Draw a sprite at screen coordinates x=200, y=100 from top left corner.
SpriteBatch.drawSprite(texture, new Vector2(200, 100));
// End and flush the batch
SpriteBatch.end();
}
function update(dt) {
spriteAngle += dt * 45; // Will rotate 45 degree per second
}
function render() {
...
// Draw a sprite at with an animated angle
SpriteBatch.drawSprite(texture, new Vector2(200, 100), Color.WHITE, spriteAngle);
...
}
See onut/samplesJS/
folders for more detailed samples.
Ottawa Game Jam 2017 - Sheep Dog Heroes
Linux Game Jam 2017 - Retro Game War
Recommended to use Visual Studio Code.
[onut path]/jsconfig.json
, [onut path]/typings/onut.d.ts
to YourGame path.settings.txt
file. Refer to samples to see what can be put in there.main.js
will always be the last JavaScript file executed, use it to initialize stuff.function update(dt) {
// Update your game here
}
function render() {
}
Before you start. Please take note of the following folder structure. It is highly recommended for minimal setup time.
The default asset search paths are configured for this structure. But it easy to add more using oContentManager->addSearchPath
.
YourGame\
assets\
Put game assets in here
src\
Your game source code (.h and .cpp)Make sure to define those 6 functions. Otherwise you will get unresolved errors.
void initSettings()
{
// Set Default game settings can be set using oSettings.
}
void init()
{
// Load your content.
}
void shutdown()
{
// Cleanup.
}
void update()
{
// Game logic.
}
void render()
{
// Game render.
}
void postRender()
{
// Render more stuff after post process.
}
void renderUI()
{
// Draw imgui debug UI.
}
Look at samples to see what can be done here.
Sprite anims can be edited in Aseprite and exported as json. Certain flags can be set on frame's properties. Properties are colon ":
" separated.
i.e.: "loop:genfliph:next=idle
"
Frame properties and their meaning:
name | usage | scope | meaning |
---|---|---|---|
loop | loop |
tag | animation will be looped |
genfliph | genfliph |
tag | an extra animation will be created with the name tag+"_fliph", flipped horitontally |
genflipv | genflipv |
tag | an extra animation will be created with the name tag+"_fliph", flipped vertically |
next | next=tagName |
tag | when this animation is finished, it will trigger tagName |
origin | origin=x,y |
frame | set frame origin. This will apply to subsequent frames until the next origin. |
sound | sound=step.wav |
frame | plays a sound on this frame |
soundcue | soundcue=step.cue |
frame | plays a sound cue on this frame |
vol | vol=0.5 |
frame | set volume for sound [0, 1]. |
pan | pan=0.0 |
frame | set panning for sound [-1, 1]. |
pitch | pitch=2.0 |
frame | set pitch for sound. |
tags | tags=tag1,tag2 |
frame | Custom tags on this frame |
When exporting the sprite sheet in json format, make sure to change "Hash" to "Array".
Logo design by Pixilabs Software Inc.