semvec/pypi-packages huggingface dataset:
pg-core 1.0
Simple Core class for pygame
License: MIT license
Keywords: pygame

# Pygame Core Library

The Pygame Core Library is a versatile framework for developing 2D games using the Pygame library. It provides essential components and a simple structure to help you get started with game development in Python. The library includes features such as a game loop manager, scheduled events, and an FPS display.

## Installation

To use this library, you'll need to have [Pygame](https://www.pygame.org/) installed. You can install it using pip:

```
pip install pygame
```

Once Pygame is installed, you can include the `core.py` file in your project, and you're ready to start using the Pygame Core Library.

## Usage

To get started with the Pygame Core Library, follow these steps:

1. Import the library into your project:

```python
import pygame_core
```

2. Create a class that extends `Core` class to set up your game:

```python
class MyClass(pygame_core.Core):

    def __init__(self, **kwargs):
        super()._init__(**kargs)

game = MyClass(size=(800, 600))
```

3. Implement your game logic by overriding the `update` and `draw` methods in your `Core` instance:

```python
def update(self):
    # Your game logic here
    pass

def draw(self):
    # Your rendering code here
    pass
```

4. Run your game by calling the `run` method on your `Core` instance:

```python
game.run()
```

5. You can schedule repeating or one-time events using the `set_interval` and `set_timeout` methods:

```python
# Schedule a function to run every 1000 milliseconds (1 second)
game.set_interval(1000, my_function)

# Schedule a one-time event to run after 2000 milliseconds (2 seconds)
game.set_timeout(2000, another_function)
```

6. Customize the FPS display and other settings by passing appropriate arguments when creating your `Core` instance.

7. Don't forget to handle Pygame events by overriding the `check_event` method in your `Core` instance for custom event handling.

8. Add any necessary cleanup or exit code in the `__exit__` method of your `Core` instance.

## Contributing

Feel free to contribute to the Pygame Core Library by submitting issues, feature requests, or pull requests on the [GitHub repository](https://github.com/viniputtim/pg-core).

## License

This library is released under the MIT License. See the [LICENSE](LICENSE) file for more details.

## Acknowledgments

- Pygame (https://www.pygame.org/) for the underlying game development framework.

Happy game development with Pygame Core Library! If you have any questions or need assistance, don't hesitate to reach out.