ID:173889
 
I was wondering what cause's lag in a game? Like is it map size, amount of code or Proc usage. The computer part of it doesnt bug me. But what about gif's. Anyway I'm asking because my game(Battle of Evermore) is getting pretty big map and code wise. Is there anything you guys can think of that would help stop lag, it even lags on my comp =(.. It's hard to make a really in depth world when theres all this lag, I made a shadow night and day code but I can't use it cus my maps are to big and it stalled my comp for a few seconds and then the entire world got dark and player icons then reverse but the 4-5 seconds it takes to make each change is pretty stupid so I scraped it.
Try spawning the procedures if they take too long, and put some time in between executions.
In response to Yota
As in the proc spawn? If thats so whats that have to do with lag? And if your taking about the shadow/night code that still wouldn't help because its the code that lags not the order its done in, but thanks.

~Hendix~
In response to HendrixandCamo
Using spawn() can help in some situations, but probably not in this one.

Excessive CPU lag (as opposed to network lag, which you don't get when you're the host) is usually due to inefficient loops. If you have a lot of loops, optimise them as much as you can.

One of the worst things is having a lot of objects, each of which starts off its own loop. AI procs, for example, are common offenders.
In response to Crispy
Well god damn, obj's are bad you say =( I mean lots of them.. 1/3 or my map is obj's and I have 20 z's and 50x50. I have tree's on all my borders and I have when so they change pixel_y and x a little bit to make it look more "natural" I can't change them as turf because they link to the turf below them. Well I have 3k+monsters looping to I was thinking about making it so that a mob activates them insted of a loop. Oh I know how to use spawn but it still doesn't make sence how that would help lag. But its all good thanks.
In response to Hendrix
spawn() helps against lag because it lets code continue past it, so the CPU can continue other instructions, saving itself from an unbreakable loop taking up all CPU time. Or summat.
In response to Hazman
I said to use spawn because I believe the lag is just the procedure waiting to finish and continue with the rest of the prosessing. If you spawn the procedure, it can process while it's calulating the shadows, etc.