Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- initwindow(900,600,"Práctica No. 8");
- srand(time(0));
- crea_hilera_horizontal(100,100,arreglo);
- //crea_hilera_vertical(100,100,arreglo);
- //scroll_vertical(arreglo);
- pinta_hilera(arreglo);
- scroll_horizontal(arreglo);
- //crea_cubo(&cub);
- //dibuja_cubo(cub);
- tecla=getch();
- closegraph();
- setcolor(15);
- setfillstyle(SOLID_FILL, c.col);
- bar(c.x, c.y, c.x+30, c.y+30);
- rectangle(c.x, c.y, c.x+30, c.y+30);
- A[0]=c.x;
- A[1]=c.y;
- A[2]=c.x+30/2;
- A[3]=c.y-30/2;
- A[4]=c.x+30*1.5;
- A[5]=c.y-30/2;
- A[6]=c.x+30;
- A[7]=c.y;
- A[8]=c.x;
- A[9]=c.y;
- fillpoly(5, A);
- drawpoly(5,A);
- A[0]=c.x+30;
- A[1]=c.y;
- A[2]=c.x+30*1.5;
- A[3]=c.y-30/2;
- A[4]=c.x+30*1.5;
- A[5]=c.y+30/2;
- A[6]=c.x+30;
- A[7]=c.y+30;
- A[8]=c.x+30;
- A[9]=c.y;
- fillpoly(5, A);
- drawpoly(5, A);
- for (i = 0; i < N;i++)
- {
- Arreglo[i].x=xi;
- Arreglo[i].y=yi;
- Arreglo[i].col=rand()%15+1;
- xi+=30;
- }
- yi+=(N-1)*30;
- for (i = 0; i < N;i++)
- {
- Arreglo[i].x=xi;
- Arreglo[i].y=yi;
- Arreglo[i].col=rand()%15+1;
- yi-=30;
- }
- while (tecla != 27)
- {
- tecla = getch();
- if (tecla == 0)
- tecla = getch();
- switch (tecla)
- {
- //Movimiento a la izquierda
- case 75:
- color=Arreglo[0].col;
- for(i=0;i<N;i++)
- {
- Arreglo[i].col=Arreglo[i+1].col;
- }
- Arreglo[N-1].col=color;
- pinta_hilera(Arreglo);
- break;
- //Movimiento a la derecha
- case 77:
- color=Arreglo[N-1].col;
- for(i=N-1;i>0;i--)
- {
- Arreglo[i].col=Arreglo[i-1].col;
- }
- Arreglo[0].col=color;
- pinta_hilera(Arreglo);
- }
- }
- while (tecla != 27)
- {
- tecla = getch();
- if (tecla == 0)
- tecla = getch();
- switch (tecla)
- {
- //Movimiento abajo
- case 80:
- color=Arreglo[0].col;
- for(i=0;i<N;i++)
- {
- Arreglo[i].col=Arreglo[i+1].col;
- }
- Arreglo[N-1].col=color;
- pinta_hilera(Arreglo);
- break;
- //Movimiento arriba
- case 72:
- color=Arreglo[N-1].col;
- for(i=N-1;i>0;i--)
- {
- Arreglo[i].col=Arreglo[i-1].col;
- }
- Arreglo[0].col=color;
- pinta_hilera(Arreglo);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement