go get -u github.com/oakmound/oak/v2/...
Or in GOPATH mode (not using go modules):
go get -u github.com/oakmound/oak/...
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.
- 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
- 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 casesSprite
,Sequence
,Switch
,Composite
- Primitive builders,
ColorBox
,Line
,Bezier
- History-tracking
Reverting
- Primarily 2D
- Particle System
- Mouse Handling
- Click Collision
- MouseEnter / MouseExit reaction events
- Drag Handling
- Joystick Support
- Audio Support
- Positional filters to pan and scale audio based on a listening position
- 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
- 2D Physics System
- Vectors
- Attachable to Objects / Renderables
- Friction
- Vectors
- Event Handler, Bus
- PubSub system:
event.CID
canBind(fn,eventName)
andTrigger(eventName)
events
- PubSub system:
- Shaping
- Convert shapes into:
- Containment checks
- Outlines
- 2D arrays
- Convert shapes into:
- Custom Console Commands
- Logging
- Swappable with custom implementations
- Default Implementation: 4 log levels, writes to file and stdout
For discussions not significant enough to be an Issue or PR, see the #oak channel on the gophers slack.
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.
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)
Learn to use the collision library and make short term shots that collide with the entites marked with collision labels.
Often times you might want to create a minimap or a radar for a game, check out this example for a barebones implementation
A different way to use the oak engine.