ENTRYPOINT void init_tunnel (ModeInfo *mi) { int i; tunnel_configuration *tc; wire = MI_IS_WIREFRAME(mi); # ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */ wire = 0; # endif if (!tconf) { tconf = (tunnel_configuration *) calloc (MI_NUM_SCREENS(mi), sizeof (tunnel_configuration)); if (!tconf) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } } tc = &tconf[MI_SCREEN(mi)]; tc->glx_context = init_GL(mi); tc->cyllist = glGenLists(1); tc->diamondlist = glGenLists(1); tc->num_effects = 12; tc->num_texshifts = 3; tc->effect_time = 0.0; tc->effect_maxsecs = 30.00; /* check bounds on cmd line opts */ if (start > tc->effect_maxsecs) start = tc->effect_maxsecs; if (end > tc->effect_maxsecs) end = tc->effect_maxsecs; if (start < tc->effect_time) start = tc->effect_time; if (end < tc->effect_time) end = tc->effect_time; /* set loop times, in seconds */ tc->start_time = start; tc->end_time = end; /* reset animation knots, effect 0 not defined. */ tc->effects = malloc(sizeof(effect_t) * ( tc->num_effects + 1)); for ( i = 1; i <= tc->num_effects ; i++) init_effects(&tc->effects[i], i); if (wire) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); do_texture = False; } if (do_texture) { /* the following textures are loaded, and possible overridden: tunnel 1, tunnel 2, tunnel 3, marquee, tardis, head */ glGenTextures(MAX_TEXTURE, tc->texture_binds); /*LoadTexture(*mi, **fn, *filename, texbind, bluralpha, bw_color, anegative, onealpha)*/ if (strcasecmp (do_tun1, "(none)")) /* tunnel 1 */ LoadTexture(mi, NULL, do_tun1, tc->texture_binds[0], 0,0.0, False, False); else LoadTexture(mi, timetunnel0_xpm, NULL, tc->texture_binds[0], 0, 0.0, False, False); if (strcasecmp (do_tun2, "(none)")) /* tunnel 2 */ LoadTexture(mi, NULL, do_tun2, tc->texture_binds[2], 0,0.0, False, False); else LoadTexture(mi, timetunnel1_xpm, NULL, tc->texture_binds[2], 0, 0.0, False, False); if (strcasecmp (do_tun3, "(none)")) /* tunnel 3 */ LoadTexture(mi, NULL, do_tun3, tc->texture_binds[5], 0,0.0, False, False); else LoadTexture(mi, timetunnel2_xpm, NULL, tc->texture_binds[5], 0, 0.0, False, False); LoadTexture(mi, tunnelstar_xpm, NULL, tc->texture_binds[4], 0, 0.0, False, False); if (strcasecmp (do_tx1, "(none)")) /* marquee */ LoadTexture(mi, NULL, do_tx1, tc->texture_binds[3], 0,0.0, False, False); #ifndef HAVE_JWZGLES /* logo_180_xpm is 180px which is not a power of 2! */ else LoadTexture(mi, (char **) logo_180_xpm, NULL, tc->texture_binds[3], 0,0.0, False, False); #endif if (strcasecmp (do_tx2, "(none)")) /* tardis */ LoadTexture(mi, NULL, do_tx2, tc->texture_binds[1], 0, 0.0 ,False, False); #ifndef HAVE_JWZGLES /* logo_180_xpm is 180px which is not a power of 2! */ else LoadTexture(mi, (char **) logo_180_xpm, NULL, tc->texture_binds[1], 0,0.0, False, False); #endif if (strcasecmp (do_tx3, "(none)")) { /* head */ LoadTexture(mi, NULL, do_tx3, tc->texture_binds[6], 0, 0.0 ,False, False); /* negative */ LoadTexture(mi, NULL, do_tx3, tc->texture_binds[9], 2,1.0, True, True); #ifndef HAVE_JWZGLES /* logo_180_xpm is 180px which is not a power of 2! */ } else { LoadTexture(mi, (char **) logo_180_xpm, NULL, tc->texture_binds[6], 0,0.0, False, False); /* negative */ LoadTexture(mi, (char **) logo_180_xpm, NULL, tc->texture_binds[9], 2,1.0, True, True); #endif } glEnable(GL_TEXTURE_2D); check_gl_error("tex"); } reshape_tunnel (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glDisable(GL_DEPTH_TEST); /* who needs it? ;-) */ if (do_fog) glEnable(GL_FOG); if (!wire) { glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5); } tc->trackball = gltrackball_init (); tc->texshift = calloc(tc->num_texshifts, sizeof(GLfloat)); for ( i = 0 ; i < tc->num_texshifts; i++) tc->texshift[i] = 0.0; glNewList(tc->cyllist, GL_COMPILE); makecyl(30, -0.1, CYL_LEN, 1., 10. / 40.0 * CYL_LEN); /*makecyl(30, -0.5, DIAMOND_LEN, 1., 4. / 40 * DIAMOND_LEN); */ glEndList(); glNewList(tc->diamondlist, GL_COMPILE); makecyl(4, -0.5, DIAMOND_LEN, 1., 4. / 40 * DIAMOND_LEN); glEndList(); }
main() { int i, itest, dobackface, dofill, dodouble; char buf[100]; float H; short idata; int xr, yr; vinit("mswin"); winopen("piston"); /* * Wait for REDRAW event ... */ while (qread(&idata) != REDRAW) ; doublebuffer(); gconfig(); unqdevice(INPUTCHANGE); qdevice(QKEY); qdevice(FKEY); qdevice(BKEY); qdevice(ESCKEY); qdevice(REDRAW); makecyl(); polymode(PYM_FILL); backface(1); /* * set up a perspective projection with a field of view of * 40.0 degrees, aspect ratio of 1.0, near clipping plane 0.1, * and the far clipping plane at 1000.0. */ perspective(400, 1.5, 0.1, 600.0); lookat(0.0, -6.0, 4., 0.0, 0.0, 0.0, 0); /* * here we loop back here adnaseum until someone hits a key */ xr = yr = 0; while(1) { for (i = 0; i < 360; i += 5) { color(BLACK); clear(); color(RED); H = 1.0 + cos(2.0 * 3.14159265*i / 180.0); yr = 500 - (int)getvaluator(MOUSEY); xr = 500 - (int)getvaluator(MOUSEX); yr = 500 - (int)getvaluator(MOUSEY); xr *= 3; yr *= 3; pushmatrix(); rotate(xr, 'x'); rotate(yr, 'y'); piston(H); popmatrix(); if (dodouble) swapbuffers(); if (qtest()) { itest = qread(&idata); itest = qread(&idata); /* Zap Up event */ if (itest == BKEY) { dobackface = !dobackface; backface(dobackface); } else if (itest == FKEY) { dofill = !dofill; if (dofill) polymode(PYM_FILL); else polymode(PYM_LINE); } else if(itest == QKEY || itest == ESCKEY) { gexit(); exit(0); } } } } }
void main(){ _setcursortype(_NOCURSOR); randomize(); clrscr(); for(int o = 0; o<9; o++){ gotoxy(3, 3+o); //puts(banner2[o]); cprintf("%s",banner2[o]); delay(50); } for(int p = 0; p<9; p++){ gotoxy(20, 15+p); cprintf("%s",banner3[p]); // puts(banner3[p]); delay(50); } gotoxy(55, 25); cout<<"by Shreyas Kishore, XI-F"; getch(); clrscr(); char ch; int selprev; box(0,0,77,24,50); gotoxy(35,1); char name[] = "ЕFlappy BirdЦ"; int n = 0; for(int l = 0; l<=7; l++){ gotoxy(12,16 +l); // cprintf("%s",banner1[p]); puts(banner1[l]); } gotoxy(35,1); while(name[n] != '\0'){ cout<<name[n]; n++; delay(25); } box(30, 4, 17, 10, 30); gotoxy(35, 7); cout<<"Choose Mode:"; gotoxy(35,10); cout<<"Normal Mode"; gotoxy(35,13); cout<<"Disco Mode"; while((int)ch != 13){ if((int)ch == 72){selprev = selection; selection = 0;} if((int)ch == 80){selprev = selection; selection = 1;} if(selprev != selection){ for(int i = 32; i<=48; i++){ for( int j = 7; j<= 14; j++){ gotoxy(i,j); cout<<" "; } } } if(selection == 0) box(32,8,13,2); if(selection == 1) box(32,11,13, 2); box(0,0,77,24,1000); gotoxy(35,1); cout<<"ЕFlappy BirdЦ"; box(30, 4, 17, 10, 300); gotoxy(35, 7); cout<<"Choose Mode:"; gotoxy(35,10); cout<<"Normal Mode"; gotoxy(35,13); cout<<"Disco Mode"; ch = getch(); } //SetConsoleCursorInfo(_NOCURSOR); int x = 25, y = 2, xprev, yprev, con = 0, scorecalc = 0, phase= 0; float del = 200; makecyl(); box(); gotoxy(35,1); //name = "Flappy Bird"; n = 0; while(name[n] != '\0'){ cout<<name[n]; n++; delay(25); } line(2, 24, 78, 24, 60, 3); long event_fall = timems(), press, event_makecyl = timems(), event_display = timems(), event_shift = timems(); while(y<=24 && data[yprev][xprev]==0){ gotoxy(x,y); //cout<<setclr(9); cout<<""; gotoxy(xprev, yprev); cout<<" "; if(timemssince(event_display)>50){ display(); event_display = timems(); linewphase(2, 24, 78, 24, 1000, phase); } if(timemssince(event_shift)>50){ shift(); scorecalc++; event_shift = timems(); data_assign(); phase++; score= (scorecalc-35)/30; if(score<0)score = 0; } if(timemssince(event_makecyl)>1500){ makecyl(); event_makecyl = timems(); } if(timemssince(event_fall)>del){ del-=30; xprev = x; yprev = y; y++; if(del<40) del = 40; event_fall = timems(); } if(getchn()){ if(con == 0){ xprev = x; yprev = y; //if(y<2) y = 2; del = 200; con = 1; press = timems(); } } if(con==1 && timemssince(press)>0 && timemssince(press)<=30){yprev=y; y--; con++;} else if(con==2 && timemssince(press)>30 && timemssince(press)<=80){yprev=y;y--; con++;} else if(con==3 && timemssince(press)>80 && timemssince(press)<=150){yprev=y;y--; con++;} else if(con==4 && timemssince(press)>150 && timemssince(press)<=240){yprev=y;y--; con++;} else if(con==5 && timemssince(press)>240 && timemssince(press)<=350){yprev=y;y--; con=0;} if(y<2)y=2; } for(int xx=34; xx<=46; xx++){ for(int yy = 11; yy<=15; yy++){ gotoxy(xx,yy); cout<<" "; } } box(32, 9, 13, 6, 5, 4); gotoxy(36,12); cout<<"GAME OVER!"; gotoxy(36,14); cout<<"Score: "<<score; getch(); }