Skip to main content

A package to show your fps in pygame

Project description

pygameFPS

A simple python package to show your fps in pygame

Example:

import pygame
import pygameFPS as fps
pygame.init()
screen = pygame.display.set_mode([500, 500])
running = True
pygame.init()
screen = pygame.display.set_mode((1280, 720))
pygame.display.set_caption('Graphing calculator')
clock = pygame.time.Clock()
maxFPS = 144
running = True

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

    fps.tick()
    # default rendering
    fps.render(screen)
    # custom args(surface, x, y, size, color)
    fps.render(screen, 50, 50, 24, (255, 255, 255))
    
    screen.fill("black")
    width = 1280
    height = 720
    colour = (255, 255, 255)
    font = pygame.font.SysFont(None, 24)
    img = font.render(f'FPS: {getFPS()}', True, colour)
    screen.blit(img, (20, 20))
    pygame.draw.line(screen, colour, (width / 2, 0), (width / 2, height), 3)
    pygame.draw.line(screen, colour, (0, height / 2), (width, height / 2), 3)

    for line in lines:
        if not line.getCalculated():
            line.calculate()
        x = line.x
        y = line.y
        x2 = line.x2
        y2 = line.y2
        half_width = width / 2
        half_height = height / 2
        pygame.draw.line(screen, colour, (half_width + x, half_height + y), (half_width + x2, half_height + y2), 3)

    pygame.display.flip()

    clock.tick(maxFPS)

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

pygameFPS-1.0.3.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

pygameFPS-1.0.3-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file pygameFPS-1.0.3.tar.gz.

File metadata

  • Download URL: pygameFPS-1.0.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pygameFPS-1.0.3.tar.gz
Algorithm Hash digest
SHA256 db994d71cd29cb883586291737f21370fd7090674fff68a389b4d7c7c4dda29a
MD5 41a893036fa24370bea77b9d65014ba1
BLAKE2b-256 61c576c4884430f848b8ed565f9bb4c8c197caf62edf8277c682e3b2ece1b70d

See more details on using hashes here.

File details

Details for the file pygameFPS-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pygameFPS-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pygameFPS-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 405ff220c62eca218f1ffc3ff53edfc91bda4f812ae17c3678fd530d65b2a810
MD5 f58e0bb36492f8dfbf37087cec0d58da
BLAKE2b-256 c6c8e20b0d546b06172c12caea2ed45236bda7113ccaaa60eb90051b21e9e138

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