{"id":14460156,"url":"https://github.com/vgupta98/compose-game","last_synced_at":"2026-05-25T14:14:46.136Z","repository":{"id":250181205,"uuid":"695238764","full_name":"vgupta98/compose-game","owner":"vgupta98","description":"A simple 2D game engine built purely in Jetpack Compose.","archived":false,"fork":false,"pushed_at":"2024-07-26T14:31:37.000Z","size":1872,"stargazers_count":44,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-28T23:39:13.513Z","etag":null,"topics":["android","compose-game","game-engine","jetpack-compose"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vgupta98.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-22T16:56:23.000Z","updated_at":"2025-08-18T18:10:00.000Z","dependencies_parsed_at":"2024-07-25T18:16:55.321Z","dependency_job_id":"8996eb73-a649-4d1e-bd3f-2746d4da0151","html_url":"https://github.com/vgupta98/compose-game","commit_stats":null,"previous_names":["vgupta98/composegameengine"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/vgupta98/compose-game","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgupta98%2Fcompose-game","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgupta98%2Fcompose-game/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgupta98%2Fcompose-game/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgupta98%2Fcompose-game/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vgupta98","download_url":"https://codeload.github.com/vgupta98/compose-game/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgupta98%2Fcompose-game/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33478325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T06:32:55.349Z","status":"ssl_error","status_checked_at":"2026-05-25T06:32:35.322Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["android","compose-game","game-engine","jetpack-compose"],"created_at":"2024-09-01T21:01:07.083Z","updated_at":"2026-05-25T14:14:46.103Z","avatar_url":"https://github.com/vgupta98.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# Compose Game Engine\n\nA simple 2D game engine built with Jetpack Compose. This library provides basic game engine functionality, including game object management, collision detection, and rendering. It utilizes compose Animatable and Canvas APIs. However, it is good for small games only.\n\n## Features\n\n- Add and manage game objects (round objects and boundaries for now)\n- Start, pause, and stop the game loop\n- Collision detection with customizable restitution\n- Add gravity and acceleration\n- Listener support for game events\n- Rendering of game objects using Jetpack Compose\n\nFeel free to experiment and add your own features.\n\n## Installation\n1. Add 'https://jitpack.io' to the ```settings.gradle``` file of your project. If you have configured your project such that all project level repositories are defined in the **project level ```build.gradle```** file, then, instead of adding it to the settings.gradle file, add it to the **project level build.gradle** file.\n\n```groovy\n// settings.gradle\ndependencyResolutionManagement {\n    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n    repositories {\n        google()\n        mavenCentral()\n        maven { url 'https://jitpack.io' } // add this\n    }\n}\n```\n\n2. Add the jitpack repository to your root gradle file and the dependency to your `build.gradle` file:\n\n```groovy\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n\ndependencies {\n    implementation 'com.github.vgupta98:compose-game:1.0.0'\n}\n```\n\n## Usage\n\n1. Create an instance of the GameEngine:\n```kotlin\nval gameEngine = GameFactory.getInstance()\n```\n2. Add round objects and boundaries to the game engine:\n```kotlin\nval roundObject = RoundObject(\n    id = 1,\n    initialPosition = Vector2D(100f, 100f),\n    radius = 20f,\n    mass = 1f,\n    initialVelocity = Vector2D(1f, 1f),\n    restitution = 0.8f\n)\n\nval boundary = Boundary(\n    id = 2,\n    startPosition = Vector2D(0f, 0f),\n    endPosition = Vector2D(300f, 0f),\n    restitution = 1f\n)\n\ngameEngine.addGameObject(roundObject)\ngameEngine.addGameObject(boundary)\n```\n3. Start the game loop using a CoroutineScope:\n```kotlin\nval scope = CoroutineScope(Dispatchers.Main)\ngameEngine.startGameLoop(scope)\n```\n4. Stop the game loop:\n```kotlin\ngameEngine.stopGameLoop(scope)\n```\n5. Use the `GameBoard` composable to render the game objects:\n```kotlin\n@Composable\nfun MyGameScreen() {\n    val gameResources = listOf(\n        RoundObjectResource(\n            id = 1,\n            painter = rememberVectorPainter(image = Icons.Default.Circle)\n        ),\n        BoundaryResource(\n            id = 2,\n            color = Color.Black,\n            thicknessInPx = 2f\n        )\n    )\n\n    GameBoard(\n        modifier = Modifier.fillMaxSize(),\n        gameEngine = gameEngine,\n        gameResources = gameResources,\n        onDrawAbove = { /* Custom drawing above the game objects */ },\n        onDrawBehind = { /* Custom drawing behind the game objects */ }\n    )\n}\n```\n6. Listening to collisions is also easy. Implement the GameListener interface to listen for collisions:\n```kotlin\nclass MyGameListener : GameListener {\n    override fun onCollision(objectId1: Int, objectId2: Int) {\n        println(\"Collision between object $objectId1 and object $objectId2\")\n    }\n}\n\nval listener = MyGameListener()\ngameEngine.addListener(listener)\n```\n\nCheckout the sample app included with this project for complete usage. Here is a preview of it:\n\n![Example](gifs/example.gif)\n\n## Contribution\n\nBug reports and pull requests are welcome. There is a lot room for optimizations and features!\n\n## License\n\n    Copyright (C) 2024 Vishal Gupta\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgupta98%2Fcompose-game","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvgupta98%2Fcompose-game","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgupta98%2Fcompose-game/lists"}