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
#5
I did originally use time.delay to slow down the game, but that caused input lag, which was fixed when I changed the code to instead reduce the framerate. And I needed to set the framerate that low just to keep the program from running insanely fast. I am running this on a high-end gaming pc, as I've already stated. Not having any kind of limit just made the program way too fast to play. Honestly, even that low of a framerate is a bit fast for me.

As for my code, I've been figuring out pygame on my own. I do have a degree in programming (complete with a certificate in python), but my college doesn't offer a class in pygame. Well, it didn't when I attended anyway. My old professor gave me a pdf file that he was planning on using for a game course he's developing. I've actually been looking at it to figure out how to optimize my program. That's where I got the framerate code from btw.

Sadly, I've never seen how someone else handles multiple screens; I just came up with something on my own. It does work so I never saw a point in figuring out another way to do it. And no, I'm not that experienced when it comes to making classes. When I was taking my python courses, honestly, I never really did get an understanding of them. Even now, to me they're just something you use to create custom modules.

And my professor told me once that python may honestly not be an ideal language for me. He suggested that I should use C++, c#, or java. I have certificates in c++14 and java, but I've never seen this c#. The C language also looks interesting to me, but it appears to be obsolete.

Come to think of it, I COULD condense all those while loops into one by using if-then statements. Have a variable that tracks which screen should be active (title, main, loss, win, playAgain), and then just use if-statements to have the program draw different screens depending on the state. I don't see how I could remove all the loops though. The frandxy (which sets the x,y coordinates of the 'food') has to have a do-while loop to work. Before I did that, I had a bug where the game would sometimes spawn in the food on top of the snake, which became increasingly common as the snake got longer.


Messages In This Thread
RE: Why do my sound effects always have a slight delay in them? - by xBlackHeartx - Sep-27-2019, 12:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Laggy Game Movement game_slayer_99 12 4,606 Oct-05-2022, 11:34 AM
Last Post: metulburr
Music [PyGame] Chopper wash effect efficiency questions. michael1789 9 4,558 Jan-19-2021, 07:12 PM
Last Post: michael1789
  Appropriately delay this PyGame code kleynah22 2 4,435 Nov-09-2017, 02:00 PM
Last Post: Windspar
  [PyGame] My program is very laggy GamePlanet 6 7,157 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