Skip to content

brotherhood-of-recursive-descent/go-ebiten-camera-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-ebiten-camera-demo

A detailed explanation on how to implement a 2d camera using the ebitenengine in the Golang language.

A basic game

Writing games is fun your friends tell you. So one day you sit down and start to write your first couple lines of code that resembles a game. Since Golang is your favourite language you checkout game engines and find ebitenengine.org. You skimmed over the documentation, learn about the Update() #TODO(link) and Draw()#TODO(link) method and end up with the following:

TODO screenshot of a bug

Not bad for a start. In your code you loaded an image, and drew it on the screen specifying the translation using the DrawImageOptions #TODO(link).

TODO draw image of coordinate system with the translation explained (no vectors yet!)

small refactoring

Pumped to have something drawn on the screen, you read more about structuring your code and decide to go down the game-object route. While at it you implement input handling and are pleased with a moving bug.

TODO screenshot of a bug on background

But you soon realize that the bug moves out of the screen 😦.

screen != world

  • mouse -> screen
  • objects -> world

enter the camera

  • center the player (lots of lines in Draw())
  • introduce the camera

change position

  • introduce the concept of position
  • vector math

zooming

  • allow zooming

smoothing

  • adds asymptotic math to make the camera following more smooth

rotation

  • adds rotation to the camera

translate between world and screen

  • utility functions for conversion between the world

References

About

demo implementation of a 2d camera using ebiten

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages