Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Timer

Credits go to ReyBrujo for helping out!
This thread is locked; no one can reply to it. rss feed Print
Timer
Rick
Member #3,572
June 2003
avatar

install_int(GodClock, 1);

This statment makes the timer get called every millisecond right? There are 1000 milliseconds in a second right? So if I want to say simulate a year to equal 30 seconds, I could take

(int)CurrentTime/30000

This would give me the year rught? Doesn't seem to work.

[EDIT]
It's in windowed mode, and it like I have to alt-tab back and forth for it to update.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

ReyBrujo
Moderator
January 2001
avatar

What is CurrentTime? How you got it? With time?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Rick
Member #3,572
June 2003
avatar

Actually I would open the windows clock to time when the year changed. But turns out the timer doesn't run when that window isn't the active window. So it works as long as it's the active window. I didn't know that.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

ReyBrujo
Moderator
January 2001
avatar

Have you tried set_display_switch_mode(SWITCH_BACKGROUND) at the begining of your program, to keep the program running when not with focus?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Rick
Member #3,572
June 2003
avatar

Never used that before. I'll give that a try.

[EDIT]
Didn't work

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

ReyBrujo
Moderator
January 2001
avatar

Then try SWITCH_BACKAMNESIA instead of the other. Let me see if I understand: You have your application running in a window. And it works only when the window has focus, when you give focus to something else, it loses it and the program stops, right?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Rick
Member #3,572
June 2003
avatar

That's what I'm thinking? I display the timer, and when someother window has focus the timer stops.

[EDIT]
That didn't work either. Where should that function be called? I put it right after allegro_init()

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

ReyBrujo
Moderator
January 2001
avatar

For Windows, use set_display_switch_mode(SWITCH_BACKGROUND), but call it AFTER setting the graphic mode.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Rick
Member #3,572
June 2003
avatar

perfect, thank you.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Kitty Cat
Member #2,815
October 2002
avatar

For optimal results, you should do:

if(set_display_switch_mode(SWITCH_BACKAMNESIA) == -1)
    set_display_switch_mode(SWITCH_BACKGROUND);

In Windows, fullscreen modes will only work in the background with BACKAMNESIA, while windowed modes will only work with BACKGROUND. I'm not sure, but I think there was talk about making BACKAMNESIA fall back onto BACKGROUND for newer Allegro versions (since it doesn't break anything by using BACKGROUND when BACKAMNESIA is requested). I'll have to ask about that.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Go to: