Skip to content

A highly-optimized, flexible and powerful 2D camera for MonoGame

License

Notifications You must be signed in to change notification settings

DeanReynolds/Dcrew.Camera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dcrew.Camera

A highly-optimized, flexible and powerful 2D camera for MonoGame

Build

Features

  • Efficient math used for 2D matrices
  • Parallax system (Z coord, optional), ground (usual 2D gameplay level) is at Z 0 and the camera is at 1
    • e.g. if you wanted to draw a sprite(s) behind and half the size & position of ground, you'd use Camera.View(-0.5f) as the transformMatrix in SpriteBatch.Begin() and you would draw this before drawing the ground using Camera.View()
  • ScreenToWorld(float x, float y, float z = 0) - Converts screen coords to world coords
  • ScreenToWorld(Vector2 xy, float z = 0) - Converts screen coords to world coords
  • ScreenToWorld(Vector3 xyz) - Converts screen coords to world coords
  • ScreenToWorld(Point xy) - Converts screen coords to world coords
  • ScreenToWorldScale(float z = 0) - Returns the scale of the world at Z z in relation to the screen
  • WorldToScreen(float x, float y, float z = 0) - Converts world coords to screen coords
  • WorldToScreen(Vector2 xy, float z = 0) - Converts world coords to screen coords
  • WorldToScreen(Vector3 xyz) - Converts world coords to screen coords
  • WorldToScreen(Point xy, float z = 0) - Converts world coords to screen coords
  • WorldToScreenScale(float z = 0) - Returns the scale of the screen in relation to the world at Z z
  • UpdateMouseXY(MouseState? mouseState = null) - Will update Camera.MouseXY. Call once per frame and before using Camera.MouseXY
    • null value will auto grab latest state
  • MouseXY - Mouse/Cursor world X/Y position, make sure to call UpdateMouseXY(MouseState? mouseState = null) once per frame before using this

About

A highly-optimized, flexible and powerful 2D camera for MonoGame

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages