https://github.com/setanarut/kamera
Camera package for Ebitengine v2
https://github.com/setanarut/kamera
2d-camera camera-shake ebiten ebiten-game-library ebitengine go go-game-engine golang
Last synced: 6 months ago
JSON representation
Camera package for Ebitengine v2
- Host: GitHub
- URL: https://github.com/setanarut/kamera
- Owner: setanarut
- License: cc0-1.0
- Created: 2023-12-26T15:38:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-04T18:47:32.000Z (7 months ago)
- Last Synced: 2025-04-29T09:57:47.598Z (6 months ago)
- Topics: 2d-camera, camera-shake, ebiten, ebiten-game-library, ebitengine, go, go-game-engine, golang
- Language: Go
- Homepage:
- Size: 120 KB
- Stars: 20
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/setanarut/kamera/v2)
# Kamera
Camera package for Ebitengine.
```Go
import "github.com/setanarut/kamera/v2"
```## Features
- Camera shake effect with [fastnoise](https://github.com/setanarut/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:
```Go
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
```console
go run github.com/setanarut/kamera/v2/examples/platformer@latest
```### Director
Run director example on your local machine
```console
go run github.com/setanarut/kamera/v2/examples/director@latest
```