Skip to content

Commit

Permalink
Merge pull request #2 from aidencompsci/main
Browse files Browse the repository at this point in the history
Adding Lerp speed to camera
  • Loading branch information
setanarut authored Aug 5, 2024
2 parents 21c7353 + e1fdcc9 commit 9ee2e51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# Dependency directories (remove the comment below to include it)
# vendor/

# IDE/Editor directories
.idea/*

# Go workspace file
go.work
examples/.DS_Store
Expand Down
6 changes: 4 additions & 2 deletions camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type Camera struct {
ZoomFactor float64

// Interpolate camera movement
Lerp bool
Lerp bool
LerpSpeed float64

// Camera shake options
ShakeOptions CameraShakeOptions
Expand All @@ -34,6 +35,7 @@ func NewCamera(lookAtX, lookAtY, w, h float64) *Camera {
c := &Camera{
ZoomFactor: 0,
Lerp: false,
LerpSpeed: 0.1,
ShakeOptions: DefaultCameraShakeOptions(),
// private
w: w,
Expand All @@ -59,7 +61,7 @@ func NewCamera(lookAtX, lookAtY, w, h float64) *Camera {
func (cam *Camera) LookAt(targetX, targetY float64) {
target := vec2{targetX, targetY}
if cam.Lerp {
cam.tempTarget = cam.tempTarget.Lerp(target, 0.1)
cam.tempTarget = cam.tempTarget.Lerp(target, cam.LerpSpeed)
cam.topLeft = cam.tempTarget
} else {
cam.topLeft = target
Expand Down

0 comments on commit 9ee2e51

Please sign in to comment.