cpebiten

package module
v0.0.0-...-d55dbd8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 10 Imported by: 2

README

cp-ebiten

Physics examples in Ebiten using the Go Chipmunk2D port.

Click here to see a few in WASM form: http://www.jakecoffman.com/cp-ebiten/

building WASM

GOOS=js GOARCH=wasm go build -o tumble/tumble.wasm github.com/jakecoffman/tumble

Documentation

Index

Constants

View Source
const (
	ScreenHeight = 480
	ScreenWidth  = 600
)
View Source
const DrawPointLineScale = 1

Variables

View Source
var Grabbable = cp.ShapeFilter{
	cp.NO_GROUP, GrabbableMaskBit, GrabbableMaskBit,
}
View Source
var GrabbableMaskBit uint = 1 << 31
View Source
var NotGrabbable = cp.ShapeFilter{
	cp.NO_GROUP, ^GrabbableMaskBit, ^GrabbableMaskBit,
}

Functions

func AddBox

func AddBox(space *cp.Space, pos cp.Vector, mass, width, height float64) *cp.Shape

func AddCircle

func AddCircle(space *cp.Space, pos cp.Vector, mass, radius float64) *cp.Shape

func AddSegment

func AddSegment(space *cp.Space, pos cp.Vector, mass, width, height float64) *cp.Shape

func AddStaticBox

func AddStaticBox(space *cp.Space, pos cp.Vector, width, height float64) *cp.Shape

func AddWall

func AddWall(space *cp.Space, body *cp.Body, a, b cp.Vector, radius float64) *cp.Shape

Types

type DrawOptions

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

func NewDrawOptions

func NewDrawOptions(img *ebiten.Image) *DrawOptions

func (*DrawOptions) CollisionPointColor

func (o *DrawOptions) CollisionPointColor() cp.FColor

func (*DrawOptions) ConstraintColor

func (o *DrawOptions) ConstraintColor() cp.FColor

func (*DrawOptions) Data

func (o *DrawOptions) Data() interface{}

func (*DrawOptions) DrawBB

func (o *DrawOptions) DrawBB(bb cp.BB, outline cp.FColor)

func (*DrawOptions) DrawCircle

func (o *DrawOptions) DrawCircle(pos cp.Vector, angle, radius float64, outline, fill cp.FColor, _ interface{})

func (*DrawOptions) DrawDot

func (o *DrawOptions) DrawDot(size float64, pos cp.Vector, fill cp.FColor, _ interface{})

func (*DrawOptions) DrawFatSegment

func (o *DrawOptions) DrawFatSegment(a, b cp.Vector, radius float64, outline, fill cp.FColor, _ interface{})

func (*DrawOptions) DrawPolygon

func (o *DrawOptions) DrawPolygon(count int, verts []cp.Vector, radius float64, outline, fill cp.FColor, _ interface{})

func (*DrawOptions) DrawSegment

func (o *DrawOptions) DrawSegment(a, b cp.Vector, fill cp.FColor, data interface{})

func (*DrawOptions) Flags

func (o *DrawOptions) Flags() uint

func (*DrawOptions) Flush

func (o *DrawOptions) Flush()

func (*DrawOptions) OutlineColor

func (o *DrawOptions) OutlineColor() cp.FColor

func (*DrawOptions) ShapeColor

func (o *DrawOptions) ShapeColor(shape *cp.Shape, _ interface{}) cp.FColor

type Game

type Game struct {
	// Space holds all of the shapes and bodies
	Space *cp.Space

	// TicksPerSecond is the fixed physics tick rate. Set it higher if objects are going
	// through each other at the cost of higher CPU usage.
	TicksPerSecond float64

	// Accumulator shows the remaining time from the physics tick.
	Accumulator float64

	// FixedUpdate is an optional callback that is called when a fixed update occurs.
	FixedUpdate func()
	// contains filtered or unexported fields
}

Game is provided as a convenience for the examples since they all share similar logic.

func NewGame

func NewGame(space *cp.Space, ticksPerSecond float64) *Game

NewGame creates a new game.

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

func (*Game) Layout

func (g *Game) Layout(int, int) (int, int)

func (*Game) PhysicsTick

func (g *Game) PhysicsTick()

func (*Game) Update

func (g *Game) Update() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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