I'm using this Allegro tutorial, but it's becoming over simplified as it touches on more advanced topics. At the point where I am, the tutorial is trying to explain how to do animations using buffering or page flipping or whatever, and is trying to combine it with the timer stuff they didn't really explain well in the last lesson. I have lots of questions on the code that the tutorial produces, so here is the code:
Okay, the first, and most important question involves the stuff highlighted in blue (and commented out). The program seems to run the same with or without this stuff dealing with timers. Due to the lack of detail in the previous tutorial which covers this stuff, I'm kind of lost as to what exactly the purpose of the commented out code is. However, from what I understand, the variable speed_counter is being incremented the entire program. If this is true, how is it possible that it can ever be decremented and therefore be lower than 0 for the test condition of that commented out while loop? If someone could elaborate about what good this code does for the program and what its exact function is, that would be great. All of that is dealing with the commented out code.
//long speed_counter = 0;
int main(int argc, char* argv)
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
BITMAP* frame_one = load_bitmap("C:\\Documents and Settings\\Owner\\My Documents\\John's Pictures\\Su-27A.bmp", NULL);
BITMAP* frame_two = load_bitmap("C:\\Documents and Settings\\Owner\\My Documents\\John's Pictures\\Su-27B.bmp", NULL);
BITMAP* frame_three = load_bitmap("C:\\Documents and Settings\\Owner\\My Documents\\John's Pictures\\Su-27C.bmp", NULL);
buffer = create_bitmap(640, 480);
int my_pic_x = 0;
int my_pic_y = 0;
int frame_counter = 0;
//while(speed_counter > 0)
if(frame_counter > 240)
frame_counter = 0;
if(frame_counter < 60)
draw_sprite(buffer, frame_one, my_pic_x, my_pic_y);
else if(frame_counter >= 60 && frame_counter < 120)
draw_sprite(buffer, frame_two, my_pic_x, my_pic_y);
draw_sprite(buffer, frame_three, my_pic_x, my_pic_y);
blit(buffer, screen, 0, 0, 0, 0, 640, 480);
Next question. The part of the blue highlighted code that is also bolded has me confused as well. I don't understand how the name of a function can be passed to a function. However, I'm thinking that this is a function pointer because I read somewhere that the name of a function represents its address. Is this correct? Also, I removed that piece of code (END_OF_FUNCTION(); ) and it had no effect on the program (of course I did this when the rest was uncommented). Why is this? This happens 2 other times in the code in two other commented out sections.
Another thing that is bugging me is what would type BITMAP signify if it wasn't declared as a pointer? The tutorial said that type BITMAP is a pointer so why does it require the * in the declaration?
Note the red highlighted 'things'. I understand that these represent key presses, but what are they? Arrays? Structures? Their syntax has got me stumped.
The rest of the program I pretty much understand if you leave the commented parts out. Muchas gracias to anyone who can help. I really appreciate it.