|
This thread is locked; no one can reply to it. |
1
2
|
timing animation again |
William Labbett
Member #4,486
March 2004
|
Quote: William, since your animation is still running slower than it seems it should be, please show us more code, specifically all that relates to the logical processing and the struct you're using for your hero object. Sure thing. I'll post my main() aswell :-
That's my logic loop. Please forgive the crazy commenting. The hero struct is :
not all it's members are still in use but I've not gotten around to fleecing it yet. This function :-
sets things up. Really appreciate your willingness to help. edit : ...and I'll be happy to post any more code that needs to be seen.
|
GullRaDriel
Member #3,861
September 2003
|
Give your project a profiling party. It will help you that much for finding where exactly you consume the most part of your cpu time. "Code is like shit - it only smells if it is not yours" |
William Labbett
Member #4,486
March 2004
|
what's a profiling party please ?
|
GullRaDriel
Member #3,861
September 2003
|
Example: I compiled an old project with the following gcc flags for activating profiling: -pg After what I launch my code one time, I play with it, and after exiting I call gprof. Here are the commands and the result: gcc -c -Wall -pedantic -pg -mwindows *.c gcc -pg -o test.exe MapEditor.o m_action.o m_grafic.o m_help.o m_ressource.o -lnilorea -lagl -lalleg -luser32 -lgdi32 -lopengl32 -lglu32 -lglaux -lwsock32 -lws2_32 -lpthreadGC2
And now I know where my time was mostly spent. My top two eating functions are allegro_gl_is_extension_s and draw_map. Obvious, but sometime it helps. "Code is like shit - it only smells if it is not yours" |
William Labbett
Member #4,486
March 2004
|
thanks Gull.. I tried it but I get :- http://www.allegro.cc/files/attachment/597746 I appreciate your help.
|
Thomas Fjellstrom
Member #476
June 2000
|
You made sure to run your program before running it through gprof right? -- |
GullRaDriel
Member #3,861
September 2003
|
Yeah, as stated before and repeated by Thomas, you must run it one time as usual before calling gprof on it. So, let's first do a '17.exe' call, after what you will be able to launch gprof on it. "Code is like shit - it only smells if it is not yours" |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Just to be clear William, you meant that your animation speed was too slow, not your program speed, right? This may be part of it : Quote:
// if(hero.anim_delay_counter > 0) { --hero.anim_delay_counter; hero.update = 0; } else { hero.update = 1; hero.anim_delay_counter = hero.anim_ticks_per_frame; } //
If you have the anim_ticks_per_frame set to 1, then your anim_delay_counter gets set to 1 when it is 0, and decremented when it is greater than zero. So starting from hero.anim_delay_counter = 0, it is set to 1 on the first logic call. On the second call it will be decremented. On the third call it will reach zero again. This effectively means that hero.update would only be set to 1 on every other logic call. With this setup it means hero.update is only set to 1 on every (hero.anim_ticks_per_frame + 1)th frame. What you want is to decrement your tick counter on every pass through the logic loop, and detect when it reaches zero that way. So something more like : // --hero.anim_delay_counter; if (hero.anim_delay_counter <= 0) { // reached the time to update the hero's frame hero.update = 1; hero.anim_delay_counter = hero.anim_ticks_per_frame; } else { hero.update = 0; } // This way when the counter starts at 1 at the beginning of the logic call, it will be decremented to zero which triggers the frame update and resets the delay counter to the number of ticks per frame. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
William Labbett
Member #4,486
March 2004
|
Okay guys. Thanks to Thomas, Edgar and Gulladriel I appreciate your patience. I've got things to work on now, so I'll be absent for a while, while I work through the help. I'll get back when I've done some work. EDIT : hi again. Trying to use profiling but with no luck. I have : used the -pg compiler flag. ..but I still get gmon.out : no such file or directory. Can anyone help ? EDIT 2 : actually I've got it now. Here's the profile :
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
It's nice to see that you've got profiling working for you. You will probably want a sample size larger than running your program for 0.20 seconds though, and you might as well wait until you've got all your basic program elements running before you worry about which functions are taking the longest overall. Did you try the fix for the animation rate that I pointed out in my last post? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
William Labbett
Member #4,486
March 2004
|
Quote: Did you try the fix for the animation rate that I pointed out in my last post? Not until I read the above. I was being neurotic about it. And I was having trouble getting on my feet today for some reason. When I saw you'd replied, I cut and pasted the code you wrote in place of the old code in my main function and commented the old code out. When I ran it, I couldn't believe it. The hero walks about really fast which is brilliant because that means I can actually choose how fast I want him to move by increasing hero.anim_ticks_per_frame which will slow him down a bit. So I'm really pleased, really relieved and feeling more positive my project now. Thanks very much for the help Edgar. You spotted exactly what the problem was.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Well, I kind of glossed over it first. I should have read it more closely. Quote: So I'm really pleased, really relieved and feeling more positive my project now. That's good. Sometimes a small victory is enough to carry the whole day. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
1
2
|