Skip to main content

A virtual screen manager for Pygame that handles window scaling and fullscreen functionality

Project description

pg_vtscreen

A virtual screen manager for Pygame that handles window scaling, aspect ratio maintenance, and fullscreen functionality.

Features

  • Create a virtual screen (game logic drawing area) independent of the display window
  • Manage the actual display window with enhanced functionality
  • Support fullscreen toggle (default F11 key)
  • Maintain aspect ratio when resizing windows
  • Handle basic window events (close, resize)

Installation

pip install pg_vtscreen

Usage Example

import pygame from pg_vtscreen import VirtualScreenManager

Initialize Pygame

pygame.init()

Create virtual screen manager

vsm = VirtualScreenManager()

Create virtual screen (game resolution)

virtual_screen = vsm.create_virtual_window(1280, 720)

Create display window (user's window)

display_screen = vsm.create_display_window( size=(800, 600), flags=pygame.RESIZABLE, caption="pg_vtscreen Example" )

Main loop

clock = pygame.time.Clock() running = True

while running: # Handle events vsm.handle_events()

# Draw on virtual screen
virtual_screen.fill((0, 0, 0))  # Black background
pygame.draw.circle(virtual_screen, (0, 255, 0), (640, 360), 50)  # Green circle in center

# Project virtual screen to display
vsm.project_to_screen(maintain_aspect_ratio=True)

# Maintain 60 FPS
clock.tick(60)

Documentation

VirtualScreenManager Class

Methods

  • __init__(): Initialize the virtual screen manager
  • create_virtual_window(width, height): Create a virtual drawing surface
  • create_display_window(size=(), flags=0, ...): Create the actual display window
  • set_fullscreen_key(key): Set custom key for fullscreen toggle (default F11)
  • project_to_screen(maintain_aspect_ratio=True): Scale and draw virtual screen to display
  • handle_events(): Handle basic window events (close, resize, fullscreen)

License

This project is licensed under the BSD License - see the LICENSE file for details.

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

pg_vtscreen-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

pg_vtscreen-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pg_vtscreen-0.1.0.tar.gz.

File metadata

  • Download URL: pg_vtscreen-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for pg_vtscreen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fa5ad46754e4c31691eee30522c758f1d46d59033c413e25322332712f4b4223
MD5 efe859522d8e38dec0ec6b0218600509
BLAKE2b-256 824b7f37596d4457559b40e952a135ed1018a7adc5280d8bcf47eba73680cecb

See more details on using hashes here.

File details

Details for the file pg_vtscreen-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pg_vtscreen-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for pg_vtscreen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f8504acd452f6918e597aee4eec53cebe40aa614a89e1d5e1907588f42f09fb
MD5 75da0d1d4bf4d795a2748d700cd462a4
BLAKE2b-256 450fcb4ff6ce1e128d39b5bee4f54e7495a89c77429110b4b9b4e489cc3035d2

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