Custom Game_Event code lags too much! - Printable Version +- Save-Point (https://www.save-point.org) +-- Forum: Games Development (https://www.save-point.org/forum-4.html) +--- Forum: Code Support (https://www.save-point.org/forum-20.html) +--- Thread: Custom Game_Event code lags too much! (/thread-4711.html) |
Custom Game_Event code lags too much! - MechanicalPen - 06-26-2013 I've been bolting on custom features (party members follow the player as events, and enemy line of sight detection) and now my game lags! Anyone good at improving performance, or have any suggestions on how to move the code into the events themselves? I hadn't tried that option because I want the player to still be able to talk to these events so I can't run it as 'Parallel Process" Here is the update method giving me trouble: Code: #------------------------------------------------------------------------ EDIT: So, I feel silly. It turned out my lag issues were caused by a runaway HUD window updating every frame. So instead maybe you guys have tips on how to profile RGSS code or tips on how to prevent lag. RE: Custom Game_Event code lags too much! - DerVVulfman - 06-26-2013 Reading... "It turns out my lag ussues were caused by a runaway HUD window updating every frame."...... Basically, You can find what I'm describing in the hud script for my Lycan ABS In the main hud window... 1) I Have a master update routine that: a) First does a check routine that only performs updates after x frames ( if Graphics.frame_count % 30 != 0) b) Same check routine sees if the current HP is the same as the last checked hp c) Same check routine sees if the current SP is the same as the .... Oh, you get the idea) 2) ONLY if the check routine says something is different.... refresh and update the rest of the window with the new data RE: Custom Game_Event code lags too much! - MechanicalPen - 06-26-2013 I was doing all of that except a). I also had some malfunctioning code meant to refresh it after a message_window is closed (because 19 year old me thought that since the message window overlapped the HUD, it would overwrite its pixels). But the HUD was redrawing whenever the message window wasn't visible, instead of when it was closed. It must have been like that since the very beginning of my project, but I only really noticed it when I tried adding text shadows to the HUD (Twice as many draw_text calls, twice as many lags) RE: Custom Game_Event code lags too much! - DerVVulfman - 06-27-2013 "But the HUD was redrawing whenever the message window wasn't visible, instead of when it was closed." Redrawing even when invisible.... Hmm... Didn't think about that in my hud code, though I did incorporate something to handle that in some other features. Have you thought about adding this BEFORE 'A' in my example? Code: return unless self.visible RE: Custom Game_Event code lags too much! - MechanicalPen - 06-27-2013 No, the HUD was redrawing when the MESSAGE WINDOW was invisible. Which is nearly all the time in a typical RPG Maker game. Either way it is fixed now, but I should look into Ruby profiling tools. They are built right into the language! |