game-asset-library 1.0.2
A fully-featured game asset library for Pygame with customizable assets, animations, and more.
Requires Python: >=3.6

Game Asset Library
A fully-featured game asset library for Pygame that allows game developers to generate, customize, and animate game assets with ease. This library includes pre-made templates for characters, objects, backgrounds, and tools for physics-based animations, customization options, collision detection, audio handling, and scene management.

Features
Pre-designed Asset Templates: Quickly create customizable characters, objects, and backgrounds.
Customization Options: Modify assets with textures, lighting, and gradients.
Advanced Animation Tools: Create physics-based animations, easing animations, and sprite sheets.
Scene Management: Easily switch between game states like menus and levels.
Collision Detection: Detect interactions between objects.
Audio Integration: Play sound effects and music in your game.
Table of Contents
Installation
Basic Usage
Creating Characters
Creating Objects
Creating Backgrounds
Customizing Assets
Advanced Features
Animations
Scene Management
Collision Detection
Audio Tools
API Documentation
Asset Templates
Customization
Animation
Scene Management
Collision
Audio
Contributing
License
Installation
To install the Game Asset Library, use pip:


pip install game_asset_library
Ensure you have the required dependencies installed:

Pygame: Used for creating and managing game assets.
NumPy: Used for efficient calculations and processing.
Install any missing dependencies:


pip install pygame numpy
Basic Usage
Hereâ€™s a quick start guide on how to use the Game Asset Library to create and manipulate game assets.

Creating Characters
You can quickly create a dynamic character with customizable parts (like the head, arms, and legs). Here's an example of creating a character:

from game_asset_library import create_dynamic_character

# Create a character with a square head and line arms
character = create_dynamic_character(parts={'head': 'square', 'arms': 'lines'}, size=(50, 75))

# Display this in a Pygame window (for demonstration)
screen.blit(character, (100, 100))
You can customize the characterâ€™s body parts by passing a dictionary with keys like 'head', 'arms', and 'legs'.

Creating Objects
You can create simple or complex procedural objects such as polygons, circles, and squares:

from game_asset_library import create_polygon_object

# Create an 8-sided polygon (octagon)
polygon = create_polygon_object(vertices=8, color=(255, 0, 0), size=(60, 60))

# Display the polygon in the Pygame window
screen.blit(polygon, (200, 100))
Creating Backgrounds
The library allows you to create various types of backgrounds like gradients, noise, and patterned textures:

from game_asset_library import create_textured_background

# Create a gradient background
background = create_textured_background(pattern_type="gradient", colors=((135, 206, 250), (0, 128, 128)))

# Set the background in your Pygame game
screen.blit(background, (0, 0))
You can choose between gradient, stripes, or random noise backgrounds.

Customizing Assets
Once you've created an asset, you can further customize it by applying effects such as textures, lighting, and gradients:

from game_asset_library import apply_texture_overlay, apply_lighting

# Apply a texture overlay to an asset (e.g., stripes)
polygon = apply_texture_overlay(polygon, texture_type="stripes", color=(200, 200, 200))

# Add lighting effect to the character
character = apply_lighting(character, intensity=0.5)
Advanced Features
Animations
The library comes with advanced animation tools, including physics-based movement, easing functions, and sprite sheet creation.

Physics-based Animation Example
from game_asset_library import PhysicsAnimation

# Create a physics animation object for a character
physics_animation = PhysicsAnimation(character, gravity=0.5, bounce_factor=0.7)

# Update the animation in the game loop
character_surface, character_position = physics_animation.update(dt)
screen.blit(character_surface, character_position)
Easing Animation Example
from game_asset_library import EasingAnimation

# Create an easing animation object for smooth transitions
easing_animation = EasingAnimation(character, start_pos=(100, 100), end_pos=(500, 300), duration=2000)

# Update the animation in the game loop
character_surface, character_position = easing_animation.update(dt)
screen.blit(character_surface, character_position)
Scene Management
The library provides a simple scene manager to handle game states like menus, levels, or cutscenes.

from game_asset_library import SceneManager

# Create a scene manager
scene_manager = SceneManager()

# Define a menu scene
def main_menu():
    # Logic for the main menu
    screen.fill((0, 0, 0))
    screen.blit(font.render("Main Menu", True, (255, 255, 255)), (100, 100))

# Define a game scene
def game_scene():
    # Game logic here
    screen.fill((0, 0, 255))

# Add scenes and switch between them
scene_manager.add_scene("menu", main_menu)
scene_manager.add_scene("game", game_scene)
scene_manager.switch_scene("menu")
Collision Detection
You can easily check for collisions between objects using the built-in collision detection tools:

from game_asset_library import check_collision

# Create two rectangles (character and platform)
rect1 = pygame.Rect(100, 100, 50, 75)
rect2 = pygame.Rect(300, 400, 200, 20)

# Check if they collide
if check_collision(rect1, rect2):
    print("Collision detected!")
Audio Tools
Play sound effects and background music using the libraryâ€™s simple audio tools:

from game_asset_library import load_sound, play_sound

# Load sound effects and music
jump_sound = load_sound("assets/jump.wav")
background_music = load_sound("assets/background_music.wav")

# Play sound effects and music
play_sound(jump_sound)
background_music.play(loops=-1)  # Loop background music
API Documentation
Hereâ€™s a complete breakdown of all the core functions in the library.

Asset Templates
create_dynamic_character(parts=None, color=(0, 128, 255), size=(100, 150))
Create a character with customizable body parts like head, arms, and legs.

parts: Dictionary to specify the shape of the parts ('head': 'circle', 'arms': 'lines', etc.).
color: RGB color of the character.
size: Tuple for the size (width, height).
create_polygon_object(vertices=5, color=(0, 255, 0), size=(40, 40))
Create a polygonal object with a specified number of vertices.

vertices: Number of vertices for the polygon.
color: RGB color of the object.
size: Size of the object.
create_textured_background(pattern_type="gradient", colors=((255, 0, 0), (0, 0, 255)), size=(800, 600))
Create a textured background (gradient, stripes, noise, etc.).

pattern_type: Type of pattern ('gradient', 'stripes', 'noise').
colors: Tuple of colors for the pattern.
size: Tuple for background size (width, height).
Customization
apply_texture_overlay(asset, texture_type="stripes", color=(255, 255, 255))
Apply a texture overlay to an asset (e.g., stripes, noise).

asset: Pygame surface to apply the texture to.
texture_type: Type of texture ('stripes', 'dots', 'noise').
color: Color of the texture.
apply_lighting(asset, intensity=0.3)
Apply a lighting effect by darkening parts of the asset.

asset: Pygame surface to apply lighting to.
intensity: Float value from 0 to 1 for the lighting intensity.
Animation
PhysicsAnimation(asset, gravity=0.5, bounce_factor=0.7)
Create a physics-based animation for an asset with gravity and bounce effects.

asset: Pygame surface of the asset.
gravity: Gravity force applied to the asset.
bounce_factor: The factor of energy retention after a bounce.
EasingAnimation(asset, start_pos, end_pos, duration)
Create an easing animation for smooth transitions between two positions.

asset: Pygame surface of the asset.
start_pos: Starting position (x, y).
end_pos: Ending position (x, y).
duration: Time duration for the transition (in milliseconds).
Scene Management
SceneManager()
A class that manages game scenes.

add_scene(name, scene_function): Add a new scene.
switch_scene(name): Switch to a different scene.
update(): Update the current scene.
Collision
check_collision(rect1, rect2)
Check if two rectangular objects are colliding.

rect1: First rectangle (pygame.Rect).
rect2: Second rectangle (pygame.Rect).
Audio
load_sound(file_path)
Load and return a Pygame sound object.

file_path: Path to the sound file.
play_sound(sound)
Play a sound effect.

sound: Pygame sound object to play.
Contributing
We welcome contributions! If you'd like to contribute to this project, please fork the repository and submit a pull request. You can also report issues or request features.

License
This project is licensed under the MIT License. See the LICENSE file for details.