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!

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

Uploaded Source

Built Distribution

Pygame_Tool_Kit-1.3.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pygame_tool_kit-1.3.0.tar.gz
Algorithm Hash digest
SHA256 a715374bf1f1fd3a85b46f33636abd19daba66e5a3ee13677e9a175e21db3b93
MD5 eedec98bb7bd049eeb4f45916de503df
BLAKE2b-256 2e16d03b14772106b91c7b813df6911fec74b3c660c11335cce1b1211b1c74d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Pygame_Tool_Kit-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32fc161c0923db4a9cc0a2a27ed63e88305cdd71c7a298a748e3d65427392bed
MD5 6113425230088f5b9963f28391620daf
BLAKE2b-256 7824737e8519afd8c8d34e34aeb0e1a78e8ea7c9a5684884250ba22dd81c0266

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