Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Threading;
- namespace mirror
- {
- partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- this.Load += l;
- }
- int[,] g = new int[1, 1];
- int i;
- List<int[]> d = new List<int[]>();
- void l(object ss, EventArgs k)
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.Width = this.Height = 800;
- TextBox t = new TextBox();
- this.Controls.Add(t);
- this.Click += (p, e) =>
- {
- t.Hide();
- string[] s = t.Text.Split(' ');
- i = o(s[0]);
- g = new int[i, i];
- d.Add(new int[] { o(s[1]), o(s[2]), o(s[3]), 0 }
- );
- g[d[0][1], d[0][2]] = 1;
- for (int j = 4;
- j < s.Length;
- ) g[o(s[j++]), o(s[j++])] = o(s[j++]);
- Thread x = new Thread(r =>
- {
- while (true)
- {
- for (int c = 0;
- c < d.Count;
- c++)
- {
- try
- {
- got: if (d[c][0] == 0) d[c][1]--;
- if (d[c][0] == 1) d[c][2]--;
- if (d[c][0] == 2) d[c][1]++;
- if (d[c][0] == 3) d[c][2]++;
- if (d[c][3] == 0)
- {
- int l = d[c][0];
- int z = g[d[c][1], d[c][2]];
- if (z == 2) d[c][0] = l == 0 ? 3 : l == 1 ? 2 : l == 2 ? 1 : 0;
- if (z == 3) d[c][0] = l == 0 ? 1 : l == 1 ? 0 : l == 2 ? 3 : 2;
- if (z == 4) d.Add(new int[] { l == 0 ? 3 : l == 1 ? 2 : l == 2 ? 1 : 0, d[c][1], d[c][2], 0 }
- );
- if (z == 5) d.Add(new int[] { l == 0 ? 1 : l == 1 ? 0 : l == 2 ? 3 : 2, d[c][1], d[c][2], 0 }
- );
- if (z == 6)
- {
- d.RemoveAt(c);
- continue;
- }
- if (z == 7) d[c][3] = 1;
- if (z == 8)
- {
- Random rr = new Random();
- d[c][1] = rr.Next(i);
- d[c][2] = rr.Next(i);
- }
- if (z > 1) goto got;
- }
- g[d[c][1], d[c][2]] = 1;
- }
- catch (Exception) { }
- }
- this.Invalidate();
- Thread.Sleep(100);
- }
- }
- );
- x.Start();
- }
- ;
- string[] ar = new string[] { " ", "*", "/", @"\", "//", @"\\", "O", "X", "T" }
- ;
- this.Paint += (h, v) =>
- {
- Graphics z = v.Graphics;
- for (int q = 0;
- q < i;
- q++) for (int w = 0;
- w < i;
- w++)
- {
- z.DrawRectangle(Pens.Black, new Rectangle(q * 20, w * 20, 20, 20));
- z.DrawString(ar[g[q, w]], this.Font, Brushes.Black, new Point(q * 20 + 8, w * 20 + 8));
- }
- }
- ;
- }
- int o(string s)
- {
- return int.Parse(s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement