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.
2
votes
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!
- user14817070
1 Answers
2
votes
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.