int main() { Context bird(new FlyStrategy()); Context fish(new SwimStrategy()); bird.doAction(); fish.doAction(); return 0; }
int main() { g_app->Init(); Obstacles obstacles; Bird bird(&obstacles); sf::Clock clock; while (g_app->window.isOpen()) { sf::Event event; while (g_app->window.pollEvent(event)) { g_input->HandleEvent(event); } sf::Time elapsed = clock.restart(); g_app->window.clear(sf::Color(95, 158, 160)); bird.Update(elapsed.asSeconds()); if (!bird.GameOver()) { obstacles.Update(elapsed.asSeconds()); } bird.Draw(); obstacles.Draw(); g_input->Reset(); g_app->window.display(); } return 0; }
void draw_fractal(t_env *env) { if (env->fractal == MANDELBROT) mandelbrot(env); else if (env->fractal == JULIA) julia(env); else if (env->fractal == BURNING) burning_ship(env); else if (env->fractal == JULIA_BURNING) julia_burning_ship(env); else if (env->fractal == BIOMORPH) biomorph(env); else if (env->fractal == BIRD) bird(env); else if (env->fractal == TRIBROT) tribrot(env); else if (env->fractal == JULIA_BIRD) julia_bird(env); else print_usage(); print_menu(env); }
void draw(int xmax,int ymax,int *poly) { x=60; int i=0; START: setfillstyle(7,RED); cleardevice(); int fire_poly[]={65,80+i,65,180+i,55,130+i,25,200+i,25,100+i,40,140+i,65,80+i}; switch(i) { case 0: drawpoly(5, poly); //tree(x,ymax); drawpoly(7,fire_poly); setfillstyle(5,YELLOW); fillpoly(7,fire_poly); man_mv(x,ymax); delay(300); switch(path) { case 0: if(p==11) { getch(); cleardevice(); outtextxy(xmax/2,ymax/2,"LOST LIFE\n Press any key to Continue........\n"); p=-1; path=random(3); getch(); } else if(p==9) p=-1; switch(p) { case -1: bird(20,1); p++; break; case 0: bird(a,b); p++; break; case 1: bird(2*a,b); p++; break; case 2: bird(3*a,2*b); p++; break; case 3: bird(2*a,3*b); p++; break; case 4: bird(4*a,4*b); p++; if(x==380) p++; break; case 5: bird(4*a,ymax-60); break; case 6: bird(4*a,3*b); p++; break; case 7: bird(2*a,2*b); p++; break; case 8: bird(a,4*b); if(x==60) p=9; else p=11; break; case 9: bird(a-20,3*b); delay(1000); break; /*case 10:bird(4*a,ymax-60); getch(); //delay(1000); break; */ case 11:bird(a,ymax-60); //delay(1000); break; } i+=150; if(!kbhit()) { delay(300); goto START; } ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } goto START; case 1: if(p==11) { getch(); cleardevice(); outtextxy(xmax/2,ymax/2,"LOST LIFE\n Press any key to Continue........\n"); p=-1; path=random(3); getch(); } else if(p==9) p=-1; switch(p) { case -1: bird(20,1); p++; break; case 0: bird(a,b); p++; break; case 1: bird(2*a,3*b); p++; break; case 2: bird(3*a,2*b); p++; break; case 3: bird(4*a,3*b); p++; break; case 4: bird(5*a,4*b); p++; if(x==540) p++; break; case 5: bird(5*a,ymax-60); break; case 6: bird(4*a,3*b); p++; break; case 7: bird(2*a,3*b); p++; break; case 8: bird(a,4*b); if(x==60) p=9; else p=11; break; case 9: bird(a-20,3*b); delay(1000); break; /*case 10:bird(4*a,ymax-60); getch(); //delay(1000); break; */ case 11:bird(a,ymax-60); //delay(1000); break; } i+=150; if(!kbhit()) { delay(300); goto START; } ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } goto START; } break; case 150: drawpoly(5, poly); //tree(x,ymax); drawpoly(7,fire_poly); setfillstyle(5,RED); fillpoly(7,fire_poly); man_mv(x,ymax); delay(300); switch(path) { case 0: if(p==5) { getch(); //cleardevice(); outtextxy(xmax/2,ymax/2,"LOST LIFE\n Press any key to Continue........\n"); p=-1; path=random(3); getch(); } else if(p==9) p=-1; switch(p) { case -1: bird(20,1); p++; break; case 0: bird(a,b); p++; break; case 1: bird(2*a,b); p++; break; case 2: bird(3*a,2*b); p++; break; case 3: bird(2*a,3*b); p++; break; case 4: bird(4*a,4*b); p++; if(x==380) p++; break; case 5: bird(4*a,ymax-60); break; case 6: bird(4*a,3*b); p++; break; case 7: bird(2*a,2*b); p++; break; case 8: bird(a,4*b); if(x==60) p=9; else p=11; break; case 9: bird(a-20,3*b); delay(1000); break; /*case 10:bird(4*a,ymax-60); getch(); // delay(1000); break; */ case 11:bird(a,ymax-60); // delay(1000); break; } i=0; if(!kbhit()) { delay(600); goto START; } ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } goto START; case 1: if(p==5) { getch(); cleardevice(); outtextxy(xmax/2,ymax/2,"LOST LIFE\n Press any key to Continue........\n"); p=-1; path=random(3); getch(); } else if(p==9) p=-1; switch(p) { case -1: bird(20,1); p++; break; case 0: bird(a,b); p++; break; case 1: bird(2*a,3*b); p++; break; case 2: bird(3*a,2*b); p++; break; case 3: bird(4*a,3*b); p++; break; case 4: bird(5*a,4*b); p++; if(x==540) p++; break; case 5: bird(5*a,ymax-60); break; case 6: bird(4*a,3*b); p++; break; case 7: bird(2*a,3*b); p++; break; case 8: bird(a,4*b); if(x==60) p=9; else p=11; break; case 9: bird(a-20,3*b); delay(1000); break; /*case 10:bird(4*a,ymax-60); getch(); //delay(1000); break; */ case 11:bird(a,ymax-60); //delay(1000); break; } i=0; if(!kbhit()) { delay(600); goto START; } ch=getch(); delay(100); switch(ch) { case 'a': if(x==60) ; else x-=160; break; case 'd': if(x==540) ; else x+=160; break; } goto START; } break; } }