예제 #1
0
int read_data( FILE *fp,char *string_vars,int *int_vars,
               float *fl_vars, int **arraysi,float **arraysf,
               float *xmin,float *xmax, float *ymin,float *ymax,
               int *current, int req,int *maxrec,int rotate )
#endif
{
    int i,err=0,read=0,rec_num=0,rotate_velocity=1;
    long curr_pos;
    struct stat buf;

    curr_pos = ftell( fp );

    if (*current>req) {
        rewind( fp );
        *current=0;
    }
    rec_num = *current;
    while (rec_num<req-1) {
        if (err=skip_data_blk( fp )) {
            if (err==EOF_ERR) *maxrec = rec_num;
            return( err );
        }
        else rec_num++;
    }
    if (err=read_data_blk( fp,string_vars, int_vars,fl_vars,arraysi,arraysf)) {
        if (err==READ_ERR) {
            clear_arrays();
            rewind( fp );
            *current=0;
        }
        else if (err==EOF_ERR) {
            *maxrec = rec_num;
            fseek( fp,curr_pos,SEEK_SET );
        }
        return( err );
    }
    /*if (req==1) {*/
    if (*maxrec==0) {
        curr_pos = ftell( fp );
        err = fstat(fileno(fp),&buf);
        *maxrec = buf.st_size/curr_pos;
    }
    *current = req;
    if (rotate) {
         swapco_(arraysf[EX],arraysf[EY],arraysf[UVP],
                                &int_vars[NUP],&rotate,&rotate_velocity );
         if (int_vars[ILAG]) {
              rotate_velocity = 0;
              if (int_vars[ILAG]==1||int_vars[ILAG]==3)
                  swapco_(arraysf[EXLG],arraysf[EYLG],NULL,
                                &int_vars[NUL],&rotate,&rotate_velocity );
              i = int_vars[NSM] * int_vars[NPM];
              if (int_vars[ILAG]==1||int_vars[ILAG]==2)
                  swapco_(arraysf[STELPX],arraysf[STELPY],NULL,
                                &i,&rotate,&rotate_velocity );
         }
    }
    find_max_min(arraysf[EX],arraysf[EY],int_vars[NUP],xmin,xmax,ymin,ymax);
    return( 0 );
}
예제 #2
0
Board::Board(QWidget *parent)  : QFrame(parent)
{
    is_game_on = false;
    clear_arrays();
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(update_arrays()));

}
예제 #3
0
void Board::clear(){
    clear_arrays();
    timer->stop();
    is_game_on = false;
    repaint();
}