Merge branch 'fps' into 'master'

Fps

See merge request !3
This commit is contained in:
Moris Krajnc 2020-07-16 10:59:20 +02:00
commit 76f307541b
2 changed files with 38 additions and 9 deletions

27
fps_counter.py Normal file
View File

@ -0,0 +1,27 @@
import sys
import pygame as pg
def main():
pg.init()
screen = pg.display.set_mode((320, 240))
font = pg.font.Font(None, 30)
clock = pg.time.Clock()
done = False
while not done:
for event in pg.event.get():
if event.type == pg.QUIT:
done = True
screen.fill(pg.Color('black'))
fps = font.render(str(int(clock.get_fps())), True, pg.Color('white'))
screen.blit(fps, (50, 50))
pg.display.flip()
clock.tick(30)
pg.quit()
sys.exit()
if __name__ == "__main__":
main()

View File

@ -295,6 +295,7 @@ logoff_sound = pygame.mixer.Sound('snd/winxplogoff.wav')
pygame_font_1 = pygame.font.Font('freesansbold.ttf', 90) pygame_font_1 = pygame.font.Font('freesansbold.ttf', 90)
pygame_font_2 = pygame.font.Font('freesansbold.ttf', 65) pygame_font_2 = pygame.font.Font('freesansbold.ttf', 65)
pygame_font_3 = pygame.font.Font('freesansbold.ttf', 45) pygame_font_3 = pygame.font.Font('freesansbold.ttf', 45)
pygame_font_4 = pygame.font.Font('freesansbold.ttf', 16)
# colors # colors
pygame_color_green = pygame.Color(42, 217, 13) pygame_color_green = pygame.Color(42, 217, 13)
@ -636,17 +637,17 @@ screen = pygame.display.set_mode((screen_size_x, screen_size_y), pygame.FULLSCRE
# define image variables # define image variables
img_itlablogo = 'img/itlablogo.png' img_itlablogo = 'img/itlablogo.png'
img_itlablogo_image = pygame.image.load(img_itlablogo) img_itlablogo_image = pygame.image.load(img_itlablogo).convert_alpha()
img_itlablogo_imagex = get_image_width(img_itlablogo) img_itlablogo_imagex = get_image_width(img_itlablogo)
img_itlablogo_imagey = get_image_height(img_itlablogo) img_itlablogo_imagey = get_image_height(img_itlablogo)
img_metalliclogo = 'img/metalliclogo.png' img_metalliclogo = 'img/metalliclogo.png'
img_metalliclogo_image = pygame.image.load(img_metalliclogo) img_metalliclogo_image = pygame.image.load(img_metalliclogo).convert_alpha()
img_metalliclogo_imagex = get_image_width(img_metalliclogo) img_metalliclogo_imagex = get_image_width(img_metalliclogo)
img_metalliclogo_imagey = get_image_height(img_metalliclogo) img_metalliclogo_imagey = get_image_height(img_metalliclogo)
img_background = 'img/bg.jpg' img_background = 'img/bg.jpg'
img_background_image = pygame.image.load(img_background) img_background_image = pygame.image.load(img_background).convert()
img_background_imagex = get_image_width(img_background) img_background_imagex = get_image_width(img_background)
img_background_imagey = get_image_height(img_background) img_background_imagey = get_image_height(img_background)
@ -793,8 +794,9 @@ while True:
screen.blit(time_surface, time_rectangle) #time screen.blit(time_surface, time_rectangle) #time
screen.blit(header_surface, header_rectangle) #header screen.blit(header_surface, header_rectangle) #header
# display everything
#pygame.display.flip() fps = pygame_font_4.render(str(int(pygame_clock.get_fps())), True, pygame.Color('white'))
screen.blit(fps, (50, 50))
# if another push of start is detected (i.e. the game is ending!) # if another push of start is detected (i.e. the game is ending!)
if not GPIO.input(pin_stop): if not GPIO.input(pin_stop):