Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.Drawing;
  6.  
  7. using System.Windows.Forms;
  8.  
  9. using System.Threading;
  10.  
  11. namespace mirror
  12. {
  13. partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. this.Load += l;
  19. }
  20. int[,] g = new int[1, 1];
  21. int i;
  22. List<int[]> d = new List<int[]>();
  23. void l(object ss, EventArgs k)
  24. {
  25. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  26. SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  27. this.Width = this.Height = 800;
  28. TextBox t = new TextBox();
  29. this.Controls.Add(t);
  30. this.Click += (p, e) =>
  31. {
  32. t.Hide();
  33. string[] s = t.Text.Split(' ');
  34. i = o(s[0]);
  35. g = new int[i, i];
  36. d.Add(new int[] { o(s[1]), o(s[2]), o(s[3]), 0 }
  37. );
  38. g[d[0][1], d[0][2]] = 1;
  39. for (int j = 4;
  40. j < s.Length;
  41. ) g[o(s[j++]), o(s[j++])] = o(s[j++]);
  42. Thread x = new Thread(r =>
  43. {
  44. while (true)
  45. {
  46. for (int c = 0;
  47. c < d.Count;
  48. c++)
  49. {
  50. try
  51. {
  52. got: if (d[c][0] == 0) d[c][1]--;
  53. if (d[c][0] == 1) d[c][2]--;
  54. if (d[c][0] == 2) d[c][1]++;
  55. if (d[c][0] == 3) d[c][2]++;
  56. if (d[c][3] == 0)
  57. {
  58. int l = d[c][0];
  59. int z = g[d[c][1], d[c][2]];
  60. if (z == 2) d[c][0] = l == 0 ? 3 : l == 1 ? 2 : l == 2 ? 1 : 0;
  61. if (z == 3) d[c][0] = l == 0 ? 1 : l == 1 ? 0 : l == 2 ? 3 : 2;
  62. if (z == 4) d.Add(new int[] { l == 0 ? 3 : l == 1 ? 2 : l == 2 ? 1 : 0, d[c][1], d[c][2], 0 }
  63. );
  64. if (z == 5) d.Add(new int[] { l == 0 ? 1 : l == 1 ? 0 : l == 2 ? 3 : 2, d[c][1], d[c][2], 0 }
  65. );
  66. if (z == 6)
  67. {
  68. d.RemoveAt(c);
  69. continue;
  70. }
  71. if (z == 7) d[c][3] = 1;
  72. if (z == 8)
  73. {
  74. Random rr = new Random();
  75. d[c][1] = rr.Next(i);
  76. d[c][2] = rr.Next(i);
  77. }
  78. if (z > 1) goto got;
  79. }
  80. g[d[c][1], d[c][2]] = 1;
  81. }
  82. catch (Exception) { }
  83. }
  84. this.Invalidate();
  85. Thread.Sleep(100);
  86. }
  87. }
  88. );
  89. x.Start();
  90. }
  91. ;
  92. string[] ar = new string[] { " ", "*", "/", @"\", "//", @"\\", "O", "X", "T" }
  93. ;
  94. this.Paint += (h, v) =>
  95. {
  96. Graphics z = v.Graphics;
  97. for (int q = 0;
  98. q < i;
  99. q++) for (int w = 0;
  100. w < i;
  101. w++)
  102. {
  103. z.DrawRectangle(Pens.Black, new Rectangle(q * 20, w * 20, 20, 20));
  104. z.DrawString(ar[g[q, w]], this.Font, Brushes.Black, new Point(q * 20 + 8, w * 20 + 8));
  105. }
  106. }
  107. ;
  108. }
  109. int o(string s)
  110. {
  111. return int.Parse(s);
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement