oak

oakmoundApache-2.0活跃维护

纯 Go 编写的 2D 游戏引擎,自带 UI 与场景管理,让 Go 开发者不用引入 C 依赖就能做游戏。

A pure Go game engine

v4.1.1发布于 2024-10-08 00:36 UTC1,668star87fork同步于 2026-11-07 07:34 UTC

怎么上手

由 README 提炼,执行前请确认
go get -u github.com/oakmound/oak/v4
硬件要求按 README 说明

README 未说明具体硬件要求;仅说明默认配置下无需 C 编译器即可构建运行,但当前没有不含 Objective-C 代码的 OSX 方案。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

纯 Go 编写的 2D 游戏引擎,无需 C 编译器即可搭建游戏或 GUI 应用

纯 Go 编写的 2D 游戏引擎,自带 UI 与场景管理,让 Go 开发者不用引入 C 依赖就能做游戏。

核心能力

  • 基于 shiny 实现窗口管理与多窗口并行
  • 提供 Sprite、Sequence、Composite 等内置渲染类型
  • 内置粒子系统与 2D 物理系统
  • 用 R-Tree 做碰撞检测并支持 2D 射线投射
  • 统一事件处理器与鼠标、手柄、音频支持

容易踩的坑

README 说明已引入含 C 代码的依赖,虽默认无需 C 编译,但部分场景可能受影响;OSX 上目前没有不含 Objective-C 代码的方案;示例与扩展功能分散在 examples 和 grove 仓库,需另行查看。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v4.1.1
  1. v4.1.1Oak v4.1.1最新正式版2024-10-08 · 2024-10-08 00:36 UTC

    This release:

    • Makes miscellaneous updates to dependencies
    • Adds an error return when you attempt to use indivisible arguments to sprite sheet creation
    • Removes a deprecation warning on OSX
    • Fixes usage of metadata on entities

    Full Changelog: https://github.com/oakmound/oak/compare/v4.1.0...v4.1.1

  2. v4.1.0Oak v4.1.02022-08-23 · 2022-08-23 00:30 UTC
    查看更新说明

    This release contains:

    • Better automated testing for JS compliation / builds
    • Improved support for child entities
    • Added floatgeom rect support for the span.Span interface
    • Added helpers to particles to enable working with specific draw stacks.

    Full Changelog: https://github.com/oakmound/oak/compare/v4.0.2...v4.1.0

  3. v4.0.2Oak v4.0.22022-06-11 · 2022-06-11 16:14 UTC
    查看更新说明
    • This release fixes a bug where the Height() method on a font would not return the default font height for those generated from default settings.

    What's Changed

    Full Changelog: https://github.com/oakmound/oak/compare/v4.0.1...v4.0.2

  4. v4.0.1Oak v4.0.12022-06-05 · 2022-06-05 17:25 UTC
    查看更新说明
    • This release fixes a bug where event bindings that returned event.ResponseUnbindThisBinding were not unbound.

    What's Changed

    Full Changelog: https://github.com/oakmound/oak/compare/v4.0.0...v4.0.1

  5. v4.0.0Oak v4.0.02022-05-21 · 2022-05-21 16:34 UTC
    查看更新说明

    High level changelog:

    Overall

    • Bump from Go 1.17 to 1.18
    • Operations that would previously fail on an oak window because they were not supported on a specific OS will now fail at compile time instead.
    • Windows, Linux, and OSX have had their window functionality standardized.
    • Examples have been trimmed down and compressed.

    Testing

    • Added Linux AMD64 and Windows AMD64 automated test agents

    Alg Package

    • alg/range has been replaced by alg/span, a genericized version of the package.
    • Intgeom rectangles now implement the alg/span interface. In other words, rectangles can be queried for arbitrary points within them and have points clamped to their boundaries.

    Audio Package

    • The audio and pcm packages have been rewritten from scratch.
    • A program can now select a specific audio driver for a platform. There are minimal options currently, but this can be extended in the future.
    • The pcm package now defines the audio interface in a streamable fashion, and audio defines options for playing back pcm streams.
    • Some functionality has been removed with no current replacement, e.g. Ears, positional filters. They can be re-added in the future.
    • Streaming enables new functionality like FadeIn and FadeOut stream wrappers.
    • Audio format packages can now be compiled in at request instead of always compiled into programs. This should decrease binary sizes of most programs, particularly those not using audio or only using one format.
    • The synth package has additional functionality for manipulating generated waveforms like detuning, combining waveforms, and detecting a waveform's pitch.

    Entities Package

    • This package has been rewritten from scratch to use optional constructors instead of a series of scaling types with additional functionality. entities/x/move has been moved to entities itself.
    • entities/x/btn has been trimmed down to use entities internally instead of its own structures.
    • entities/x/force and entities/x/stat have been removed.
    • entities/x/shake has been promoted to oak/shake.

    Event Handling

    • Event handling has been augmented to support type safe argument handling via generics.
    • The interface for binding and unbinding events, and the internal logic for processing requests, has been overhauled.
    • Example: previously to unbind a specific known binding in collision.Detach, we did this:
    if _, ok := en.(attachSpace); ok { 
    event.UnbindBindable(
    	event.UnbindOption{
    		Event: event.Event{
    			Name:     event.Enter,
    			CallerID: s.CID,
    		},
    		Fn: attachSpaceEnter,
    	},
    )
    }
    

    Now, bindings return a value that can be explicitly used to unbind themselves later:

    if as, ok := en.(attachSpace); ok {
        as.getAttachSpace().binding.Unbind()
    }
    
    • These rewrites eliminate the need for oak.Config.EventRefreshRate.

    Render

    • The build tag nogift can be added to exclude the disintegration/gift dependency and its helper functions.
    • The build tag noimages can be added to exclude registering the standard library's built in image support.

    Scene Handling

    • Scenes no longer have a Loop function. For operations that should happen every frame, the event package is preferred, with helpers like scene.Context.DoEachFrame added. scene.Context.GoToScene and its like are preferred for handling when a scene ends.
    • Scene contexts embed most of their component constructs, and can be provided to the event and render packages as appropriate.

    Changelog by PRs:

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    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="https://raw.githubusercontent.com/oakmound/oak/HEAD/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.