1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| [...]
find = FALSE ;
FD_ZERO(&readfds) ;
FD_SET(STDIN_FILENO, &readfds) ;
timeout.tv_usec -= acc.tv_usec ;
timeout.tv_sec -= acc.tv_sec ;
if(timeout.tv_usec < 0) {
timeout.tv_sec -= 1 ;
timeout.tv_usec += 1000000 ;
}
if(gettimeofday(&tv1, NULL)==-1) {
endcurses() ;
perror("gettimeofday") ;
return EXIT_FAILURE ;
}
if(select(1, &readfds, NULL, NULL, &timeout)==-1) {
endcurses() ;
perror("select") ;
exit(EXIT_FAILURE) ;
}
if(FD_ISSET(STDIN_FILENO, &readfds)) {
r = getch() ; // fontion getch() des ncurses et non celle de conio.h
switch(r) {
case ESCAPE:
cont = FALSE ;
break ;
case KEY_UP:
if(lab->grid[posY-1][posX] == 1) { // player hits a wall
if(--pv==0)
[...] |