Camera package for Ebitengine.
import "github.com/setanarut/kamera/v2"kamera_demo.mp4
- Camera shake effect with fastnoise library noise types.
- Smooth camera movement with three interpolation modes:
None: Direct camera movement without smoothingLerp: Linear interpolation for smooth transitionsSmoothDamp: Spring-like motion with acceleration and deceleration and maximum speed.
- Rotate/Zoom
A pseudo code:
func (g *Game) Update() error {
MainCamera.LookAt(playerCenter.X, playerCenter.Y)
return nil
}
func (g *Game) Draw(screen *ebiten.Image) {
playerDrawImageOptions.GeoM.Reset() // GeoM must be reset
playerDrawImageOptions.GeoM.Translate(playerTopLeft.X, playerTopLeft.Y) // Move player
MainCamera.Draw(playerImage, playerDrawImageOptions, screen)
}Run platformer example on your local machine
go run github.com/setanarut/kamera/v2/examples/platformer@latestRun director example on your local machine
go run github.com/setanarut/kamera/v2/examples/director@latestRun director_colorm example on your local machine
go run github.com/setanarut/kamera/v2/examples/director_colorm@latest