{"id":22297746,"url":"https://github.com/paulledemon/pycollision","last_synced_at":"2025-07-29T01:33:08.985Z","repository":{"id":62579393,"uuid":"394314177","full_name":"PaulleDemon/PyCollision","owner":"PaulleDemon","description":"Quickly makes hitboxes given an image, useful for collision detection. view demo images: https://github.com/PaulleDemon/PyCollision/blob/main/DemoImages.md","archived":false,"fork":false,"pushed_at":"2024-09-04T04:08:50.000Z","size":2049,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-14T13:53:10.819Z","etag":null,"topics":["2d-game","collision","collision-detection","pycollision","pygame"],"latest_commit_sha":null,"homepage":"https://browsedocs.com/LBImCEvuwGje","language":"Python","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/PaulleDemon.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2021-08-09T14:04:43.000Z","updated_at":"2024-09-04T04:08:53.000Z","dependencies_parsed_at":"2023-12-04T15:37:18.537Z","dependency_job_id":null,"html_url":"https://github.com/PaulleDemon/PyCollision","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PaulleDemon/PyCollision","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulleDemon%2FPyCollision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulleDemon%2FPyCollision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulleDemon%2FPyCollision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulleDemon%2FPyCollision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PaulleDemon","download_url":"https://codeload.github.com/PaulleDemon/PyCollision/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulleDemon%2FPyCollision/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267616582,"owners_count":24116155,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["2d-game","collision","collision-detection","pycollision","pygame"],"created_at":"2024-12-03T17:51:16.278Z","updated_at":"2025-07-29T01:33:08.679Z","avatar_url":"https://github.com/PaulleDemon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyCollision\n\nThis is a collision detection program that makes use of rectangles to detect collision.\n\nQuick example using pygame:\n```python\nimport pygame\nimport random\nfrom pycollision import Collision\n\npygame.init()\n\nscreen = pygame.display.set_mode((1000, 800))\n\nplayer_rect = pygame.Rect(0, 0, 50, 50)\n\ncollision_check = Collision(r\"sample.png\", (15, 15), wall_collision=False) # set wall collision to True if you want to check the collision only at the walls, this will be much faster\ncollision_object = pygame.image.load(r\"sample.png\").convert_alpha()\n\ncolors = [(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) for x in\n          range(len(collision_check.collision_points()))]\n\nrunning = True\nspeed = 1.5\npos_x, pos_y = (10, 10)\n\ncoll_font = pygame.font.SysFont('Consolas', 50)\n\nwhile running:\n\n    screen.fill((255, 255, 255))\n\n    for event in pygame.event.get():\n\n        if event.type == pygame.QUIT:\n            running = False\n\n    pos_x, pos_y = pygame.mouse.get_pos()\n\n    colliding, pos = collision_check.smart_check((pos_x, pos_y)) # checks if the point is first inside the outer rectangle then checks if it is inside the image\n    # rect = (player_rect.x, player_rect.y, player_rect.x+player_rect.width, player_rect.height+player_rect.y)\n    # colliding, pos = collision_check.rect_collide(rect)\n    if colliding:\n        screen.fill((255, 16, 8))\n        screen.blit(coll_font.render(\"Collision\", True, (255, 255, 255)), (50, 50))\n\n    screen.blit(collision_object, (0, 0))\n\n    # for color, x in zip(colors, collision_check.collision_points()):  # uncomment this to get colourful rectangles\n    #     x = (x[0], x[1], x[2] - x[0], x[3] - x[1])\n    #     pygame.draw.rect(screen, color, pygame.Rect(x), width=3)\n\n    player_rect = pygame.Rect(pos_x, pos_y, 50, 50)\n    pygame.draw.rect(screen, (0, 0, 0), player_rect)\n\n    pygame.display.update()\n```\nsave the below sample image in the same directory as the program and give a test run.\n\n![Sample Image](https://github.com/PaulleDemon/PyCollision/blob/main/Examples/TestImages/sample.png?raw=True)\n\nCheck out more examples [here](https://github.com/PaulleDemon/PyCollision/tree/main/Examples).\n\nRefer documentation [here](https://browsedocs.com/LBImCEvuwGje)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulledemon%2Fpycollision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulledemon%2Fpycollision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulledemon%2Fpycollision/lists"}