int filmfunk(int msec) {
/* (optional) subfunction for film
** we have at least to do:
** vg_window_flush();
** vg_wait_time(msec);
** return(0);
** but we want to do more:
** - when hit SPACE, end the film
** - when hit ENTER, pause/continue the film
** - and give out the actual position of film for debugging purposes
*/
/* give out actual position of film */
int i1,i2,i3;
char buf[64];
vg_film_position(&i1,&i2,&i3);
snprintf(buf,sizeof(buf),"Position: %d,%d,%d",i1,i2,i3);
vg_draw_text(NULL,RGB_WHITE,0,0,buf,NULL,RGB_TRANS);
/* flush out to window */
vg_window_flush();
/* check for keypress to stop or pause/continue film */
vg_key_update();
if (vg_key_pressed(KEY_SPACE,SHORTKEY)) {return(1);} /* stop film */
if (vg_key_pressed(KEY_ENTER,SHORTKEY)) { /* pause film */
vg_sound_paus("ALL"); /* pause all sound */
do { /* check for a keypress to continue film */
vg_window_flush();
vg_wait_time(msec);
vg_key_update();
if (vg_key_pressed(KEY_SPACE,SHORTKEY)) {return(1);} /* stop film */
} while (vg_key_pressed(KEY_ENTER,SHORTKEY)==0);
vg_sound_cont("ALL"); /* continue all sound */
return(0);
}
/* wait the required time */
vg_wait_time(msec);
return(0);
} /* end filmfunk */
|