Giter Site home page Giter Site logo

oak's Introduction

Oak

A pure Go game engine

GoDoc Go Report Card Code Coverage Mentioned in Awesome Go

Table of Contents

  1. Installation

  2. Motivation

  3. Features

  4. Support

  5. Quick Start

  6. Implementation and Examples

  7. Finished Games


Installation

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

Or in GOPATH mode (not using go modules):

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

Motivation

The initial version of oak was made to support Oakmound Studio's game, Agent Blue, and was developed in parallel. Oak supports Windows with no dependencies and Linux with limited audio dependencies. We don't own a machine to check with, but hypothetically it supports OSX as well. We hope that users will be able to make great pure Go games with oak and welcome improvements.

Because Oak wants to have as few non-Go dependencies as possible, Oak does not use OpenGL or GLFW. We're open to adding support for these in the future for performance gains, but we always want an alternative that requires zero or near-zero dependencies.

Features

  1. Window Rendering
    • Windows and key events forked from shiny
    • Logical frame rate distinct from Draw rate
    • Fullscreen, Window Positioning support
    • Auto-scaling for screen size changes
  2. Image Management
    • render.Renderable interface
    • Sprite Sheet Batch Loading at startup
    • Manipulation
      • render.Modifiable interface
      • Built in Transformations and Filters
      • Some built-ins via gift
      • Extensible Modification syntax func(image.Image) *image.RGBA
    • 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
    • Click to see gif captured in examples/particle-demo

      particles!

  4. Mouse Handling
    • Click Collision
    • MouseEnter / MouseExit reaction events
    • Drag Handling
  5. Joystick Support
    • Click to see gif captured in examples/joystick-viz

      particles!

  6. Audio Support
    • Positional filters to pan and scale audio based on a listening position
  7. Collision
    • Collision R-Tree forked from rtreego
    • 2D Raycasting
    • Collision Spaces
      • Attachable to Objects
      • Auto React to collisions through events
      • OnHit bindings func(s1,s2 *collision.Space)
      • Start/Stop collision with targeted objects
  8. 2D Physics System
    • Vectors
      • Attachable to Objects / Renderables
      • Friction
  9. Event Handler, Bus
    • PubSub system: event.CID can Bind(fn,eventName) and Trigger(eventName) events
  10. Shaping
    • Convert shapes into:
      • Containment checks
      • Outlines
      • 2D arrays
  11. Custom Console Commands
  12. Logging
    • Swappable with custom implementations
    • Default Implementation: 4 log levels, writes to file and stdout

Support

For discussions not significant enough to be an Issue or PR, see the #oak channel on the gophers slack.

Quick Start

This is an example of the most basic oak program:

oak.Add("firstScene",
    // Initialization function
    func(prevScene string, inData interface{}) {}, 
    // Loop to continue or stop the current scene
    func() bool {return true}, 
    // Exit to transition to the next scene
    func() (nextScene string, result *scene.Result) {return "firstScene", nil}) 
oak.Init("firstScene")

See the examples folder for longer demos, godoc for reference documentation, and the wiki for more guided feature sets, tutorials and walkthroughs.

Implementation and Examples

Platformer

Platformer

Build up to having a simple platforming game by doing the following: Setup a character, get it to move, set basic gravity, get it to jump, make it only jump on solid ground, put it all together.

char := entities.NewMoving(100, 100, 16, 32,
	render.NewColorBox(16, 32, color.RGBA{255, 0, 0, 255}),
nil, 0, 0)
char.Bind(func(id int, nothing interface{}) int {
	char := event.GetEntity(id).(*entities.Moving)

	// Move left and right with A and D
	if oak.IsDown(key.A) {
		char.Delta.SetX(-char.Speed.X())
	} else if oak.IsDown(key.D) {
		char.Delta.SetX(char.Speed.X())
	} else {
		char.Delta.SetX(0)
	}
	oldX, oldY := char.GetPos()
    char.ShiftPos(char.Delta.X(), char.Delta.Y())
	return 0
}, event.Enter)

Top Down Shooter

Learn to use the collision library and make short term shots that collide with the entites marked with collision labels.

Shoota

Radar

Often times you might want to create a minimap or a radar for a game, check out this example for a barebones implementation

Radar

Slideshow

A different way to use the oak engine.

Slideshow

Examples of Finished Games

Agent Blue

AgentBlue

Fantastic Doctor

Fantastic Overview

Fantastic Overview 2

Jeremy The Clam

Clammy

oak's People

Contributors

200sc avatar draoncc avatar hectorprats avatar implausiblyfun avatar lolbinarycat avatar mefellows avatar xdk78 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.