2

I recently wrote my first pygame program and am working on a second, and discovered an issue with running the program. I use the editor MuEditor for Python 3.8.6, and when I run the game using this editor it works exactly how I want it to. Although, if I run the program from ANY other editor such as IDLE or PyCharm, it ramps up the game speed and displays the fonts incorrectly, making the game much more difficult to play. My friend wants to be able to play the games I write, so I sent him the code through an email and they ran it through MuEditor, and it still worked incorrectly. The game only runs how it should when I run it from my computer in MuEditor, and I was wondering if anyone else has had this problem or if there's a fix for it? I highly doubt the error here is in my code, but I can provide it if necessary.

1
  • I am a new user, so I don't have enough reputation to comment. I will try to fit all my possible ideas in this post: 1. Are they using the same python version? It might cause some weird errors if they are not. 2. Are they using the same pygame version? There might be some bugs in different versions. 3. What are their errors? This could be very important in solving the problem. I apologize for not commenting on this but I don't have 50 reputations. I hope this will help you solve your problem! Commented Dec 13, 2020 at 9:52

1 Answer 1

2

Use pygame.time.Clock to control the frames per second and thus the game speed. See pygame.time.Clock.tick():

This method should be called once per frame. It will compute how many milliseconds have passed since the previous call.

The method tick() of a pygame.time.Clock object, delays the game in that way, that every iteration of the loop consumes the same period of time.

That means that the loop:

clock = pygame.time.Clock()
run = True
while run:
   clock.tick(60)

runs 60 times per second.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the suggestion with the clock, it helped out a good amount. Although, I implemented this and still have a small issue with the game speed, as well as all the fonts still being displayed as the default even though I use pygame.font.SysFont()and display these multiple times.
@bperry14 If you have a "small issue with the game speed", there is a minor bug or inaccuracy in your application. It seems that the chosen font is not available on other systems.
I assumed that the system might not have the same fonts as mine, but the main font I'm trying to use is Times New Roman, and I would think a common font like this should be there.
@bperry14 I don't know and I don't want to know. I'm annoyed by system dependencies. But as far as I know, Times New Roman is a Windows font.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.