I have made a countdown timer using C# on basic form window and i want it to appear on game screen i tried to set form properties but it wont work on game screen. how would it be done? Any Idea?
-
Do you mean you want it to always be on top, sort of like a fps counter. – The Muffin Man Nov 14 '10 at 07:52
-
@cdHowie: Game Screen Means during game play timer would also be on top. – Inv Xaasha Nov 14 '10 at 07:54
-
Right, but is this *your* game, or somebody else's game? – cdhowie Nov 14 '10 at 07:54
-
@cdHowie: No its not mine any third party game. – Inv Xaasha Nov 14 '10 at 07:55
-
1Since most games will switch to full-screen direct-render mode, this is not something you can do easily, especially not with Winforms. You are going to have to mess with DirectX/OpenGL at a very low level and hook into the game's buffer-switch call. – cdhowie Nov 14 '10 at 07:57
-
Oh k! so any other alternate or possibility ? – Inv Xaasha Nov 14 '10 at 08:00
-
The only example of such thing I've ever seen is Steam, and it hook with the game code in pretty low level so I fear you're at dead end here. Sorry for the bad news! – Shadow The GPT Wizard Nov 14 '10 at 08:23
2 Answers
If you are looking to draw a timer into an existing DirectX or OpenGL backed game then I suggest you take a look at the following question which offers information about hooking and the ability to intercept calls along with working with the applications draw calls. However I believe this is above the level of complexity you would wish to encounter for adding a timer.
As you don't indicate if you are using OpenGL, XNA or what I will give you a generic response.
If it is your game
Your splash screen should be part of the game loop. This means that will have an update() and a draw().
In the update method you have to calculate the remaining time and store it in a variable or property of an object.
In the draw method you should paint the remaining time.
My recommendation is that you create a TimeCounter class because seems you are also going to reuse it during game.
If it is not your game
Most games will switch to full-screen direct-render mode. It is not impossible but pretty hard.
If the game is web, then you can wrap it in IFrame or similar and put the counter

- 6,817
- 8
- 57
- 90