gifbounce

package
v0.0.0-...-5d2067b Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromImagePoint

func FromImagePoint(p *image.Point) box2d.Point

func FromImagePolygons

func FromImagePolygons(imagePolygons [][]image.Point) [][]box2d.Point

func FromImageRect

func FromImageRect(p *image.Rectangle) box2d.AABB

func ToImagePoint

func ToImagePoint(p *box2d.Point) image.Point

Types

type Params

type Params struct {
	NumFrames int
	Gravity   float64
	Worker    func(int, func(int), ...string)
	Things    struct {
		Dynamic []*ThingParams
		Static  []*ThingParams
		Walls   struct {
			Distance   float64
			Bounciness float64
			Friction   float64
			Left       bool
			Right      bool
			Top        bool
			Bottom     bool
		}
	}
	Solver struct {
		TimeStep           func(float64) float64
		VelocityIterations int
		PositionIterations int
	}
}

func (*Params) New

func (p *Params) New() *World

type Recording

type Recording struct {
	Active       []bool
	Frames       []int
	Angles       []float64
	WorldCenters []box2d.Point
	LocalCenters []box2d.Point
	Bounds       []box2d.AABB
}

func (*Recording) Len

func (r *Recording) Len() int

func (*Recording) PadRightTo

func (r *Recording) PadRightTo(k int)

func (*Recording) Record

func (r *Recording) Record(active bool, frame int, angleDeg float64, worldCenter, localCenter box2d.Point, aabb box2d.AABB)

func (*Recording) Slice

func (r *Recording) Slice(i, j int) Recording

type Thing

type Thing struct {
	*ThingParams
	Shape   *box2d.PolygonShape
	Fixture *box2d.Fixture
	Frame   int

	Static    bool
	Recording Recording
}

func (*Thing) LocalCenter

func (t *Thing) LocalCenter() box2d.Point

func (*Thing) Record

func (t *Thing) Record()

func (*Thing) SpawnDynamic

func (t *Thing) SpawnDynamic(w *World)

func (*Thing) SpawnStatic

func (t *Thing) SpawnStatic(w *World)

func (*Thing) Step

func (t *Thing) Step(time float64)

func (*Thing) WorldCenter

func (t *Thing) WorldCenter() box2d.Point

type ThingParams

type ThingParams struct {
	Images         []image.Image
	Polygons       [][]box2d.Point
	Bounciness     func(float64) float64
	LinearDamping  func(float64) float64
	AngularDamping func(float64) float64
	Friction       func(float64) float64
	Initial        struct {
		LinearVelocity     box2d.Point
		Position           box2d.Point
		Time               float64
		AngularVelocityDeg float64
	}
}

func (*ThingParams) New

func (p *ThingParams) New() *Thing

type World

type World struct {
	*Params
	Box2d  *box2d.World
	Things struct {
		Dynamic []*Thing
		Static  []*Thing
	}
}

func (*World) ContainsDynamicThings

func (w *World) ContainsDynamicThings(aabb box2d.AABB) bool

func (*World) SpawnWallH

func (w *World) SpawnWallH(distance float64)

func (*World) SpawnWallV

func (w *World) SpawnWallV(distance float64)

func (*World) Step

func (w *World) Step(t float64)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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