What happens during Alt-tab?

BlitzPlus Forums/BlitzPlus Programming/What happens during Alt-tab?

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.

Actually I was mistaken. I'm getting weird behavior. The game does seem to continue in the background, but not in a normal manner.

For example, if I fire a bullet, alt tab out of the app for a moment, and then return to it, the bullet's direction is often reversed, as if it bounced off a wall and came straight back at me. But when bullets bounce off the walls in my game, they don't come straight back at you, they ricochet off at an angle like a pool ball.

So something funky is going on.

Maybe the gameplay stops but the timer continues, and this causes weird glitches in my physics code. Though I don't see how a frame time of over a second would cause a glitch like this.

I guess it's back to using my own custom alt-tab code. I just removed it yesterday because I thought Blitz had gotten it's act together on alt-tab. The game should stop completely when you alt-tab out of it in full screen. That includes the timer incrementing.

If (KeyDown(KEY_LEFTALT) Or KeyDown(KEY_RIGHTALT)) And KeyDown(KEY_TAB) Then Stop

The above code doesn't stop the timer from incrementing, but it does stop everything else. The timer is internal to windows, and special code would need to handle storing and restoring the value when the game is alt tabbed out of. Or you would need to skip a frame when you return to the game.

Actually perhaps if I just moved the alt tab code to another part of my main loop between the end of the last frame, and the storing of the time the last frame finished rendering at... Hm.

Argh. I just did another test. It seems like my own custom code won't be called at all if I alt-tab out of the game! So I can't do this to solve the problem:

			If (KeyDown(KEY_LEFTALT) Or KeyDown(KEY_RIGHTALT)) And KeyDown(KEY_TAB) 
			
				; Stop app.
				Stop
			
				; Reset timer.  Do nothing for first frame after returning from alt-tab.
				Current_Time    = MilliSecs()
				Time_Delta      = 0
				Time_Old		= Current_Time
				Time_Delta_Sec# = 0
			 
			EndIf



The code will never get executed. Blitz steals the alt-tab input from me. Ugh. Well this is stupid. I would rather Blitz force me to write my own alt-tab code than behave like this. If it behaves this way EVERY game will break. At least if Mark did nothing then properly coded games won't break on return from alt-tab. Is Mark considering alt-tabbing out as more important than the game working when you return to the game?