Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

What is the best way (tips) to eliminate game lag???

Hi people, I been making a game that's very 'custumized' and I been getting some lag problems. Like for example: sometime I dispose I picture and it stays on the screen for a couple more frames (seconds) that what is usual. Also, the FPS drop and fluctuate very badly. WHATS THE BEST WAY TO ELIMINATE LAG???

2 On a side note, does RGSS and RGSS2 differ much??

Thank YOu
 
Thanks, but this deals  with lag produced by too many events  in a map.
What im looking for is for tips for making my scripting more efficient.
For example: something that I noticed with RMXP is that the MORE LINES OF SCRIPT there are on the game THE MORE IT LAGS. Have anyone else noticed this???

Also, how can I make this more short:

if @a== 1 or @a== 2 or @a== 3 or @a == 4

p 'example'
end

is there a way to make this without repeting the '@a==' part everytime???

TU
 

khmp

Sponsor

kaB00M":vv5lqqtl said:
Thanks, but this deals  with lag produced by too many events  in a map.
What im looking for is for tips for making my scripting more efficient.
For example: something that I noticed with RMXP is that the MORE LINES OF SCRIPT there are on the game THE MORE IT LAGS. Have anyone else noticed this???

Also, how can I make this more short:

if @a== 1 or @a== 2 or @a== 3 or @a == 4

p 'example'
end

is there a way to make this without repeting the '@a==' part everytime???

TU

The only way to reduce event lag further than having an Anti-lag script is have less events. Or be smarter with what's necessary.

p 'wee' if 1..4 === @a
 

boon

Sponsor

kaB00M":a580p5w2 said:
Thanks, but this deals  with lag produced by too many events  in a map

That's what the scripts do...

Also, don't shove your game full of scripts you don't need. Organizing your scripts in the database can change so much in how it lags. GubiD's TBS has I don't know, over 1,500 lines of script and doesn't lag a bit. It's all to do with sequence.

"2 On a side note, does RGSS and RGSS2 differ much??"

Yes. A lot. For example, Scenes now correspond to Scene_Base whereas they used to stand alone. The whole scripting language is organized differently and more efficiently. The only reason I learn RGSS instead of RGSS2 is because of the lovely tileset editor in XP.

"something that I noticed with RMXP is that the MORE LINES OF SCRIPT there are on the game THE MORE IT LAGS. Have anyone else noticed this???"

It's like a car. The more stuff you shove in the car, the heavier the car gets. The slower it goes.
It's not just RMXP, it's any game system. RMVX Lags less because of it's efficiency.
 
Boonzeet":2bd3u7jo said:
kaB00M":2bd3u7jo said:
Thanks, but this deals  with lag produced by too many events  in a map



Also, don't shove your game full of scripts you don't need. Organizing your scripts in the database can change so much in how it lags. GubiD's TBS has I don't know, over 1,500 lines of script and doesn't lag a bit. It's all to do with sequence.

1.What do you mean by sequence: like for example: IF Script-B is used after Script-A, to put Script-B below Script-A

What I notice is that no matter if the script is used or not the game lags more. To test this I made a copy of exixting scripts in my game and then I changed the class name. Like for example: class Scene_Map. I made a copy and then I changed the name to: class Scene_nono. So this way THE WHOLE SCRIPT ISN't USED BY MY GAME, BUT IT STILLS LAGS THE GAME!!!
Is this really how it goes???

2. So the more lines the more lag??? So will this be 'wiser' to do this:

if @a == 1 : p 'd' end  *(and in this same line)* if @b == 7 : p 'f' end

Instead of...

if @a == 1 : p 'd' end 
if @b == 7 : p 'f' end

in 2 different lines???

I know this may sound simple to you, but Im a complete newbee. So when I asked FOR TIPS TO ELIMINATE GAME LAG, I was refering to tips(tutorials) on HOW TO BE AN EFFICIENT scripter in order to eliminate lag. Are there any tutorias IN RPMX.org or outside pages that deals with this?

Thank you and sorry if Im asking for too much.

@: khmp: Thank you so much.
 

khmp

Sponsor

In reference to more lines means more lag. Its absolutely true, the more lines of code that needs to be executed the amount of time increases as well. However I doubt that being able to fit a "n" line code block if placed into one line runs any differently or more efficient than its "n" line counterpart. The code is being interpreted the same. But as I am in most cases this is probably wrong or partly so. I'll try to find some proof to this. The most important thing is being able to distinguish how much work is being done in a line. Math.sin/cos/tan, drawing, spriting all expensive etc.
 
My father has been working as a programmer for years.  He's never worked with RUBY, although he does keep hearing the "young-bloods" touting it.

He told me recently that he once tested in several of the languages he does know whether there's a difference between using if/elsif/then and case/when for control structures.  In his experimentation, case/when came out on top for anything with two or more possibilities (if there was an else, it was better to do a case with two whens).  My question is...  does this apply to RUBY as well?
 

khmp

Sponsor

@kaB00M:

What's the question that this topic needed bumping. Its hard to siphon out what hasn't been answered?

If its still about lag. Avoid complex math, avoid tons of sprites and/or windows, have less events, one or less parallel process events. I really don't know any other ways to avoid lag.

I found this topic:
http://www.rmxp.org/forums/index.php?topic=43370.0

@DrakoShade:

I honestly don't know if if/elsif/then/end are slower than case statements. But Ruby is built on top of C. So I don't see why it wouldn't make sense for the same principles to be applied. I'm not sure how to implement a high frequency timer into Ruby either to check what is faster.
 
Well, I like to edit some scripts and I began to understand a little of ruby, though I don't know much. But here's what I know:

First, the more scripts you have, the more lag you get. That's probably because even if it isn't a valid Scene, the Interpreter has to check that script anyways. So use only the scripts you really need. (mainly for scripts that have update and alias command)

Second, Anti Lag is good, but it works by disabling updates of events that aren't on line of sight. So if you have an event that happens on the other side of the map, you'll have trouble. There's a script called "Event Spawner". Using a single event, on the script tag, you can create as many other events as you want, but you will have to write everything.
However, there will be almost no lag caused by events.

Third, I believe that the RPG Maker doesn't have the proper structure to handle much information. For example, I have GTA in my computer and I finished the game with almost no lag. But in RPG Maker, when I try to use an animation with many frames, the game crashes! So if you put too many resources in your game, you'll also get more lag.

About that problem you asked, I think it should be like this:

case @
when 1..4
p 'example'
end

don't know if will work though
These are just my opinion, I may be wrong, but I hope to be of help.
See ya!
 
Thank you very much.
I already changes some things in my scripts and the game is already running better.
For example, I changed a couple of individual 'ifs' to 'ifs + elsif's' and some 'ifs' to 'cases'. It does work.
Again, thank you to all :thumb:
Thanks for the link khmp. :thumb:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top