Engine.Update / Engine.Draw, am I forced to use this pattern?

I like to have a lot of control over my setup. It seems like monogame wants me to use the Update / Draw pattern, as in call Update on all game entities, and call Draw on all entities. Is there anything forcing me to follow this, as in will anything break if I just run everything out of Update and forego calling anything in Draw at all?

I notice if I comment out base.Update(gameTime) inside of Update and base.Draw(gameTime) inside of Draw it seems to have no effect on my game at all. I have also made Draw almost entirely empty and it seems to also have no effect on my game at all, so everything seems fine just running the Update function.

I just want to make sure there is nothing hidden here that will bite me long term. Not using the Draw function is just my personal preference (I come from SDL land, where you have a lot of control over the flow of how you structure things).

I’ve seem somewhat similar questions, but the answers weren’t conclusive. Some said “You should follow this pattern”, but what I’m asking if I must follow this pattern. Thanks in advance.

Hi @Will_Jameson and Welcome to the Forums,

You can code as you wish, you can inherit from the Game class and create your own methods.

Happy Coding!

Ok Thanks for the fast response MrValentine. I was assuming it would be OK to do because I am doing it now and everything seems to be working fine.

1 Like

There is a reason that xna designed the frame loop with both update and draw as well as why others do.

It basically allows you to ensure that you can keep consistent timing in at least one method when that is absolutely needed.

It means you can differentiate (if you code properly) between being cpu bound or gpu bound quickly which is difficult to figure out in other ways.

It lets your ui cope with the situation when you are lagging so that it doesn’t become unresponsive or become tied to the lag and become unpredictable.

1 Like

If MG won’t bite you in the ass, your own code will. Separate your game logic and rendering, it is very important just for the code readability. Plus, Draw() will actually drop frames if you put way too much load on the game, which is probably better than clogging up Update and forcing the framerate to drop even lower.

I also was in the “put everything in Draw” camp, no fun there.

2 Likes

Okay I’ll split up my Update and Draw methods. It’s probably better to use it the way it was designed to be used.

1 Like

Another one saved it seems. :ok_hand:

1 Like

I’m just here to emphasize this some more.

1 Like