semvec/pypi-packages huggingface dataset:
PyCollision 0.0.2
This library helps to detect collision for image with transparency. Useful for game development
License: MIT
Requires Python: >=3.5
Keywords: Collision,pygame,python collision,Rectangular collision,pycollision

# PyCollision

This is a collision detection program that makes use of rectangles to detect collision.

Quick example using pygame:
```python
import pygame
import random
from pycollision import Collision

pygame.init()

screen = pygame.display.set_mode((1000, 800))

player_rect = pygame.Rect(0, 0, 50, 50)

collision_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
collision_object = pygame.image.load(r"sample.png").convert_alpha()

colors = [(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) for x in
          range(len(collision_check.collision_points()))]

running = True
speed = 1.5
pos_x, pos_y = (10, 10)

coll_font = pygame.font.SysFont('Consolas', 50)

while running:

    screen.fill((255, 255, 255))

    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            running = False

    pos_x, pos_y = pygame.mouse.get_pos()

    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
    # rect = (player_rect.x, player_rect.y, player_rect.x+player_rect.width, player_rect.height+player_rect.y)
    # colliding, pos = collision_check.rect_collide(rect)
    if colliding:
        screen.fill((255, 16, 8))
        screen.blit(coll_font.render("Collision", True, (255, 255, 255)), (50, 50))

    screen.blit(collision_object, (0, 0))

    # for color, x in zip(colors, collision_check.collision_points()):  # uncomment this to get colourful rectangles
    #     x = (x[0], x[1], x[2] - x[0], x[3] - x[1])
    #     pygame.draw.rect(screen, color, pygame.Rect(x), width=3)

    player_rect = pygame.Rect(pos_x, pos_y, 50, 50)
    pygame.draw.rect(screen, (0, 0, 0), player_rect)

    pygame.display.update()
```
save the below sample image in the same directory as the program and give a test run.

![Sample Image](https://github.com/PaulleDemon/PyCollision/blob/main/Examples/TestImages/sample.png?raw=True)

Check out more examples [here](https://github.com/PaulleDemon/PyCollision/tree/main/Examples).

Refer documentation [here](https://github.com/PaulleDemon/PyCollision/blob/main/Documentation.md)
joshc-repo 0.0.0.6
None
License: MIT
Requires Python: >=3.6

# Project

> This repo has been populated by an initial template to help get you started. Please
> make sure to update the content to build a great experience for community-building.

As the maintainer of this project, please make a few updates:

- Improving this README.MD file to provide a great experience
- Updating SUPPORT.MD with content about this project's support experience
- Understanding the security reporting process in SECURITY.MD
- Remove this section from the README

## Contributing

This project welcomes contributions and suggestions.  Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft 
trademarks or logos is subject to and must follow 
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.