Skip to content

Commit

Permalink
Merge pull request #207 from oakmound/release/v4.0.0
Browse files Browse the repository at this point in the history
Release/v4.0.0
  • Loading branch information
200sc committed May 21, 2022
2 parents ece3195 + e4df7da commit a75e0d2
Show file tree
Hide file tree
Showing 583 changed files with 8,078 additions and 17,274 deletions.
55 changes: 49 additions & 6 deletions .github/workflows/go.yml
@@ -1,15 +1,58 @@
name: Go
on: [push]
jobs:
test-arm:
name: Test (arm)
test-windows-x64:
name: Test (windows amd64)
runs-on: [self-hosted, windows, x64]
steps:

- name: Set up Go 1.18
uses: actions/setup-go@v1
with:
go-version: 1.18
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: ./test_examples.sh
shell: bash

test-linux-arm:
name: Test (linux arm)
runs-on: [self-hosted, linux, ARM64]
steps:

- name: Set up Go 1.17
- name: Set up Go 1.18
uses: actions/setup-go@v1
with:
go-version: 1.18
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: ./test_examples.sh

test-linux-x64:
name: Test (linux x64)
runs-on: [self-hosted, linux, x64]
steps:

- name: Set up Go 1.18
uses: actions/setup-go@v1
with:
go-version: 1.17
go-version: 1.18
id: go

- name: Check out code into the Go module directory
Expand All @@ -27,10 +70,10 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.17
- name: Set up Go 1.18
uses: actions/setup-go@v1
with:
go-version: 1.17
go-version: 1.18
id: go

- name: Check out code into the Go module directory
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -14,4 +14,7 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

coverage.txt
coverage.txt

# Workspace configuration
.vscode
47 changes: 24 additions & 23 deletions README.md
Expand Up @@ -2,8 +2,8 @@

## A Pure Go game engine

[![Go Reference](https://pkg.go.dev/badge/github.com/oakmound/oak/v3.svg)](https://pkg.go.dev/github.com/oakmound/oak/v3)
[![Code Coverage](https://codecov.io/gh/oakmound/oak/branch/develop/graph/badge.svg)](https://codecov.io/gh/oakmound/oak)
[![Go Reference](https://pkg.go.dev/badge/github.com/oakmound/oak/v4.svg)](https://pkg.go.dev/github.com/oakmound/oak/v4)
[![Code Coverage](https://codecov.io/gh/oakmound/oak/branch/master/graph/badge.svg)](https://codecov.io/gh/oakmound/oak)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go)

## Table of Contents
Expand All @@ -24,14 +24,14 @@

## Installation <a name="installation"/>

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

## Features and Systems <a name="features"></a>

1. Window Management
- Windows and key events forked from [shiny](https://pkg.go.dev/golang.org/x/exp/shiny)
- Support for multiple windows running at the same time
1. [Image Rendering](https://pkg.go.dev/github.com/oakmound/oak/v3/render)
1. [Image Rendering](https://pkg.go.dev/github.com/oakmound/oak/v4/render)
- Manipulation
- `render.Modifiable` interface
- Integrated with optimized image manipulation via [gift](https://github.com/disintegration/gift)
Expand All @@ -40,22 +40,22 @@
- Primitive builders, `ColorBox`, `Line`, `Bezier`
- History-tracking `Reverting`
- Primarily 2D
1. [Particle System](https://pkg.go.dev/github.com/oakmound/oak/v3/render/particle)
1. [Mouse Handling](https://pkg.go.dev/github.com/oakmound/oak/v3/mouse)
1. [Joystick Support](https://pkg.go.dev/github.com/oakmound/oak/v3/joystick)
1. [Audio Support](https://pkg.go.dev/github.com/oakmound/oak/v3/audio)
1. [Collision](https://pkg.go.dev/github.com/oakmound/oak/v3/collision)
1. [Particle System](https://pkg.go.dev/github.com/oakmound/oak/v4/render/particle)
1. [Mouse Handling](https://pkg.go.dev/github.com/oakmound/oak/v4/mouse)
1. [Joystick Support](https://pkg.go.dev/github.com/oakmound/oak/v4/joystick)
1. [Audio Support](https://pkg.go.dev/github.com/oakmound/oak/v4/audio)
1. [Collision](https://pkg.go.dev/github.com/oakmound/oak/v4/collision)
- Collision R-Tree forked from [rtreego](https://github.com/dhconnelly/rtreego)
- [2D Raycasting](https://pkg.go.dev/github.com/oakmound/oak/v3/collision/ray)
- [2D Raycasting](https://pkg.go.dev/github.com/oakmound/oak/v4/collision/ray)
- Collision Spaces
- Attachable to Objects
- Auto React to collisions through events
1. [2D Physics System](https://pkg.go.dev/github.com/oakmound/oak/v3/physics)
1. [Event Handler](https://pkg.go.dev/github.com/oakmound/oak/v3/event)
1. [2D Physics System](https://pkg.go.dev/github.com/oakmound/oak/v4/physics)
1. [Event Handler](https://pkg.go.dev/github.com/oakmound/oak/v4/event)

## Support <a name="support"></a>

For discussions not significant enough to be an Issue or PR, feel free to ping us in the #oak channel on the [gophers slack](https://invite.slack.golangbridge.org/).
For discussions not significant enough to be an Issue or PR, feel free to ping us in the #oak channel on the [gophers slack](https://invite.slack.golangbridge.org/). For insight into what is happening in oak see the [blog](https://200sc.dev/).

## Quick Start <a name="quick-start"></a>

Expand All @@ -65,8 +65,8 @@ This is an example of the most basic oak program:
package main

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

func main() {
Expand All @@ -79,27 +79,28 @@ func main() {
}
```

See below or the [examples](examples) folder for longer demos, [godoc](https://pkg.go.dev/github.com/oakmound/oak/v3) for reference documentation, and the [wiki](https://github.com/oakmound/oak/wiki) for more guided tutorials and walkthroughs.
See below or navigate to the [examples](examples) folder for demos. For more examples and documentation checkout [godoc](https://pkg.go.dev/github.com/oakmound/oak/v4) for reference documentation, the [wiki](https://github.com/oakmound/oak/wiki), or our extended features in [grove](https://github.com/oakmound/grove).

## Examples <a name="examples"></a>

| | | |
|:-------------------------:|:-------------------------:|:-------------------------:|
|<img width="1400" src="examples/platformer-tutorial/6-complete/example.gif" a=examples/platformer-tutorial> [Platformer](examples/platformer-tutorial) | <img width="1400" src="examples/top-down-shooter-tutorial/6-performance/example.gif"> [Top down shooter](examples/top-down-shooter-tutorial)|<img width="1400" src="examples/radar-demo/example.gif"> [Radar](examples/radar-demo) |
|<img width="1400" src="examples/slide/example.gif"> [Slideshow](examples/slide) | <img width="1400" src="examples/bezier/example.PNG"> [Bezier Curves](examples/bezier) |<img width="1400" src="examples/joystick-viz/example.gif"> [Joysticks](examples/joystick-viz)|
|<img width="1400" src="examples/collision-demo/example.PNG"> [Collision Demo](examples/collision-demo) | <img width="1400" src="examples/custom-cursor/example.PNG"> [Custom Mouse Cursor](examples/custom-cursor) |<img width="1400" src="examples/fallback-font/example.PNG"> [Fallback Fonts](examples/fallback-font)|
|<img width="1400" src="examples/screenopts/example.PNG"> [Screen Options](examples/screenopts) | <img width="1400" src="examples/multi-window/example.PNG"> [Multi Window](examples/multi-window) |<img width="1400" src="examples/particle-demo/overviewExample.gif"> [Particle Demo](examples/particle-demo)|
|<img width="1400" src="examples/platformer/example.gif" a=examples/platformer> [Platformer](examples/platformer) | <img width="1400" src="examples/top-down-shooter//example.gif"> [Top down shooter](examples/top-down-shooter)|<img width="1400" src="examples/flappy-bird//example.gif"> [Flappy Bird](examples/flappy-bird/)
| <img width="1400" src="examples/bezier/example.PNG"> [Bezier Curves](examples/bezier) |<img width="1400" src="examples/joystick-viz/example.gif"> [Joysticks](examples/joystick-viz)|<img width="1400" src="examples/piano/example.gif"> [Piano](examples/piano)|
|<img width="1400" src="examples/screenopts/example.PNG"> [Screen Options](examples/screenopts) | <img width="1400" src="examples/multi-window/example.PNG"> [Multi Window](examples/multi-window) |<img width="1400" src="examples/particle-demo/overviewExample.gif"> [Particles](examples/particle-demo)|

## Games using Oak <a name="finished-games"/>
## Games using Oak <a name="finished-games"></a>

To kick off a larger game project you can get started with [game-template](https://github.com/oakmound/game-template).

| | |
|:-------------------------:|:-------------------------:|
|<img width="1400" src="https://img.itch.zone/aW1hZ2UvMTk4MjIxLzkyNzUyOC5wbmc=/original/aRusLc.png" a=examples/platformer-tutorial> [Agent Blue](https://oakmound.itch.io/agent-blue) | <img width="1400" src="https://img.itch.zone/aW1hZ2UvMTY4NDk1Lzc4MDk1Mi5wbmc=/original/hIjzFm.png"> [Fantastic Doctor](https://github.com/oakmound/lowrez17)
|<img width="1400" src="https://img.itch.zone/aW1hZ2UvMzkwNjM5LzI2NzU0ODMucG5n/original/eaoFrd.png"> [Hiring Now: Looters](https://oakmound.itch.io/cheststacker) | <img width="1400" src="https://img.itch.zone/aW1hZ2UvMTYzNjgyLzc1NDkxOS5wbmc=/original/%2BwvZ7j.png"> [Jeremy The Clam](https://github.com/200sc/jeremy)
|<img width="1400" src="https://img.itch.zone/aW1hZ2UvOTE0MjYzLzUxNjg3NDEucG5n/original/5btfEr.png"> [Diamond Deck Championship](https://oakmound.itch.io/diamond-deck-championship) |
|<img width="1400" src="https://img.itch.zone/aW1hZ2UvOTE0MjYzLzUxNjg3NDEucG5n/original/5btfEr.png"> [Diamond Deck Championship](https://oakmound.itch.io/diamond-deck-championship) | <img width="1400" src="https://img.itch.zone/aW1nLzgzMDM5MjcucG5n/105x83%23/oA19CL.png"> [SokoPic](https://oakmound.itch.io/sokopic)

## On Pure Go <a name="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 scenarios, and currently we have no OSX solution that lacks objective C code.
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.
2 changes: 1 addition & 1 deletion alg/floatgeom/point.go
Expand Up @@ -3,7 +3,7 @@ package floatgeom
import (
"math"

"github.com/oakmound/oak/v3/alg"
"github.com/oakmound/oak/v4/alg"
)

// Point2 represents a 2D point on a plane.
Expand Down
2 changes: 1 addition & 1 deletion alg/floatgeom/point_test.go
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/oakmound/oak/v3/alg"
"github.com/oakmound/oak/v4/alg"
)

func Seed() {
Expand Down
2 changes: 1 addition & 1 deletion alg/floatgeom/polygon.go
@@ -1,7 +1,7 @@
package floatgeom

import (
"github.com/oakmound/oak/v3/alg"
"github.com/oakmound/oak/v4/alg"
)

// A Polygon2 is a series of points in 2D space.
Expand Down
2 changes: 1 addition & 1 deletion alg/intgeom/point.go
Expand Up @@ -3,7 +3,7 @@ package intgeom
import (
"math"

"github.com/oakmound/oak/v3/alg"
"github.com/oakmound/oak/v4/alg"
)

// Point2 represents a 2D point in space.
Expand Down
2 changes: 1 addition & 1 deletion alg/intgeom/point_test.go
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/oakmound/oak/v3/alg"
"github.com/oakmound/oak/v4/alg"
)

func Seed() {
Expand Down
96 changes: 96 additions & 0 deletions alg/intgeom/rect.go
@@ -1,5 +1,11 @@
package intgeom

import (
"math/rand"

"github.com/oakmound/oak/v4/alg/span"
)

// A Rect2 represents a span from one point in 2D space to another.
// If Min is less than max on any axis, it will return undefined results
// for methods.
Expand Down Expand Up @@ -326,3 +332,93 @@ func (r Rect2) Intersects(r2 Rect2) bool {
return !((r2.Max.X() <= r.Min.X() || r.Max.X() <= r2.Min.X()) ||
(r2.Max.Y() <= r.Min.Y() || r.Max.Y() <= r2.Min.Y()))
}

// MulConst multiplies the boundary points of this rectangle by i.
func (r Rect2) MulConst(i int) Rect2 {
return Rect2{
r.Min.MulConst(i),
r.Max.MulConst(i),
}
}

// Poll returns a pseudorandom point from within this rectangle
func (r Rect2) Poll() Point2 {
return Point2{
r.Min.X() + int(rand.Float64()*float64(r.W())),
r.Min.Y() + int(rand.Float64()*float64(r.H())),
}
}

// Clamp returns a version of the provided point such that it is contained within r. If it was already contained in
// r, it will not be changed.
func (r Rect2) Clamp(pt Point2) Point2 {
for i := 0; i < r.MaxDimensions(); i++ {
if pt[i] < r.Min[i] {
pt[i] = r.Min[i]
} else if pt[i] > r.Max[i] {
pt[i] = r.Max[i]
}
}
return pt
}

// Percentile returns a point within this rectangle along the vector from the top left to the bottom right of the
// rectangle, where for example, 0.0 will be r.Min, 1.0 will be r.Max, and 2.0 will be project the vector beyond r
// and return r.Min + {r.W()*2, r.H()*2}
func (r Rect2) Percentile(f float64) Point2 {
return Point2{
r.Min.X() + int(f*float64(r.W())),
r.Min.Y() + int(f*float64(r.H())),
}
}

// MulSpan returns this rectangle as a Point2 Span after multiplying the boundary points of the rectangle by f.
func (r Rect2) MulSpan(f float64) span.Span[Point2] {
return r.MulConst(int(f))
}

// MulConst multiplies the boundary points of this rectangle by i.
func (r Rect3) MulConst(i int) Rect3 {
return Rect3{
r.Min.MulConst(i),
r.Max.MulConst(i),
}
}

// Poll returns a pseudorandom point from within this rectangle
func (r Rect3) Poll() Point3 {
return Point3{
r.Min.X() + int(rand.Float64()*float64(r.W())),
r.Min.Y() + int(rand.Float64()*float64(r.H())),
r.Min.Z() + int(rand.Float64()*float64(r.D())),
}
}

// Clamp returns a version of the provided point such that it is contained within r. If it was already contained in
// r, it will not be changed.
func (r Rect3) Clamp(pt Point3) Point3 {
for i := 0; i < r.MaxDimensions(); i++ {
if pt[i] < r.Min[i] {
pt[i] = r.Min[i]
} else if pt[i] > r.Max[i] {
pt[i] = r.Max[i]
}
}
return pt
}

// Percentile returns a point within this rectangle along the vector from the top left to the bottom right of the
// rectangle, where for example, 0.0 will be r.Min, 1.0 will be r.Max, and 2.0 will be project the vector beyond r
// and return r.Min + {r.W()*2, r.H()*2, r.D()*2}
func (r Rect3) Percentile(f float64) Point3 {
return Point3{
r.Min.X() + int(f*float64(r.W())),
r.Min.Y() + int(f*float64(r.H())),
r.Min.Z() + int(f*float64(r.D())),
}
}

// MulConst multiplies the boundary points of this rectangle by i.
func (r Rect3) MulSpan(f float64) span.Span[Point3] {
return r.MulConst(int(f))
}

0 comments on commit a75e0d2

Please sign in to comment.