Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. initwindow(900,600,"Práctica No. 8");
  2. srand(time(0));
  3.  
  4. crea_hilera_horizontal(100,100,arreglo);
  5. //crea_hilera_vertical(100,100,arreglo);
  6. //scroll_vertical(arreglo);
  7. pinta_hilera(arreglo);
  8. scroll_horizontal(arreglo);
  9.  
  10. //crea_cubo(&cub);
  11. //dibuja_cubo(cub);
  12.  
  13. tecla=getch();
  14. closegraph();
  15.  
  16. setcolor(15);
  17. setfillstyle(SOLID_FILL, c.col);
  18. bar(c.x, c.y, c.x+30, c.y+30);
  19. rectangle(c.x, c.y, c.x+30, c.y+30);
  20.  
  21. A[0]=c.x;
  22. A[1]=c.y;
  23. A[2]=c.x+30/2;
  24. A[3]=c.y-30/2;
  25. A[4]=c.x+30*1.5;
  26. A[5]=c.y-30/2;
  27. A[6]=c.x+30;
  28. A[7]=c.y;
  29. A[8]=c.x;
  30. A[9]=c.y;
  31.  
  32. fillpoly(5, A);
  33. drawpoly(5,A);
  34. A[0]=c.x+30;
  35. A[1]=c.y;
  36. A[2]=c.x+30*1.5;
  37. A[3]=c.y-30/2;
  38. A[4]=c.x+30*1.5;
  39. A[5]=c.y+30/2;
  40. A[6]=c.x+30;
  41. A[7]=c.y+30;
  42. A[8]=c.x+30;
  43. A[9]=c.y;
  44. fillpoly(5, A);
  45. drawpoly(5, A);
  46.  
  47. for (i = 0; i < N;i++)
  48. {
  49. Arreglo[i].x=xi;
  50. Arreglo[i].y=yi;
  51. Arreglo[i].col=rand()%15+1;
  52. xi+=30;
  53. }
  54.  
  55. yi+=(N-1)*30;
  56.  
  57. for (i = 0; i < N;i++)
  58. {
  59. Arreglo[i].x=xi;
  60. Arreglo[i].y=yi;
  61. Arreglo[i].col=rand()%15+1;
  62. yi-=30;
  63. }
  64.  
  65. while (tecla != 27)
  66. {
  67.  
  68. tecla = getch();
  69.  
  70. if (tecla == 0)
  71. tecla = getch();
  72.  
  73. switch (tecla)
  74. {
  75. //Movimiento a la izquierda
  76. case 75:
  77. color=Arreglo[0].col;
  78. for(i=0;i<N;i++)
  79. {
  80. Arreglo[i].col=Arreglo[i+1].col;
  81. }
  82. Arreglo[N-1].col=color;
  83. pinta_hilera(Arreglo);
  84. break;
  85. //Movimiento a la derecha
  86. case 77:
  87. color=Arreglo[N-1].col;
  88. for(i=N-1;i>0;i--)
  89. {
  90. Arreglo[i].col=Arreglo[i-1].col;
  91. }
  92. Arreglo[0].col=color;
  93. pinta_hilera(Arreglo);
  94. }
  95.  
  96. }
  97.  
  98. while (tecla != 27)
  99. {
  100.  
  101. tecla = getch();
  102.  
  103. if (tecla == 0)
  104. tecla = getch();
  105.  
  106. switch (tecla)
  107. {
  108. //Movimiento abajo
  109. case 80:
  110. color=Arreglo[0].col;
  111. for(i=0;i<N;i++)
  112. {
  113. Arreglo[i].col=Arreglo[i+1].col;
  114. }
  115. Arreglo[N-1].col=color;
  116. pinta_hilera(Arreglo);
  117. break;
  118. //Movimiento arriba
  119. case 72:
  120. color=Arreglo[N-1].col;
  121. for(i=N-1;i>0;i--)
  122. {
  123. Arreglo[i].col=Arreglo[i-1].col;
  124. }
  125. Arreglo[0].col=color;
  126. pinta_hilera(Arreglo);
  127. }
  128.  
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement