Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

onut. A little framework to make games in C++ or JavaScript

License

NotificationsYou must be signed in to change notification settings

Daivuk/onut

Repository files navigation

Logo

Oak Nut engine.

Commonly called "onut". Game engine focused on rapid development. Aimed at Game Jams.

Quick javascript sample

Load image and draw a sprite

vartexture=getTexture("image.png");functionrender(){// Begin a batchSpriteBatch.begin();// Draw a sprite at screen coordinates x=200, y=100 from top left corner.SpriteBatch.drawSprite(texture,newVector2(200,100));// End and flush the batchSpriteBatch.end();}

Update loop

functionupdate(dt){spriteAngle+=dt*45;// Will rotate 45 degree per second}functionrender(){    ...// Draw a sprite at with an animated angleSpriteBatch.drawSprite(texture,newVector2(200,100),Color.WHITE,spriteAngle);        ...}

Seeonut/samplesJS/ folders for more detailed samples.

Overview

List of projects using it:

Arctic Distress

Click to Repair

Eagle's Nest

Messenger Hacker

Retro Game War

Spy Satellite Showdown

Fire Whisperers

Cannon Fodder Commander

Release history

  • Onut 4.0 - The 3D release -TBD
  • Onut 3.0 - The JavaScript release - Jul 14, 2017
  • Onut 2.0 - The Cleanup release - Apr 3, 2016
  • Onut 1.0 - Feb 6, 2016

JavaScript Game

Compile the executable

  1. Clone onut somewhere on your PC.
  2. Generate using cmake.
  3. Build the JSStandAlone project in release.
  4. Copy the executable to your game's folder.

Setting up your JavaScript project

Recommended to use Visual Studio Code.

  1. Create a folder for your game somehere on your PC
  2. Copy[onut path]/jsconfig.json,[onut path]/typings/onut.d.ts to YourGame path.
  3. Create asettings.txt file. Refer to samples to see what can be put in there.
  4. Create assets and javascript files
  5. main.js will always be the last JavaScript file executed, use it to initialize stuff.

main.js

functionupdate(dt){// Update your game here}functionrender(){}

C++ game

Recommended folder structure

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 usingoContentManager->addSearchPath.

  • YourGame\
    • assets\ Put game assets in here
      • ...
    • src\ Your game source code (.h and .cpp)
    • .. projects files or your CMakeLists.txt

main.cpp

Make sure to define those 6 functions. Otherwise you will get unresolved errors.

voidinitSettings(){// Set Default game settings can be set using oSettings.}voidinit(){// Load your content.}voidshutdown(){// Cleanup.}voidupdate(){// Game logic.}voidrender(){// Game render.}voidpostRender(){// Render more stuff after post process.}voidrenderUI(){// Draw imgui debug UI.}

Look at samples to see what can be done here.

Specific usages

SpriteAnim

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"

Logo

Frame properties and their meaning:

nameusagescopemeaning
looplooptaganimation will be looped
genfliphgenfliphtagan extra animation will be created with the name tag+"_fliph", flipped horitontally
genflipvgenflipvtagan extra animation will be created with the name tag+"_fliph", flipped vertically
nextnext=tagNametagwhen this animation is finished, it will trigger tagName
originorigin=x,yframeset frame origin. This will apply to subsequent frames until the next origin.
soundsound=step.wavframeplays a sound on this frame
soundcuesoundcue=step.cueframeplays a sound cue on this frame
volvol=0.5frameset volume for sound [0, 1].
panpan=0.0frameset panning for sound [-1, 1].
pitchpitch=2.0frameset pitch for sound.
tagstags=tag1,tag2frameCustom tags on this frame

When exporting the sprite sheet in json format, make sure to change "Hash" to "Array".

Mentions

Logo design by Pixilabs Software Inc.


[8]ページ先頭

©2009-2025 Movatter.jp