MEGASTAR.PAS 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. Uses CRT, Graph;
  2. Const
  3. otn = 3;
  4. typeofstar = 5;
  5. ang1=5;
  6. ang2=10;
  7. ang3=15;
  8. Type TStar = record
  9. x,y,radius,color,ang : integer;
  10. end;
  11. Var
  12. stars : array [1..1+typeofstar+typeofstar*typeofstar] of Tstar;
  13. i : integer;
  14. Procedure GetStars;
  15. Var
  16. i,j: integer;
  17. tmp,tmp2 : integer;
  18. Begin
  19. randomize;
  20. with stars[1] do
  21. begin
  22. x := getmaxx div 2;
  23. y := getmaxy div 2;
  24. radius := 150;
  25. inc(ang,5);
  26. if ang > 360 then ang := ang mod 360;
  27. end;
  28. for i := 2 to typeofstar+1 do
  29. begin
  30. with stars[i] do
  31. begin
  32. tmp :=i*(360 div typeofstar)+stars[1].ang-(180 div typeofstar);
  33. x := stars[1].x+round(150*cos(Pi*tmp/180));
  34. y := stars[1].y+round(150*sin((Pi*tmp)/180));
  35. radius := 70;
  36. dec(ang,10);
  37. if ang < 0 then ang := 360+ang;
  38. for j := (i-1)*typeofstar+2 to (i-1)*typeofstar+2+typeofstar do
  39. with stars[j] do
  40. begin
  41. tmp2 :=j*(360 div typeofstar)+stars[i].ang-(180 div typeofstar);
  42. x := stars[i].x+round(70*cos(Pi*tmp2/180));
  43. y := stars[i].y+round(70*sin((Pi*tmp2)/180));
  44. radius := 35;
  45. inc(ang,15);
  46. if ang > 360 then ang := ang mod 360;
  47. end;
  48. end;
  49. end;
  50. End;
  51. Procedure INITG;
  52. Var
  53. grDriver: Integer;
  54. grMode: Integer;
  55. i : integer;
  56. begin
  57. grDriver := Detect;
  58. InitGraph(grDriver, grMode,'');
  59. for i := 1 to 1+typeofstar+typeofstar*typeofstar do stars[i].color := random(14)+1;
  60. End;{INITG}
  61. {------------------------------}
  62. Procedure Star(x,y,radius,Color,a0: integer);
  63. Var
  64. dx,dy,i,a : integer;
  65. Begin
  66. SetColor(color);
  67. MoveTO(x+round((radius div otn)*cos(pi*a0/180)),
  68. y+round((radius div otn)*sin(pi*a0/180)));
  69. for i := 1 to typeofstar * 2 do begin
  70. a := i*(360 div (typeofstar*2))+a0;
  71. if i mod 2 = 1 then
  72. begin
  73. dx := round(radius*cos((Pi*a)/180));
  74. dy := round(radius*sin((Pi*a)/180))
  75. end
  76. else
  77. begin
  78. dx := round((radius div otn)*cos((Pi*a)/180));
  79. dy := round((radius div otn)*sin((Pi*a)/180))
  80. end;
  81. LineTo(x+dx,y+dy);
  82. end;
  83. End;{Star}
  84. Begin
  85. INITG;
  86. repeat
  87. cleardevice;
  88. Getstars;
  89. for i := 1 to 1+typeofstar+typeofstar*typeofstar do
  90. star(stars[i].x,stars[i].y,stars[i].radius,stars[i].color,stars[i].ang);
  91. delay(500);
  92. until keypressed;
  93. CloseGraph;
  94. End.