![]() |
|
Crazy fast...why? |
SkaxCo
Member #8,323
February 2007
|
I can't figure out what is wrong with this. I'm using that thingy- the while(speed_counter > 0){ //do stuff speed_counter--; } But it is going insanely fast! There is also
There is lots of drawing but that code is fine. For some reason it flies through it, determines you died, and brings up the death screen. What is wrong with this code? |
Seppl
Member #4,656
May 2004
![]() |
the first possible bug that comes to my mind: __________________________________ |
SkaxCo
Member #8,323
February 2007
|
No, its volatile long speed_counter = 0; |
HardTranceFan
Member #7,317
June 2006
![]() |
My guess is that it's because everything's running at 60 BPS, and you don't have a pausing or slowdown coded in the sections that need it. You're raising, moving and animating zombies at 60 times per second. I would have thought animation of 60 times per second is too much. 8-10 frames a sec might suit a little better. You can achieve this by using a counter in the animation method. One way to determine whether this is the problem is to temporarily change the BPS_TO_TIMER(60) to BPS_TO_TIMER(6). -- |
SkaxCo
Member #8,323
February 2007
|
All changing that does is change te pause before it ends. It appears as though the while(...){...} statement is having a large problem. |
HardTranceFan
Member #7,317
June 2006
![]() |
Err, yes, silly me - I should have realised What happens if you try the following: Add a variable (int delay) to your zombie class, and initialise it to 10 for every zombie. Then update the section of code that draws the zombies. /*=draw the zombies, check 4 hits=====*/ for(int i = 0; i < 250; i++){ if(horde<i>.alive){ if (!(--horde<i>.delay)){ horde<i>.y += horde<i>.fall_speed; horde<i>.frame++; if(horde<i>.frame > 8) horde<i>.frame = 1; horde<i>.delay = 10; } } } If this helps the animation, try the something similar for the 'raise me some zombies' section. BTW, I'm having a wild guess at what the problem is that you're experiencing. This may not solve it at all. But, it's worth a crack. -- |
SkaxCo
Member #8,323
February 2007
|
To everyone who helped: my most profuse thanks. |
ImLeftFooted
Member #3,935
October 2003
![]() |
Quote: There is also volatile long speed_counter = 0; in a header file. This is your first (and maybe biggest) problem. Quote: What is wrong with this code? Hmm...
(lvl < 5)?(prog += (10-lvl)):(prog++); // I believe most programmers would agree this version is cleaner: prog += (lvl < 5) ? (10 - lvl) : 1; In short: Maybe you should decide a few code distribution systems you enjoy using and explore them more thoroughly. |
|