Categorygithub.com/oakmound/oak/v4
modulepackage
4.1.1
Repository: https://github.com/oakmound/oak.git
Documentation: pkg.go.dev

# README

Oak

A Pure Go game engine

Go Reference Code Coverage Mentioned in Awesome Go

Table of Contents

  1. Installation

  2. Features

  3. Support

  4. Quick Start

  5. Examples

  6. Finished Games


Installation

go get -u github.com/oakmound/oak/v4

Features and Systems

  1. Window Management
    • Windows and key events forked from shiny
    • Support for multiple windows running at the same time
  2. Image Rendering
    • Manipulation
      • render.Modifiable interface
      • Integrated with optimized image manipulation via gift
    • Built in Renderable types covering common use cases
      • Sprite, Sequence, Switch, Composite
      • Primitive builders, ColorBox, Line, Bezier
      • History-tracking Reverting
    • Primarily 2D
  3. Particle System
  4. Mouse Handling
  5. Joystick Support
  6. Audio Support
  7. Collision
    • Collision R-Tree forked from rtreego
    • 2D Raycasting
    • Collision Spaces
      • Attachable to Objects
      • Auto React to collisions through events
  8. 2D Physics System
  9. Event Handler

Support

For discussions not significant enough to be an Issue or PR, feel free to ping us in the #oak channel on the gophers slack. For insight into what is happening in oak see the blog.

Quick Start

This is an example of the most basic oak program:

package main

import (
    "github.com/oakmound/oak/v4"
    "github.com/oakmound/oak/v4/scene"
)

func main() {
    oak.AddScene("firstScene", scene.Scene{
        Start: func(*scene.Context) {
            // ... draw entities, bind callbacks ... 
        }, 
    })
    oak.Init("firstScene")
}

See below or navigate to the examples folder for demos. For more examples and documentation checkout godoc for reference documentation, the wiki, or our extended features in grove.

Examples

<img width="200" src="examples/platformer/example.gif" a=examples/platformer> Platformer Top down shooter Flappy Bird
Bezier Curves Joysticks Piano
Screen Options Multi Window Particles

Games using Oak

To kick off a larger game project you can get started with game-template.

<img width="200" src="https://img.itch.zone/aW1hZ2UvMTk4MjIxLzkyNzUyOC5wbmc=/original/aRusLc.png" a=examples/platformer-tutorial> Agent Blue Fantastic Doctor
Hiring Now: Looters Jeremy The Clam
Diamond Deck Championship SokoPic

On Pure Go

Oak has recently brought in dependencies that include C code, but we still describe the engine as a Pure Go engine, which at face value seems contradictory. Oak's goal is that, by default, a user can pull down the engine and create a fully functional game or GUI application on a machine with no C compiler installed, so when we say Pure Go we mean that, by default, the library is configured so no C compilation is required, and that no major features are locked behind C compliation.

We anticipate in the immediate future needing to introduce alternate drivers that include C dependencies for performance improvements in some scasenarios, and currently we have no OSX solution that lacks objective C code.

# Packages

Package alg provides algorithms and math utilities.
Package audio provides utilities for playing or writing audio streams to OS consumers.
Package collision provides collision tree and space structures along with hit detection functions on spaces.
Package debugstream provides an interface for custom debug commands to assist in program development.
Package debugtools provides structures to aid in development debugging of graphical programs.
Package dlog provides basic logging functions.
Package entities provides common entity constructor functions.
Package event provides structures to propagate event occurrences to subscribed system entities.
Package fileutil provides functionality to replace os and io calls with custom filesystems.
Package joystick provides utilities for querying and reacting to joystick or gamepad inputs.
Package key enumerates keystrings for use in bindings.
Package mouse handles the propagation of mouse events though clickable regions.
Package oakerr stores errors returned throughout oak.
Package physics provides vector types and trivial physics manipulation for them.
Package render provides structures for organizing graphics to draw to a window and essential graphical primitives.
Package scene provides definitions for interacting with game loop scenes.
Package shake provides methods for rapidly shifting graphical components' positions.
Package shape provides 2D shaping utilities.
Package shiny provides interfaces and drivers for instantiating and managing application windows.
Package timing provides utilities for time.
Package window provides a common interface for oak-created windows.

# Functions

AddScene calls AddScene on the default window.
Bounds returns the default window's boundary.
FileConfig loads a config file, that could exist inside oak's binary data storage (see fileutil), to SetupConfig.
GetCursorPosition calls GetCursorPosition on the default window.
HideCursor calls HideCursor on the default window.
Init calls Init on the default window.
IsDown calls IsDown on the default window.
IsHeld calls IsHeld on the default window.
MoveWindow calls MoveWindow on the default window.
NewConfig creates a config from a set of transformation options.
NewWindow creates a window with default settings.
ReaderConfig reads a Config as json from the given reader.
ScreenShot calls ScreenShot on the default window.
SetBackground calls SetBackground on the default window.
SetBorderless calls SetBorderless on the default window.
SetColorBackground calls SetColorBackground on the default window.
SetFS updates all calls oak or oak's subpackages will make to read from the given filesystem.
SetFullScreen calls SetFullScreen on the default window.
SetIcon calls SetIcon on the default window.
SetLoadingRenderable calls SetLoadingRenderable on the default window.
SetTitle calls SetTitle on the default window.
SetTopMost calls SetTopMost on the default window.
SetViewport calls SetViewport on the default window.
SetViewportBounds calls SetViewportBounds on the default window.
ShiftViewport calls ShiftViewport on the default window.
UpdateViewSize calls UpdateViewSize on the default window.

# Constants

The following constants define valid types of input sent via the InputChange event.
The following constants define valid types of input sent via the InputChange event.
The following constants define valid types of input sent via the InputChange event.
The following constants define valid types of input sent via the InputChange event.

# Variables

FocusGain is triggered when a window gains focus.
FocusLoss is triggered when a window loses focus.
InputChange is triggered when the most recent input device changes (e.g.
OnStop is triggered when the engine is stopped, e.g.
ViewportUpdate is triggered when the position of of the viewport changes.

# Structs

Assets is a json type storing paths to different asset folders.
BatchLoadOptions is a json type storing customizations for batch loading.
A Config defines the settings oak accepts on initialization.
Debug is a json type storing the starting debug filter and level.
Screen is a json type storing the starting screen width and height.

# Interfaces

A Background can be used as a background draw layer.

# Type aliases

A ConfigOption transforms a Config object.
A Driver is a function which can take in our lifecycle function and initialize oak with the OS interfaces it needs.
InputType expresses some form of input to the engine to represent a player.