steering

package module
v0.0.0-...-1343c39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2022 License: MIT Imports: 5 Imported by: 0

README

Go Steering

This library is intended to be a go implementation of OpenSteer. However this project doesn't work and is pretty much abandoned.

Copy the wasm_exec.js file to your project's directory cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .

Build the code and put it in main.wasm GOOS=js GOARCH=wasm go build -o main.wasm

Install goexec if needed

# install goexec: go get -u github.com/shurcooL/goexec

Run a webserver from the command line

$ goexec 'http.ListenAndServe(":8080", http.FileServer(http.Dir(".")))'

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	// contains filtered or unexported fields
}

func MakeBlock

func MakeBlock(pos Vector) *Block

func (*Block) Draw

func (b *Block) Draw(c *gg.Context)

func (*Block) MaxSpeed

func (v *Block) MaxSpeed() float32

func (*Block) Position

func (v *Block) Position() Vector

func (*Block) Radius

func (v *Block) Radius() float32

func (*Block) Update

func (b *Block) Update()

func (*Block) Velocity

func (v *Block) Velocity() Vector

type Entity

type Entity interface {
	Update()
	Draw(*gg.Context)
	Position() Vector
	Radius() float32
}

type Hunter

type Hunter struct {
	*Vehicle
	// contains filtered or unexported fields
}

func MakeHunter

func MakeHunter(q Quarry) *Hunter

func (*Hunter) Draw

func (h *Hunter) Draw(c *gg.Context)

func (*Hunter) Update

func (h *Hunter) Update()

type Level

type Level struct {
	Width    int
	Height   int
	Vehicles []Entity
	// contains filtered or unexported fields
}

func MakeLevel

func MakeLevel(width int, height int) *Level

func (*Level) Bounds

func (l *Level) Bounds() Vector

func (*Level) Draw

func (l *Level) Draw(c *gg.Context)

func (*Level) Update

func (l *Level) Update()

type Matrix

type Matrix []Vector

Column Major

func MakeMatrix

func MakeMatrix(row int, col int, data []float32) Matrix

func (Matrix) Determinant

func (m Matrix) Determinant() float32

func (Matrix) Mult

func (m Matrix) Mult(v Vector) Vector

type Object

type Object interface {
	Position() Vector
	Radius() float32
}

type Prey

type Prey struct {
	*Vehicle
	Sphere float32
	// contains filtered or unexported fields
}

func MakePrey

func MakePrey(l *Level) *Prey

func (*Prey) Draw

func (p *Prey) Draw(c *gg.Context)

func (*Prey) Update

func (p *Prey) Update()

type Quarry

type Quarry interface {
	Velocity() Vector
	Position() Vector
}

type Spawn

type Spawn struct {
	// contains filtered or unexported fields
}

func (*Spawn) Draw

func (s *Spawn) Draw(c *gg.Context)

func (*Spawn) Update

func (s *Spawn) Update()

type Steerer

type Steerer interface {
	Position() Vector
	Velocity() Vector
	MaxSpeed() float32
	Forward() Vector
	Side() Vector
	Up() Vector
	Radius() float32
}

type Vector

type Vector []float32

func Avoid

func Avoid(s Steerer, spheres []Entity, length float32) Vector

func Contain

func Contain(s Steerer, leftTopBack Vector, rightBottomFront Vector, futureUpdates float32, dimensions int) Vector

func Flee

func Flee(s Steerer, target Vector) Vector

func Pursuit

func Pursuit(s Steerer, q Quarry, futureUpdates float32) Vector

func Seek

func Seek(s Steerer, target Vector) Vector

func Wander

func Wander(s Steerer, sphere float32, orientation Matrix) Vector

func (Vector) Clone

func (v Vector) Clone() Vector

func (Vector) Cross

func (v Vector) Cross(w Vector) Vector

func (Vector) Distance

func (v Vector) Distance(other Vector) float32

func (Vector) DividedBy

func (v Vector) DividedBy(s float32) Vector

func (Vector) Dot

func (v Vector) Dot(other Vector) float32

func (Vector) Equals

func (v Vector) Equals(w Vector, epsilon float64) bool

func (Vector) Hadamard

func (v Vector) Hadamard(w Vector) Vector

func (Vector) Len

func (v Vector) Len() float32

func (Vector) Minus

func (v Vector) Minus(w Vector) Vector

func (Vector) Mult

func (v Vector) Mult(s float32) Vector

func (Vector) Normal

func (gradient Vector) Normal(point Vector, t float32) Vector

func (Vector) Normalize

func (v Vector) Normalize() Vector

func (Vector) Plus

func (v Vector) Plus(w Vector) Vector

func (Vector) Project

func (v Vector) Project(u Vector) float32

func (Vector) Trunc

func (v Vector) Trunc(limit float32) Vector

type Vehicle

type Vehicle struct {
	Mass float32

	MaxForce float32

	Orientation Matrix
	// contains filtered or unexported fields
}

func MakeVehicle

func MakeVehicle(pos Vector, mass, maxForce, maxSpeed, radius float32) *Vehicle

func (*Vehicle) Forward

func (v *Vehicle) Forward() Vector

func (*Vehicle) MaxSpeed

func (v *Vehicle) MaxSpeed() float32

func (*Vehicle) Move

func (v *Vehicle) Move(steering_direction Vector)

func (*Vehicle) Position

func (v *Vehicle) Position() Vector

func (*Vehicle) Radius

func (v *Vehicle) Radius() float32

func (*Vehicle) Side

func (v *Vehicle) Side() Vector

func (*Vehicle) Up

func (v *Vehicle) Up() Vector

func (*Vehicle) Velocity

func (v *Vehicle) Velocity() Vector

func (*Vehicle) X

func (v *Vehicle) X() float32

func (*Vehicle) Y

func (v *Vehicle) Y() float32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL