void content() { glClear (GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); extern void grid(), drawcar(float ,float ,float ), drawXtree(const Vec3&, const Vec3&); grid(); drawcar(0, 0, 0); drawXtree(Vec3(1,0,1), Vec3(1,1,1)); glutSwapBuffers(); }
void draw(int col, int board[][col], int level, int x[19], int *frogx, int *frogy) { int wnum=50, wseg=width/wnum, hnum=100, hseg=height/hnum, boardw=width/25, boardh=height/13, temp; //graphics parameters int dx=3*level,i; for(i=0; i<3; i++) { //draw multiple logs and turtles in the same rows x[0+i*5]=drawlog(x[0+i*5]+=(dx+4),1,wseg,hseg,boardw,boardh,2,col,board); //moves right x[1+i*5]=drawturtle(x[1+i*5]-=(dx+3),2,wseg,hseg,boardw,boardh,col,board); //moves left x[2+i*5]=drawlog(x[2+i*5]+=(dx+2),3,wseg,hseg,boardw,boardh,4,col,board); //moves right x[3+i*5]=drawlog(x[3+i*5]+=(dx+1),4,wseg,hseg,boardw,boardh,3,col,board); //moves right x[4+i*5]=drawturtle(x[4+i*5]-=(dx),5,wseg,hseg,boardw,boardh,col,board); //moves left } //end for(i=0;i<3;i++) if(*frogy<6 && *frogy>0) //if frog on a moving item for(i=0; i<3; i++) //go through items on the row if(abs(*frogx-x[(*frogy+5*i)-1]/boardw)<=1) //find which item in the row the frog is on *frogx=x[(*frogy+5*i)-1]/boardw; //move the frog with the drifting item x[15]=drawtruck(x[15]-=(dx+4),7,wseg,hseg,boardw,boardh,2,4,col,board); //moves left x[16]=drawcar(x[16]+=(dx+2),8,wseg,hseg,boardw,boardh,3,2,col,board); //moves right x[17]=drawtruck(x[17]-=(dx+3),9,wseg,hseg,boardw,boardh,3,3,col,board); //moves left x[18]=drawcar(x[18]+=(dx+5),10,wseg,hseg,boardw,boardh,4,1,col,board); //moves right } //end draw