So I had another epiphany. Thinking outside the box again.
GM custom is to put all code in the Create Event, Step Event, and Draw Event. If you want it to run when the object is created, CREATE EVENT. When you want it to run every step, STEP EVENT. When you want it to display something, DRAW EVENT. Have collisions? Use the Collision With events or place_meeting() or place_empty(). Blah blah blah.
Question: How do you pause the game? Go to another room? Deactivate all instances? Put a "if pause=true exit;" call in every Step Event? How do you prevent animation during pause? So many things to consider.
Now what if you put all Step Event code in the User Event 0 for each object? How would GM be able to run it, then? Only one object in the whole room would have a Step Event -- the controller object -- and in it you'd check for any pause variables then, if the game isn't paused, call this:
if !pause
with all
event_perform(ev_user,0)
The pause variable only gets checked once per step, rather than once per instance. It should speed up your game a tad.
The nice thing about this is suppose you want some objects to perform different actions depending on certain states of the game? You could put that code in a different User Event and perform it as needed. If an object doesn't have the specified User Event, GM just skips over it (well, it breaks, but that's close enough).
I just wish there was a way to disable automatic image_speed handling.
No comments:
Post a Comment