|
AllegroTimer Class trouble |
iLSILENT
Member #7,617
August 2006
|
hi to all! I'm trying to organize the allegro timer in an unique class in order to speed up programming with allegro. the target is: create a class so i just have to instantiate an AllegroTimer object in main like this: I declared static the IncSpeedCounter method and the speed_counter property to get rid of the function pointer requested by install_int_ex, but when i try to instantiate an object of this class the compiler can't misteriously resolve some links. I'm using VC++8 and don't know if with other compilers this will work instead. Suggestions, changes to the codes, ideas...are all welcome. Tnx! This is the class:
|
CGamesPlay
Member #2,559
July 2002
|
Quote: I'm dumb! so i don't know if this can be accomplished in a easier and more convenient way. At least you're honest First, please read this and use [code] tags. About the code: IIRC one may only have one timer interrupt per function. However, you may use the install_param_int_ex function to have mulitples, just use the this variable as the parameter. You will need to use an instance member (not a static member) to store the speed_counter, otherwise you will only be able to have one instance. -- Ryan Patterson - <http://cgamesplay.com/> |
Kitty Cat
Member #2,815
October 2002
|
If you're using a class to run as a timer, you may want to think about using methods other than Allegro's timers, as they're rather innaccurate. For example, this timer class I have runs off gettimeofday on most systems, or timeGetTime on Windows (which is a bit more accurate than Allegro's timers). I could use QueryPerformanceFrequency/Counter, but I've been lazy on properly using the LARGE_INTGETER type.
The init() method is used to start it ticking the specified amount of times per second. The reset() method is for if you've neglected to read the ticks and don't want to deal with a jump in time (like after pausing, or switching levels or something). The get_tics method returns the the number of times it's ticked since the last call, and optionally storing the total number of times it's ticked in the supplied unsigned long variable. The rewind ticks method is used if you want to back up, say after getting an unexpectedly large return value from get_tics and not wanting to handle them all right now, or if you want to fully reset the timer to 0 (along with calling the reset method). -- |
iLSILENT
Member #7,617
August 2006
|
thank you for your replies! |
CGamesPlay
Member #2,559
July 2002
|
Any time you type I'm dumb! in this forum, it is converted to "I'm dumb!". Never, ever, use the expression 'I'm dumb!'. It is terrible and will make everyone respectable hate you Anyways, it was just terribly appropriate -- Ryan Patterson - <http://cgamesplay.com/> |
Richard Phipps
Member #1,632
November 2001
|
iLSILENT
Member #7,617
August 2006
|
eheheheh! post continued: ok, thanks for the help. i made it up with another timer class (quite good)
see ya! |
Audric
Member #907
January 2001
|
[OT]CGamesPlay, how did YOU manage to write it then? Even |o| is not quite the same...[/OT] |
CGamesPlay
Member #2,559
July 2002
|
If you take your member number and multiply it by two, then add 1000, then multiply this number by 3, then add 45 thousand, divide the whole thing by 6, and finally subtract 3738 plus your member number, you get your "censorship index" (I don't remember what exactly the moderator called it). Basically, if this number is within 3354 of your member number, you can use that phrase and all manner of swear words without being censored. The formula, once again: [append] This is actually only a linear approximation of the actual formula. Admittedly, the real formula is simpler, but requires trigonometry, so I didn't post it. But this one works for most users. -- Ryan Patterson - <http://cgamesplay.com/> |
Jakub Wasilewski
Member #3,653
June 2003
|
Or, if you are one of the unfortunate users whose swearword index is bigger than 3354, you could try using empty i or b markers to break the word in two parts. But that's for sissies. Real men just register accounts until they get a preferable swearword index. --------------------------- |
|