ebitencm is Drawer for setanarut/cm Chipmunk physics space.
- Color theme customization for Fill and Stroke colors.
- Detailed drawing options.
drawer.GeoM{}
structure is provided for screen transformation. (Cameras)
First create a drawer
var drawer *ebitencm.Drawer = ebitencm.NewDrawer()
Then
func (g *Game) Draw(screen *ebiten.Image) {
drawer.DrawSpace(space, screen)
}
If you want to enable dragging, call the HandleMouseEvent()
function within the Update
method, passing the *cm.Space
object. This will allow objects to be dragged using a mouse or touch device.
func (g *Game) Update() error {
drawer.HandleMouseEvent(space)
Use Drawer.GeoM{}
for all vertices transform. The cursor position is calculated according to this matrix.
// move the all space objects 100 pixels to the left (move camera to right)
drawer.GeoM.Translate(-100, 0)
Here is an example with the setanarut/kamera package.
func (g *Game) Update() error {
g.space.Step(1 / 60.0)
g.cam.LookAt(x, y)
// Apply camera transform to drawer
g.drawer.GeoM.Reset()
g.cam.ApplyCameraTransform(g.drawer.GeoM)
// Enable cursor dragging
g.drawer.HandleMouseEvent(g.space)
Browse to the examples folder for all examples.