Skip to main content

Scale elements to fit user resolution.

Project description

Overview

This library provides a ResolutionManager class for Pygame that handles resolution scaling across different screen sizes. It allows you to design your game for a base resolution (e.g. 1920x1080) and automatically scale positions, sizes, and images to fit both fullscreen and windowed modes.

Basic Usage

from resolution_manager import ResolutionManager import pygame

pygame.init()

#Create class res = ResolutionManager(fullscreen=False, windowed_size=(1280, 720))

screen = res.get_screen() clock = pygame.time.Clock()

#Load and scale image img = pygame.image.load("internal/sp_health_100.png").convert_alpha() img = pygame.transform.scale(img, res.get_scaled_size(300, 300))

running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False

screen.fill((30, 30, 30))

#Draw centered image
img_rect = img.get_rect(center=(res.screen_width // 2, res.screen_height // 2))
screen.blit(img, img_rect)

pygame.display.flip()
clock.tick(60)

pygame.quit()

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

PyResScale-1.0.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyResScale-1.0.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file PyResScale-1.0.0.tar.gz.

File metadata

  • Download URL: PyResScale-1.0.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for PyResScale-1.0.0.tar.gz
Algorithm Hash digest
SHA256 64580abb25d37be802240ff18e93883c9f070e4a04f6ef0f45439cd16b0b0334
MD5 9081eb5ff31c4ba3156e2bb71223cc8f
BLAKE2b-256 82e666b467a0110c267033cf496c3f7a646d584c370e54ec4fe0529cff40a5e7

See more details on using hashes here.

File details

Details for the file PyResScale-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: PyResScale-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for PyResScale-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb8f99a0301acddab6520a67102c560d52dd3b45f71f11269afaa7953abc0c93
MD5 29104e47484a978f1fbe677c1d0b0aa1
BLAKE2b-256 446b6d510e0738d2227887a61ac21a289efe80b693c5fb3b32a632b30da7e50b

See more details on using hashes here.

Supported by

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