Graphics refresh - best practise?

BlitzMax Forums/BlitzMax Beginners Area/Graphics refresh - best practise?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yep - this was a rubbish way of trying to get my problem across - apologies to all. I think I just have badly structured code and too much is happening in each iteration of the main loop.

What was happening was that originally all the graphics refreshed each iteration of the main loop, but the main loop is too slow to make my special effect work properly, so the special effect had a jerky look to it.

So what I wanted to do was to somehow have a loop within the main loop that handled the special effect idependantly - something like...

	For Local i# = 0.1 To 1 Step 0.01 
		
		varScale :+ i# / 500
		varAlpha :+ i# / 50
		tBonusFoul.ScaleAndFade(varScale,varAlpha)
		
		Flip
		Cls
		
	Next


...where the ScaleAndFade method redraws the bonus image using the new new scale and alpha.

But having the flip and cls in this inner loop (as well as in the outer main loop) mucks up all of the rest of the graphics since they haven't been drawn to the back screen.

So my issue really related to having multiple Flips and Cls's in the code.

I guess my poorly structured code really needs to be amended so that in the main loop, if the bonus is being displayed, only this - and the other draw commands should be executed in that iteration.

So then I thought well what is the best way of doing this? How do I make sure that the main loop only executes the minimum amount of code and still draws all the images to the screen; and is there a 'best practise way of coding this?

Should there be a call to a function within this example code above - where the function draws all the other required items to the screen? This would prevent all the rest of the main loop having to execute and should speed the special effect 'animation' up?

Anyway - I think maybe I need to look at how my code is structured (I have spent so much time trying to get a handle on the syntax for this new - to me - language, that I have not paid any attention to how I am structuring my code, which is probably where the problem lies).

Hopefully this makes things a little clearer to everyone, and apologies again to those who have tried to struggle vainly through my ramblings in an effort to help me out.