#27994 - QuantumDoja - Mon Oct 25, 2004 9:01 pm
Hi, I know what a pointer is, but what is a function pointer?
_________________
Chris Davis
_________________
Chris Davis
yaustar wrote: |
I know what they are myself but I still dont understand what are they used for. Someone said something about 'dynamically changing the flow of the program at run time' :S |
yaustar wrote: |
I know what they are myself but I still dont understand what are they used for. |
Code: |
typedef void (*state)();
// the one and only global game state static state g_state = title_screen(); void title_screen() { draw_main_menu(); if (user_selection() == new_game) { g_state = load_game; } } void load_game() { load_all_level_graphics(); g_state = play_game(); } void play_game() { draw_game(); accept_input(); if (game_over == true) { g_state = title_screen; } } void main() { while(1) { vblank(); g_state(); } } |