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.5.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.5-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygameFPS-1.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 adbab5f7bb3b70a7c9a6e87d4313abdeee01fef331889f2d53191498d791226d
MD5 8ff6ff477ff7a2cbca9f0902039b3307
BLAKE2b-256 520af8e061d1eea452310325a1f6d52ae822ce41c541e7a4f00cc64051575840

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygameFPS-1.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cb3b02a0834b05d8b55d90a6ae5f65c8bb101638da0f5961d9dee7c820aa5f63
MD5 552fd049fbf68489b751914345359d8b
BLAKE2b-256 c21369edfa10c085e08c6f1829a5cb12b2877de5b7d41e57e7f167c771edde03

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