Skip to content

setanarut/kamera

Repository files navigation

GoDoc

Kamera

Camera package for Ebitengine.

import "github.com/setanarut/kamera/v2"

Features

  • Camera shake effect with fastnoise library noise types.
  • Smooth camera movement with three interpolation modes:
    • None: Direct camera movement without smoothing
    • Lerp: Linear interpolation for smooth transitions
    • SmoothDamp: Spring-like motion with acceleration and deceleration and maximum speed.
  • Rotate/Zoom

Usage

A pseudo code:

func (g *Game) Update() error {
  g.MainCamera.LookAt(player.X, player.Y)
  // Apply all world-space `playerDrawImageOptions.GeoM{}` transform here
 }
func (g *Game) Draw(screen *ebiten.Image) {
  g.MainCamera.Draw(playerImage, playerDrawImageOptions, screen)
 }

Examples

Platformer

Run platformer example on your local machine

go run github.com/setanarut/kamera/v2/examples/platformer@latest

Director

Run director example on your local machine

go run github.com/setanarut/kamera/v2/examples/director@latest