|
Tips and Tricks - ALT+TAB and CPU usage
#54547
09/09/05 17:09
09/09/05 17:09
|
Joined: Aug 2005
Posts: 1,185 Ukraine
Lion_Ts
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,185
Ukraine
|
Hi! Look at this: No game pausing: cpu usage ~97% Freezing funcs only: cpu usage ~60% Code:
var wndf=0; starter pause_game_at_alt_tab() //pause game on loose focus { while (1) { if (window_focus == 0){ if (!wndf){ wndf=1; // camera.visible=off; // fps_max=4; freeze_mode = 1; } }else{ if (wndf){ freeze_mode = 0; // fps_max=40; // camera.visible=on; wndf=0; } } wait(1); } }
restrict fps: cpu usage ~7% Code:
var wndf=0; starter pause_game_at_alt_tab() //pause game on loose focus { while (1) { if (window_focus == 0){ if (!wndf){ wndf=1; // camera.visible=off; fps_max=4; freeze_mode = 1; } }else{ if (wndf){ freeze_mode = 0; fps_max=40; // camera.visible=on; wndf=0; } } wait(1); } }
disable camera: cpu usage ~0% !Code:
var wndf=0; starter pause_game_at_alt_tab() //pause game on loose focus { while (1) { if (window_focus == 0){ if (!wndf){ wndf=1; camera.visible=off; fps_max=4; freeze_mode = 1; } }else{ if (wndf){ freeze_mode = 0; fps_max=40; camera.visible=on; wndf=0; } } wait(1); } }
Ok, if you read this, you understand now, for low cpu usage catch loose focus event and disable your camera.
|
|
|
Re: Tips and Tricks - ALT+TAB and CPU usage
[Re: Lion_Ts]
#54550
09/09/05 17:59
09/09/05 17:59
|
Joined: Mar 2003
Posts: 569
FRAJO
User
|
User
Joined: Mar 2003
Posts: 569
|
Cool. I'll integrate it in my game!
-------------------------------------------
ICQ: 242543712
Ich bin nicht hier und bin nicht da.
Wo bin ich dann?
".."
("")
^ ^
This is the evil vampire bunny. Copy and paste him into your signiture to help him achieve world domination. Yeah
|
|
|
Re: Tips and Tricks - ALT+TAB and CPU usage
[Re: FRAJO]
#54551
09/09/05 18:06
09/09/05 18:06
|
Joined: Apr 2005
Posts: 4,506 Germany
fogman
Expert
|
Expert
Joined: Apr 2005
Posts: 4,506
Germany
|
Jep, useful codesnippet. Very short and easy, itīs strange that no one had this idea before. Congratulations
no science involved
|
|
|
Re: Tips and Tricks - ALT+TAB and CPU usage
[Re: fogman]
#54552
09/09/05 18:18
09/09/05 18:18
|
Joined: Aug 2005
Posts: 1,185 Ukraine
Lion_Ts
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,185
Ukraine
|
Quote:
Jep, useful codesnippet. Very short and easy, itīs strange that no one had this idea before. Congratulations
I think many people has this code, but may be they just forget to post this one ?
|
|
|
Re: Tips and Tricks - ALT+TAB and CPU usage
[Re: TripleX]
#54554
09/10/05 12:30
09/10/05 12:30
|
Joined: Jul 2002
Posts: 446 Switzerland
Mr Wurm
Senior Member
|
Senior Member
Joined: Jul 2002
Posts: 446
Switzerland
|
Yep, I for one knew about that one, used it when I got so few frames in the menu, navigating with a mouse pointer was a pain in the ... . Disabling the camera, since the view was covered anyways was a lifesaver there.
- Mr Wurm
|
|
|
Re: Tips and Tricks - ALT+TAB and CPU usage
[Re: TripleX]
#54555
09/10/05 18:09
09/10/05 18:09
|
Joined: Aug 2005
Posts: 1,185 Ukraine
Lion_Ts
OP
Serious User
|
OP
Serious User
Joined: Aug 2005
Posts: 1,185
Ukraine
|
Quote:
nope the most people havn't cared about the cpu usage if windows_focus is 0 By the way, it works. thy
Thank you, TripleX, for compliment.
|
|
|
Re: Tips and Tricks - ALT+TAB and CPU usage
[Re: Lion_Ts]
#54556
09/12/05 07:22
09/12/05 07:22
|
Joined: Apr 2005
Posts: 3,815 Finland
Inestical
Rabbit Developer
|
Rabbit Developer
Joined: Apr 2005
Posts: 3,815
Finland
|
wow, nice code comes very handy ^^
"Yesterday was once today's tomorrow."
|
|
|
|