Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BOX = 1
View Source
var CIRCLE = 0
View Source
var DebugRenderer = sk.NewSystem(func(g *sk.Game) error { return nil }, TransformAndBodyQuery)
View Source
var MAX_BODY_SIZE float64 = 64 * 64
View Source
var MAX_DENSITY float64 = 24
View Source
var MIN_BODY_SIZE float64 = 0.01 * 0.01
View Source
var MIN_DENSITY float64 = 0.01
View Source
var PhysicsUpdater = sk.NewSystem(func(g *sk.Game) error { objs := TransformAndBodyQuery.Query() for i := 0; i < len(objs)-1; i++ { for j := i + 1; j < len(objs); j++ { a := objs[i] b := objs[j] ok, normal, depth := collideCircleCircle(a.Transform, b.Transform, a.RigidBody, b.RigidBody) if ok { hdepth := depth / 2 a.Transform.MoveBy(normal.X*hdepth, normal.Y*hdepth) b.Transform.MoveBy(-normal.X*hdepth, -normal.Y*hdepth) } } } return nil }, TransformAndBodyQuery)
View Source
var RigidBody = sk.NewComponentWithOptions(sk.ComponentOptions[DRigidBody]{ OnCreated: func(r *DRigidBody) { r.Mass = 1 r.Density = 1 r.Restitution = 0.5 r.Shape = CIRCLE r.Radius = 1 r.image = ebiten.NewImage(500, 500) }, })
View Source
var TransformAndBodyQuery = sk.NewQuery[struct { Transform *core.DTransform RigidBody *DRigidBody }]()
Functions ¶
This section is empty.
Types ¶
type DRigidBody ¶
type DRigidBody struct { LinearVelocity sk.Vec2 AngularVelocity float64 Mass float64 Density float64 Restitution float64 Area float64 Static bool // Temp Shape int // 0: Circle, 1: Box Radius float64 Width float64 Height float64 // contains filtered or unexported fields }
func (*DRigidBody) AsBox ¶
func (r *DRigidBody) AsBox(width, height, density, restitution float64, static bool)
Temp
func (*DRigidBody) AsCircle ¶
func (r *DRigidBody) AsCircle(radius, density, restitution float64, static bool)
Temp
func (*DRigidBody) GetBounds ¶
func (r *DRigidBody) GetBounds() sk.Rect
Click to show internal directories.
Click to hide internal directories.