box2d

package
v0.0.0-...-28575ab Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 16 Imported by: 0

README

Arche Demo -- Box2D

A simulation using the Go port of Box2D, a 2D physics engine for games.

Here, Arche only handles the graphics and applies forces from the mouse.

See the live demo for this example.

Documentation

Overview

Package box2d demonstrates the use of the Go port of Box2D, a 2D physics engine for games.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run()

Types

type Body

type Body struct {
	Body   *box2d.B2Body
	Radius float64
}

Body component

type BoxWorld

type BoxWorld struct {
	World *box2d.B2World
}

BoxWorld resource

type Images

type Images struct {
	Circle *image.RGBA
}

Images resource, containing images for use in drawing Box2D bodies.

func NewImages

func NewImages() (Images, error)

NewImages creates a new Images resource.

type SysB2Physics

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

SysB2Physics is a simple system that updates the Box2D world to perform a physics step.

func (*SysB2Physics) Finalize

func (s *SysB2Physics) Finalize(world *ecs.World)

Finalize the system

func (*SysB2Physics) Initialize

func (s *SysB2Physics) Initialize(world *ecs.World)

Initialize the system

func (*SysB2Physics) Update

func (s *SysB2Physics) Update(world *ecs.World)

Update the system

type SysInitEntities

type SysInitEntities struct {
	Count       int
	Restitution float64
}

SysInitEntities is a system to create Box2D bodies and associated ECS entities.

func (*SysInitEntities) Finalize

func (s *SysInitEntities) Finalize(world *ecs.World)

Finalize the system

func (*SysInitEntities) Initialize

func (s *SysInitEntities) Initialize(world *ecs.World)

Initialize the system

func (*SysInitEntities) Update

func (s *SysInitEntities) Update(world *ecs.World)

Update the system

type SysPhysics

type SysPhysics struct {
	MinFleeDistance float64
	MaxFleeDistance float64
	ForceScale      float64
	// contains filtered or unexported fields
}

SysPhysics is a system that applies an impulse to all Box2D bodies that are within a certain distance to the mouse.

func (*SysPhysics) Finalize

func (s *SysPhysics) Finalize(world *ecs.World)

Finalize the system

func (*SysPhysics) Initialize

func (s *SysPhysics) Initialize(world *ecs.World)

Initialize the system

func (*SysPhysics) Update

func (s *SysPhysics) Update(world *ecs.World)

Update the system

type UISysDrawEntities

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

UISysDrawEntities is a system to draw Box2D bodies on an [Image] resource.

func (*UISysDrawEntities) FinalizeUI

func (s *UISysDrawEntities) FinalizeUI(world *ecs.World)

FinalizeUI the system

func (*UISysDrawEntities) InitializeUI

func (s *UISysDrawEntities) InitializeUI(world *ecs.World)

InitializeUI the system

func (*UISysDrawEntities) PostUpdateUI

func (s *UISysDrawEntities) PostUpdateUI(world *ecs.World)

PostUpdateUI the system

func (*UISysDrawEntities) UpdateUI

func (s *UISysDrawEntities) UpdateUI(world *ecs.World)

UpdateUI the system

type UISysManagePause

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

UISysManagePause is a simple system that transfers the pause state from the common.PauseMouseListener resource to the model's model.Systems.

func (*UISysManagePause) FinalizeUI

func (s *UISysManagePause) FinalizeUI(world *ecs.World)

FinalizeUI the system

func (*UISysManagePause) InitializeUI

func (s *UISysManagePause) InitializeUI(world *ecs.World)

InitializeUI the system

func (*UISysManagePause) PostUpdateUI

func (s *UISysManagePause) PostUpdateUI(world *ecs.World)

PostUpdateUI the system

func (*UISysManagePause) UpdateUI

func (s *UISysManagePause) UpdateUI(world *ecs.World)

UpdateUI the system

Jump to

Keyboard shortcuts

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