pygame-click-manager


Namepygame-click-manager JSON
Version 1.0 PyPI version JSON
download
home_pagehttps://github.com/FrickTzy/Pygame-Click-Manager
SummaryA package for managing clicks in pygame.
upload_time2024-06-11 04:21:28
maintainerNone
docs_urlNone
authorFrickTzy (Kurt Arnoco)
requires_pythonNone
licenseNone
keywords python pygame python game python game development pygame button
VCS
bugtrack_url
requirements pygame
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pygame-Click-Manager

`pygame_click_manager` is a Python module designed to facilitate the handling of mouse events and collisions within the Pygame framework. The main class, `ClickManager`, provides methods to check for button clicks, verify if the mouse is within a specified area, and determine if one object is inside or colliding with another object.

## Features

- **Check Button Clicks**: Verify if a button is clicked and execute a command if provided.
- **Mouse Area Check**: Determine if the mouse pointer is within a specified area.
- **Object Containment**: Check if one object is completely inside another object.
- **Object Collision**: Check if one object is colliding with another object.

## Installation

To use `pygame_click_manager`, ensure you have Pygame installed:

```bash
pip install pygame
```

Then, include `pygame_click_manager` in your project by copying the class definition into your codebase.

## Usage

Here's a basic example of how to use the `ClickManager` class:

```python
import pygame
from pygame_click_manager import ClickManager

# Initialize Pygame
pygame.init()

# Create a screen
screen = pygame.display.set_mode((800, 600))

# Define a command to be executed on button click
def button_command():
    print("Button clicked!")

# Main loop
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # Check for button clicks
    if ClickManager.check_buttons_for_clicks((100, 100), (150, 50), button_command):
        print("Button area was clicked.")

    # Your game logic here

    # Update the display
    pygame.display.update()

pygame.quit()
```

## Class Reference

### `ClickManager`

#### Methods

- `check_buttons_for_clicks(starting_pos: tuple[int, int], size: tuple[int, int], command=None) -> bool`
  - Checks if a button is clicked within the specified area.
  - **Parameters**:
    - `starting_pos`: The top-left corner of the button area.
    - `size`: The width and height of the button area.
    - `command`: An optional command (function) to be executed when the button is clicked.
  - **Returns**: `True` if the button is clicked, otherwise `False`.

- `_is_mouse_in_area(starting_pos: tuple[int, int], size: tuple[int, int]) -> bool`
  - Checks if the mouse is within a specified area.
  - **Parameters**:
    - `starting_pos`: The top-left corner of the area.
    - `size`: The width and height of the area.
  - **Returns**: `True` if the mouse is in the area, otherwise `False`.

- `is_object_inside_another(start_pos_1: tuple[int, int], size_1: tuple[int, int], start_pos_2: tuple[int, int], size_2: tuple[int, int]) -> bool`
  - Checks if the second object is completely inside the first object.
  - **Parameters**:
    - `start_pos_1`: The top-left corner of the first object.
    - `size_1`: The width and height of the first object.
    - `start_pos_2`: The top-left corner of the second object.
    - `size_2`: The width and height of the second object.
  - **Returns**: `True` if the second object is inside the first object, otherwise `False`.

- `is_object_colliding_with_another(start_pos_1: tuple[int, int], size_1: tuple[int, int], start_pos_2: tuple[int, int], size_2: tuple[int, int]) -> bool`
  - Checks if the second object is colliding with the first object.
  - **Parameters**:
    - `start_pos_1`: The top-left corner of the first object.
    - `size_1`: The width and height of the first object.
    - `start_pos_2`: The top-left corner of the second object.
    - `size_2`: The width and height of the second object.
  - **Returns**: `True` if the objects are colliding, otherwise `False`.

## License

This project is licensed under the MIT License.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/FrickTzy/Pygame-Click-Manager",
    "name": "pygame-click-manager",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, pygame, python game, python game development, pygame button",
    "author": "FrickTzy (Kurt Arnoco)",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/93/8c/fbdd4a44ab3d9a0c86416850df09394eedbcb83f43d96e593bae509fc105/pygame_click_manager-1.0.tar.gz",
    "platform": null,
    "description": "# Pygame-Click-Manager\n\n`pygame_click_manager` is a Python module designed to facilitate the handling of mouse events and collisions within the Pygame framework. The main class, `ClickManager`, provides methods to check for button clicks, verify if the mouse is within a specified area, and determine if one object is inside or colliding with another object.\n\n## Features\n\n- **Check Button Clicks**: Verify if a button is clicked and execute a command if provided.\n- **Mouse Area Check**: Determine if the mouse pointer is within a specified area.\n- **Object Containment**: Check if one object is completely inside another object.\n- **Object Collision**: Check if one object is colliding with another object.\n\n## Installation\n\nTo use `pygame_click_manager`, ensure you have Pygame installed:\n\n```bash\npip install pygame\n```\n\nThen, include `pygame_click_manager` in your project by copying the class definition into your codebase.\n\n## Usage\n\nHere's a basic example of how to use the `ClickManager` class:\n\n```python\nimport pygame\nfrom pygame_click_manager import ClickManager\n\n# Initialize Pygame\npygame.init()\n\n# Create a screen\nscreen = pygame.display.set_mode((800, 600))\n\n# Define a command to be executed on button click\ndef button_command():\n    print(\"Button clicked!\")\n\n# Main loop\nrunning = True\nwhile running:\n    for event in pygame.event.get():\n        if event.type == pygame.QUIT:\n            running = False\n\n    # Check for button clicks\n    if ClickManager.check_buttons_for_clicks((100, 100), (150, 50), button_command):\n        print(\"Button area was clicked.\")\n\n    # Your game logic here\n\n    # Update the display\n    pygame.display.update()\n\npygame.quit()\n```\n\n## Class Reference\n\n### `ClickManager`\n\n#### Methods\n\n- `check_buttons_for_clicks(starting_pos: tuple[int, int], size: tuple[int, int], command=None) -> bool`\n  - Checks if a button is clicked within the specified area.\n  - **Parameters**:\n    - `starting_pos`: The top-left corner of the button area.\n    - `size`: The width and height of the button area.\n    - `command`: An optional command (function) to be executed when the button is clicked.\n  - **Returns**: `True` if the button is clicked, otherwise `False`.\n\n- `_is_mouse_in_area(starting_pos: tuple[int, int], size: tuple[int, int]) -> bool`\n  - Checks if the mouse is within a specified area.\n  - **Parameters**:\n    - `starting_pos`: The top-left corner of the area.\n    - `size`: The width and height of the area.\n  - **Returns**: `True` if the mouse is in the area, otherwise `False`.\n\n- `is_object_inside_another(start_pos_1: tuple[int, int], size_1: tuple[int, int], start_pos_2: tuple[int, int], size_2: tuple[int, int]) -> bool`\n  - Checks if the second object is completely inside the first object.\n  - **Parameters**:\n    - `start_pos_1`: The top-left corner of the first object.\n    - `size_1`: The width and height of the first object.\n    - `start_pos_2`: The top-left corner of the second object.\n    - `size_2`: The width and height of the second object.\n  - **Returns**: `True` if the second object is inside the first object, otherwise `False`.\n\n- `is_object_colliding_with_another(start_pos_1: tuple[int, int], size_1: tuple[int, int], start_pos_2: tuple[int, int], size_2: tuple[int, int]) -> bool`\n  - Checks if the second object is colliding with the first object.\n  - **Parameters**:\n    - `start_pos_1`: The top-left corner of the first object.\n    - `size_1`: The width and height of the first object.\n    - `start_pos_2`: The top-left corner of the second object.\n    - `size_2`: The width and height of the second object.\n  - **Returns**: `True` if the objects are colliding, otherwise `False`.\n\n## License\n\nThis project is licensed under the MIT License.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A package for managing clicks in pygame.",
    "version": "1.0",
    "project_urls": {
        "Homepage": "https://github.com/FrickTzy/Pygame-Click-Manager"
    },
    "split_keywords": [
        "python",
        " pygame",
        " python game",
        " python game development",
        " pygame button"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c257576ee0675850705614fba348b935fa84283bd60b26727c681a15a226cb1b",
                "md5": "9c158962a0b587dcfdf8969962f7a991",
                "sha256": "68c5382fb062e80088eeb63c741c07e0e3c8330e7a82fd5df7c52d6cc057c3e9"
            },
            "downloads": -1,
            "filename": "pygame_click_manager-1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9c158962a0b587dcfdf8969962f7a991",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3488,
            "upload_time": "2024-06-11T04:21:26",
            "upload_time_iso_8601": "2024-06-11T04:21:26.368329Z",
            "url": "https://files.pythonhosted.org/packages/c2/57/576ee0675850705614fba348b935fa84283bd60b26727c681a15a226cb1b/pygame_click_manager-1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "938cfbdd4a44ab3d9a0c86416850df09394eedbcb83f43d96e593bae509fc105",
                "md5": "ab830b7556b1308dee11e823506e7474",
                "sha256": "433fdf2ec930b6d9243263275bb046d53539a7b4b25a7c1f9e7349fc0718f43e"
            },
            "downloads": -1,
            "filename": "pygame_click_manager-1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ab830b7556b1308dee11e823506e7474",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 2990,
            "upload_time": "2024-06-11T04:21:28",
            "upload_time_iso_8601": "2024-06-11T04:21:28.253417Z",
            "url": "https://files.pythonhosted.org/packages/93/8c/fbdd4a44ab3d9a0c86416850df09394eedbcb83f43d96e593bae509fc105/pygame_click_manager-1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-11 04:21:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "FrickTzy",
    "github_project": "Pygame-Click-Manager",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pygame",
            "specs": [
                [
                    "~=",
                    "2.5.2"
                ]
            ]
        }
    ],
    "lcname": "pygame-click-manager"
}
        
Elapsed time: 0.73020s