Python Forum
[PyGame] sound effect delay and program laggy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] sound effect delay and program laggy
#4
Damn.... i just wrote a whole post here and accidentally deleted it all before posting. I dont really want to spend another 20 minutes rewriting that again...sorry.

quick rundown:
A) There are a few bottlenecks. In each while loop you have render font that is static text unnecessarily.
B) You should avoid nested while loops to implement game states as it causes spaghetti code and camouflage bugs. Its more sane to create a state machine to organize your code.
C) Are you intending on it moving on a block by block basis or per pixel? Just saw that you shrunk FPS drastically
D) You can use github for sharing programs with resources.
E) Always set your FPS to 60. Do not reduce that to reduce speed. If you need to reduce its speed movement then you need to use time. The first example does this but you dont want every second, probably every millisecond, and "do something" is move. In your case you are going to up your FPS to 60 and slow the snake down to whatever you want. The longer delay, the slower it goes. Aside form that you can also do delta time movement.

You would also make it a lot easier on yourself and others if you used classes. For example the snake should be a class, with all its drawing in it, logic in it, data in it, collisions in it, etc.
Recommended Tutorials:


Messages In This Thread
RE: Why do my sound effects always have a slight delay in them? - by metulburr - Sep-26-2019, 11:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Laggy Game Movement game_slayer_99 12 4,550 Oct-05-2022, 11:34 AM
Last Post: metulburr
Music [PyGame] Chopper wash effect efficiency questions. michael1789 9 4,531 Jan-19-2021, 07:12 PM
Last Post: michael1789
  Appropriately delay this PyGame code kleynah22 2 4,425 Nov-09-2017, 02:00 PM
Last Post: Windspar
  [PyGame] My program is very laggy GamePlanet 6 7,128 Aug-15-2017, 03:00 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020