1

I just noticed that pygame rendering works so slow on OSX... I thought that the problem is in my code, but when I run the same code on windows it runs much faster.. (on OSX I get ~25fps, on windows ~1700)... Is there any way to speed up pygame on OSX? Or maybe I have to use other programming languages for creating nice and fast working games on OSX? And the sample code that I was using for this test...

import pygame
from pygame.locals import *
import time
import sys

pygame.init()
width = 28*40
height = 28*21
DISPLAYSURF = pygame.display.set_mode((width,height), DOUBLEBUF)
x, y = [0,0]
t = time.clock()
speed = [1,1]
while(True):
    pygame.draw.circle(DISPLAYSURF, (255,0,0), (x,y), 10)
    if x>width or x<0:
        speed[0]=-speed[0]
    if y>height or y<0:
        speed[1]=-speed[1]
    x+=speed[0]
    y+=speed[1]
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
    pygame.display.update()
    print(1/(time.clock()-t))
    t = time.clock()
Ruben Kostandyan
  • 321
  • 3
  • 12
  • Are the two FPS counts for Mac and Windows taken from the same computer on a dual-boot? If not, the spec difference between the machines could make a difference to the FPS. Admittedly, 25 FPS for something like this does seem a little too slow though. – Aaron Christiansen Mar 07 '18 at 08:40
  • The problem isn't only in FPS... The program visually works so slow on OSX... On windows it works so fast (again visually)... I use MBP 13' - 2017 – Ruben Kostandyan Mar 07 '18 at 08:46
  • Can you offer maybe other programming languages for making games for example?... I want to use my MBP for programming, because I can't always use the windows PC... – Ruben Kostandyan Mar 07 '18 at 08:48
  • And for counting FPS I use `print(1/(time.clock()-t))` as I showed in the code – Ruben Kostandyan Mar 07 '18 at 08:51
  • I would highly recommend Unity - it uses C# or JavaScript (your choice) as a programming language. Unity is used for many popular games, and there's a free edition. Godot is also worth a look. It's relatively new and supports 'GDScript', a modified version of Python, and also C#. – Aaron Christiansen Mar 07 '18 at 08:51
  • Wouldn't unity work slow on my MBP? (I think it is massive program..?) But thanks a lot, I'll try them and add my impressions as a comment to this post.... I still create 2D games (as an additional information, so if you can recommend other programming languages too, then welcome :) – Ruben Kostandyan Mar 07 '18 at 08:55
  • 1
    Try to use a pygame.time.Clock and its [`get_fps`](http://www.pygame.org/docs/ref/time.html#pygame.time.Clock.get_fps) method. – skrx Mar 07 '18 at 10:43
  • I did and got fps ~28-30 on OSX... – Ruben Kostandyan Mar 07 '18 at 11:31
  • If nobody has a clue, try to contact the devs via the [mailing list](https://www.pygame.org/wiki/info) or github. Also, don't ask us for recommendations about other languages, libraries or tools, since that's off-topic on Stack Overflow. – skrx Mar 08 '18 at 07:19
  • Maybe you can look at the [display.info](https://www.pygame.org/docs/ref/display.html#pygame.display.Info) to see what's different between your systems? Seems like your windows system is benefiting from some hardware acceleration. Are both of your pygame installations the same? – import random Mar 09 '18 at 06:06

0 Answers0