{"id":13435558,"url":"https://github.com/dotnet-ad/Comora","last_synced_at":"2025-03-18T11:31:31.151Z","repository":{"id":64877340,"uuid":"66837325","full_name":"dotnet-ad/Comora","owner":"dotnet-ad","description":"A simple 2D camera for Monogame.","archived":false,"fork":false,"pushed_at":"2019-07-17T15:20:44.000Z","size":1567,"stargazers_count":85,"open_issues_count":5,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-05-01T13:52:14.499Z","etag":null,"topics":["camera","monogame"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotnet-ad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-29T11:20:58.000Z","updated_at":"2024-04-30T09:02:36.000Z","dependencies_parsed_at":"2022-12-20T00:11:11.112Z","dependency_job_id":null,"html_url":"https://github.com/dotnet-ad/Comora","commit_stats":null,"previous_names":["aloisdeniel/comora"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-ad%2FComora","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-ad%2FComora/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-ad%2FComora/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-ad%2FComora/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnet-ad","download_url":"https://codeload.github.com/dotnet-ad/Comora/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244211025,"owners_count":20416571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["camera","monogame"],"created_at":"2024-07-31T03:00:36.838Z","updated_at":"2025-03-18T11:31:26.143Z","avatar_url":"https://github.com/dotnet-ad.png","language":"C#","funding_links":[],"categories":["Helpers"],"sub_categories":[],"readme":"![logo](./Documentation/Logo.png)\n\n# Comora\n\nA simple 2D camera for [Monogame](http://www.monogame.net/).\n\n## Install\n\nAvailable on NuGet\n\n[![NuGet](https://img.shields.io/nuget/v/Comora.svg?label=NuGet)](https://www.nuget.org/packages/Comora/)\n\n## Quickstart\n\n```sharp\nprivate Camera camera;\n\nprotected override void Initialize()\n{\n\tthis.camera = new Camera(this.graphics);\n\t\n\tbase.Initialize();\n}\n\nprotected override void Update(GameTime gameTime)\n{\n\tthis.camera.Update(gameTime);\n\t\n\tthis.camera.Position = Mouse.GetState().Position.ToVector2();\n\t\n\tbase.Update(gameTime);\n}\n\nprotected override void Draw(GameTime gameTime)\n{\n    graphics.GraphicsDevice.Clear(Color.CornflowerBlue);\n    \n\tspriteBatch.Begin(this.camera);\n\t// Draw here\n\tspriteBatch.End();\n\n\tbase.Draw(gameTime);\n}\n\n```\n\n## Draw\n\nThrough the `SpriteBatch` extension methods, simply call `Begin` as usual, but with your camera :\n\n```csharp\nspriteBatch.Begin(this.camera);\n```\n\nYou can add a parralax factor too :\n\n```csharp\nspriteBatch.Begin(this.camera, new Vector2(0.85f,0.85f));\n```\n## Animations\n\nYou can add animation by applying [Transform](https://www.github.com/aloisdeniel/Transform) velocities or tweens onto the the camera's `Transform` property.\n\n## Conversion\n\nYou can convert a point from screen unit to world :\n\n```csharp\nvar screenPosition = Vector.Zero;\nvar worldPosition = Vector.Zero;\ncamera.ToWorld(ref screenPosition, out worldPosition);\n```\n\nConverting world coordinates to screen coordinates is also possible.\n\n```csharp\nvar screenPosition = Vector.Zero;\nvar worldPosition = Vector.Zero;\ncamera.ToScreen(ref worldPosition, out screenPosition);\n```\n\n## Debug tools\n\n![](./Documentation/DebugTools.png)\n\nThe framework provide several tools for debugging purpose.\n\n```csharp\ncamera.Debug.IsVisible = Keyboard.GetState().IsKeyDown(Keys.F1);\n```\n\nMake sure to load content too :\n\n```csharp\nthis.camera.LoadContent(GraphicsDevice);\n```\n\nAnd then draw it with `Draw` extension method. You don't have to call `spriteBatch.Begin` and `spriteBatch.End` which are already invoked by the method.\n\n```csharp\nthis.spriteBatch.Draw(this.camera.Debug);\n```\n\n### FPS\n\nThe number of frame per seconds will be displayed on the layer.\n\n### Grid\n\nA visual grid for world units.\n\n```csharp\n// To draw a white line of size 2 every 50 world units\n// and a red one of size 4 every 200 world units.\ncamera.Debug.Grid.AddLines(50, Color.White, 2);\ncamera.Debug.Grid.AddLines(200, Color.Red, 4);\n```\n\n## Roadmap / Ideas\n\n* Integrate shaders for easy screen effects.\n* Add more built-in animations.\n* Clean and improve debug layer.\n\n## Why?\n\n\"Seriously, just a camera ?\" ... Yes! I often see full engines with tons of stuff I never need. I'm looking about modularity and easy APIs (like many awesome [LÖVE](https://love2d.org/) libraries) and that's why I created **Comora**. I'm sure this could be useful for someone else.\n\n## Thanks\n\n* [david-gouveia](http://www.david-gouveia.com/portfolio/2d-camera-with-parallax-scrolling-in-xna/)\n* [Monogame.Extended](https://github.com/craftworkgames/MonoGame.Extended)\n\n## Contributions\n\nContributions are welcome! If you find a bug please report it and if you want a feature please report it.\n\nIf you want to contribute code please file an issue and create a branch off of the current dev branch and file a pull request.\n\n### License\n\nMIT © [Aloïs Deniel](http://aloisdeniel.github.io)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-ad%2FComora","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnet-ad%2FComora","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-ad%2FComora/lists"}