Skip to main content

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

Project description

Pygame Tool Kit
Pygame Tool Kit


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.2.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygame_tool_kit-1.2.0.tar.gz
  • Upload date:
  • Size: 11.9 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.2.0.tar.gz
Algorithm Hash digest
SHA256 14be9c628f71a4fa686d799dae69d32935e24ae1bd668aa7aa5ebf21b6d9d21f
MD5 a5d5b03307d9c83ef369420e3e6a352f
BLAKE2b-256 ab864df18aa75cc5088199c21f3e94407c6125498eb8c7e9dc4a172ae57817d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Pygame_Tool_Kit-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 469927875c467b8d41908d1aa515b1cce53aa9f378435c68a24f774f78312aba
MD5 531978ddee476b207ef99495ef9e04b4
BLAKE2b-256 20450c949ee87cbabc37e606f793e2634b89c8905f44aa08d9c16753222333ef

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