Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

setanarut/kamera

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc

Kamera

Camera package for Ebitengine.

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

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 {
  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(target.X, target.Y) // Move player
  MainCamera.Draw(playerImage, playerDrawImageOptions, screen)
 }

Examples

  1. Clone this repository
  2. In the terminal, change directory to the examples folder cd examples
  3. Run a demo with go run ./folder_name (go run ./platformer, go run ./director).

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.