Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Baklazhan, Ayumi, Hanky27), 1,348 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
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 Offline OP
Serious User
Lion_Ts  Offline 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] #54548
09/09/05 17:28
09/09/05 17:28
Joined: Oct 2002
Posts: 4,753
Munich, Bavaria, South of Germ...
TripleX Offline
Expert
TripleX  Offline
Expert

Joined: Oct 2002
Posts: 4,753
Munich, Bavaria, South of Germ...
thanks a lot! Interesting tricks... I'll try it out today evening!
If this is true it should belong to the wiki

Re: Tips and Tricks - ALT+TAB and CPU usage [Re: TripleX] #54549
09/09/05 17:52
09/09/05 17:52
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline OP
Serious User
Lion_Ts  Offline OP
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
It's true. I'm playing with this, when think: "what exceccive task do it with my cpu, when I'm in IDE ?". Then I tried to disable camera and framerate - that's it ! It's useful for windowed mode with automatic game pausing when task swiched, I think.

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 Offline
User
FRAJO  Offline
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
F
fogman Offline
Expert
fogman  Offline
Expert
F

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 Offline OP
Serious User
Lion_Ts  Offline 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: Lion_Ts] #54553
09/09/05 20:20
09/09/05 20:20
Joined: Oct 2002
Posts: 4,753
Munich, Bavaria, South of Germ...
TripleX Offline
Expert
TripleX  Offline
Expert

Joined: Oct 2002
Posts: 4,753
Munich, Bavaria, South of Germ...
nope the most people havn't cared about the cpu usage if windows_focus is 0

By the way, it works. thy

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 Offline
Senior Member
Mr Wurm  Offline
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 Offline OP
Serious User
Lion_Ts  Offline 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 Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
wow, nice code comes very handy ^^


"Yesterday was once today's tomorrow."
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1