1

I was planning on making clones of simple 8-bit era games to start my 'career' in using pygame. I've almost finished my clone of snake. I was planning on putting these games on my laptop so I could play them on the go, but honestly, I don't know if the laptop could handle it.

While developing my snake clone, I noticed that the game would experience increasing lag as the game progressed. I was surprised at this, seeing as I'm running this on a high-end gaming computer. I determined the problem was that my algorithm for recording the snake's path (which I use for drawing the tail) was filling up insanely fast with coordinates. I fixed this by having the game only allow the list of coordinates to be as long as the snake's current length. This did a lot to fix the lag, but I still experience some slow down if I get the snake really long.

I don't understand why the game would lag on my computer just from a (relatively) small list of variables. This machine can run Skyrim on full graphics, yet it can't handle a game that uses over a few dozen variables? This has made me worried for my laptop, since, obviously that is NOT a gaming machine.

However, I have no clue how to determine if my laptop could run my game or not. Normally I just go to 'can you run it?' if I need to figure this out, but obviously I can't do that for my game. I don't know how to determine what kind of system a person would need to run any game I make. I wasn't expecting such primitive games to cause performance issues on my machine. I mean, if I can run Skyrim at full graphics, then why does my Snake game slow down as it progresses? It makes no sense. And I'm using pygame.draw for graphics, so I'm not having to load and draw proper sprites either. Honestly, the only game out there that's less graphics intensive than mine is pong. How could something so basic have issues on a modern gaming computer of all things?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • 1
    The only thing I can guess is that the problem is not the graphic, but something else which is consuming a lot of memory. Without looking at the code, is impossible to say anything more. Moreover, if you are looking for optimization, https://codereview.stackexchange.com may be a better place where to show your code. – Valentino Jul 30 '19 at 22:06
  • This question is about finding the system requirements for a program you make yourself, not whether or not my program is efficient or not. There isn't that much to it anyway. There's only 9 variables, plus that list which could theoretically have hundreds of entries stored (that would require for your snake to get quite long though). Also, the whole program is only 80 lines of code, so again, there isn't much to it. Even if the sole reason its that short is because I don't have a proper start menu, or have anything happen when you lose yet. –  Jul 31 '19 at 00:07
  • Variables are not the only thing you need to consider. In pygame, for example, if you redraw the whole screen each iteration of the main loop it will slow the game. You should redraw only the portion of the screen which is animated to have better performance. This consideration apart, I don't know how professionists test their program requisites. I guess they have testing suits to measure performances of their games. So I leave this considerations to experts. – Valentino Jul 31 '19 at 00:28
  • The lag vanished as soon as I limited how long the list could get. Its obvious that the increasingly long list of variables was enough to lag my game. As for the insensitive input, it probably a consequence of the fact that I have a delay of 100. Anything less felt too fast, which is why I won't change it despite the noticeable input delay it causes.And either way, your comments are off topic. I'm not asking why my program runs poorly, I'm asking how I could measure its system requirements to see if I could run it on my laptop. –  Jul 31 '19 at 20:01
  • I am voting to close this question as there is no [**Minimal**, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – Rabbid76 Jan 08 '21 at 09:23

0 Answers0