Skip to main content

Un conjunto de herramientas útiles para el desarrollo de videojuegos con Pygame.

Project description

Pygame Tool Kit

Pygame Tool Kit Logo

A powerful and flexible toolkit to simplify game development with Pygame.


Table of Contents


Description

Pygame Tool Kit is a library designed to simplify game development in Python using Pygame. It provides a range of tools and utilities covering events management, storage handling, and more, allowing developers to focus on what really matters: creating great games!


Features

  • Events Management: Subscribe, emit, and manage events efficiently.
  • Storage Management: Save and load game settings and data in JSON format.
  • Flexible Configuration: Configure the library from anywhere in your project.
  • Easy to Use: Intuitive interfaces that are easy to integrate with your project.

Installation

You can easily install it by using pip:

pip install Pygame_Tool_Kit

Usage

Configuration

Before using Pygame Tool Kit, you need to configure some basic parameters such as screen resolutions and the initial scale. This configuration can be done from anywhere in your project. Example of a game_config.json file:

{
	"font_path": "Pygame_Tool_Kit/assets/font/Gloack_Font.ttf",
	"assets_path": "Pygame_Tool_Kit/assets/GUI/",
	"icon_path": "Pygame_Tool_Kit/assets/GUI/icon.png",
	"storage_path": "Pygame_Tool_Kit/storage/",
	"game_title": "Simple Game",
	"resolutions": [
		[384, 216],
		[768, 432],
		[1152, 648],
		[1536, 864],
		[1920, 1080]
	],
	"init_scale": 1
}

Events Management

Manage in-game events using the constant EVENTS_MANAGER. You can subscribe to events, emit them, and process them with ease.

from pygame_tool_kit.constants import EVENTS_MANAGER

# Funcion to call when the "quit" event is emitted
def on_quit ():
    print ("The game is closing")

EVENTS_MANAGER.subscribe ("quit", on_quit)

# Emit the "quit" event
EVENTS_MANAGER.emit ("quit")

Storage Management

Storage_Manager allows you to save and load game data from JSON files in a structured way. It distinguishes between static and dynamic data.

  • Static Data: Stored in a single static.json file.
  • Dynamic Data: Each piece of data is stored in its own JSON file within a dynamic directory.

Saving Data

To save dynamic game data (such as game progress or user settings):

from pygame_tool_kit.constants import STORAGE_MANAGER

data : dict[str, int] = { "level" : 3, "score" : 1500 }
STORAGE_MANAGER.save ("current_game", data)

This will save the data to a file located at STORAGE_PATH/dynamic/current_game.json.


Loading Data

To load either static or dynamic data:

# Loading dynamic data
current_game = STORAGE_MANAGER.load ("current_game", static = False)
print (current_game)

# Loading static data
static_data = STORAGE_MANAGER.load ("game_settings", static = True)
print (static_data)
  • If static=True, it will look for the data in STORAGE_PATH/static.json.
  • If static=False, it will load the data from STORAGE_PATH/dynamic/{at}.json.

License

This project is licensed under the MIT License.


Thank you for using Pygame Tool Kit! I hope it helps you create amazing games with Python! Additional Notes:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygame_tool_kit-1.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

Pygame_Tool_Kit-1.1.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pygame_tool_kit-1.1.0.tar.gz.

File metadata

  • Download URL: pygame_tool_kit-1.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for pygame_tool_kit-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6d2b3d3e2dd3d13093b415c717b2718bb419b5ecbea3cf19d0d1cc96fe349b45
MD5 5b62ddab1b726d249e2cb4ba9b3cdbe2
BLAKE2b-256 3877eb6012db34f3608a4054b47a3dcac431e069d6b097583e61cb418e09cdc7

See more details on using hashes here.

File details

Details for the file Pygame_Tool_Kit-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for Pygame_Tool_Kit-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9937e9706806c0fb0e00210517aee63f130950633a1173000f2e8c3aa191ab64
MD5 05856185a279301fcebc11ab7ec09a02
BLAKE2b-256 18ea6947461f11fdab092d5b45dc2cd675571d6d32e8b912210bdef0f6c425f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page