Hi everyone,

I have a main Draw method that calls various Draw methods inside my classes i.e.

protected override void Draw(GameTime gameTime)





I also have a main Update method that does a similar thing. My problem is that it would seem my Draw methods are being called DURING my Update method. The reason I think this is that my ball Update method moves my ball but at the end of the update, if the ball is colliding with my paddle, it will move its position back. This is all done during one update method so, in theory, after each Update call the ball will never be colliding with the paddle.

I am sometimes seeing the ball colliding with the paddle as if the Draw had been called half way through the Update method after it has been moved at the start of the method but before it has been moved back at the end.

Is this possible and what can I do to resolve it


Re: XNA Game Studio Express Can Draw() be called halfway though Update()


I'm sorry, please ignore my stupidity. It's funny how you only realise something when you ask someone else! I was not taking into account the height of the ball when checking the collision with the paddle which is why it was sneaking inside.

If someone could give closure on the Draw - Update execution that would still be useful though, i.e. are they discreet from each other.

Re: XNA Game Studio Express Can Draw() be called halfway though Update()

Derek Nedelman

Yes, your updating and drawing should take place separately.

Re: XNA Game Studio Express Can Draw() be called halfway though Update()

Jon Watte

The framework will make sure that your Update() gets called at the fixed frequency you specify. With whatever time left over, it will call Draw(). Thus, Draw() may be called more or less often than Update(). The look conceptually looks something like:

lastTime = now();
while (running) {
curTime = now();
while (curTime >= lastTime + updateDelta) {
curTime += updateDelta;

There are some additional gnarls to deal with the case that you will always get a Draw() once in a while, and detecting that Update() runs slow, but that's the gist of it.