Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a SystemMonitorOverlay class #15

Open
joshjaysalazar opened this issue May 5, 2023 · 0 comments
Open

Add a SystemMonitorOverlay class #15

joshjaysalazar opened this issue May 5, 2023 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@joshjaysalazar
Copy link
Owner

joshjaysalazar commented May 5, 2023

Feature description

A SystemMonitorOverlay class that provides real-time information about major system resources, such as CPU usage, memory usage, and network usage, within a game developed using the Pygkit library. This feature would help users monitor their game's performance and identify potential bottlenecks or resource-intensive operations. The monitor would be customizable, allowing users to enable or disable specific components, choose the location on the screen, and have both text and visual representations for each component.

Proposed solution

Introduce a SystemMonitorOverlay class with the following methods and properties:

  • __init__(self, components, position): Initialize the SystemMonitorOverlay with a list of components to display (e.g., CPU usage, memory usage, network usage) and the position on the screen (e.g., top-left, top-right, bottom-left, bottom-right).
  • draw(self, screen): Render the system monitor on the given screen, displaying both text and visual representations for each enabled component.
  • toggle_component(self, component): Toggle the visibility of a specific component during runtime.

Here's an example of how the SystemMonitorOverlay class could be used:

import pygame
import pygkit

# Setup Pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()

# Create a SystemMonitorOverlay instance with CPU and memory usage components
system_monitor = pygkit.SystemMonitorOverlay(
    components=['cpu', 'memory'],
    position='top_left'
)

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

    # Render the game and the SystemMonitorOverlay
    screen.fill((128, 128, 128))
    system_monitor.draw(screen)

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

pygame.quit()

Alternative solutions

An alternative solution could be to provide individual classes for each component (e.g., CPUUsageOverlay, MemoryUsageOverlay, NetworkUsageOverlay) and allow users to create and manage multiple instances of these classes. However, this approach might be more complex and less convenient for users who want to create a comprehensive system resource monitor with minimal configuration.

Additional context

This feature would be a valuable addition to the Pygkit library, as it allows users to monitor their game's performance and understand the impact of their code on system resources. The customizable nature of the SystemMonitorOverlay ensures that users can tailor the monitor to their specific needs and only display the information they find most useful. Integrating this feature into the library would provide developers with an additional tool for optimizing their games and ensuring a smooth and enjoyable gameplay experience.

@joshjaysalazar joshjaysalazar added the enhancement New feature or request label May 5, 2023
@joshjaysalazar joshjaysalazar added this to the v0.1 milestone May 5, 2023
@joshjaysalazar joshjaysalazar changed the title Add a SystemResourceMonitor class Add a SystemMonitorOverlay class May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant