Advertisement
al33kappa

Kinda works

May 13th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp4
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. label2.BackColor = Color.Red;
  19. label1.BackColor = Color.Yellow;
  20. label3.BackColor = Color.Orange;
  21. label4.BackColor = Color.Purple;
  22. label5.BackColor = Color.Blue;
  23. labelCarcas.BackColor = Color.Black;
  24.  
  25. }
  26. int pot1 = 44;
  27. bool flag = true;
  28. int opredelitel = 1;
  29. Stack<Label> F_stack = new Stack<Label>();
  30. Stack<Label> S_stack = new Stack<Label>();
  31. Stack<Label> T_stack = new Stack<Label>();
  32. Stack<int> Int_Stack = new Stack<int>();
  33. Queue<Label> F_Queue = new Queue<Label>();
  34. Queue<Label> T_Queue = new Queue<Label>();
  35. int i = 2, j = 0;
  36. Label[] massiv;
  37. Label[] massiv_3;
  38. int[] massivj = new int[4] { -1, -2, -3, -4 };
  39. private void pictureBox1_Click(object sender, EventArgs e)
  40. {
  41.  
  42. }
  43. private void timer1_Tick(object sender, EventArgs e)
  44. {
  45. move_1_2();
  46. //move_1_3();
  47. }
  48. public void button1_Click(object sender, EventArgs e)
  49. {
  50. timer1.Interval = 2;
  51. F_stack.Push(label1);
  52. F_stack.Push(label2);
  53. F_stack.Push(label3);
  54. //F_stack.Push(label4);
  55. //F_stack.Push(label5);
  56.  
  57. //massiv_3 = new Label[5] { label111, label222, label333, label444, label555 };
  58. //S_stack.Push(label55);
  59. //S_stack.Push(label44);
  60. S_stack.Push(label11);
  61. S_stack.Push(label22);
  62. S_stack.Push(label33);//?? ????????
  63. F_Queue.Enqueue(label11);
  64. F_Queue.Enqueue(label22);
  65. F_Queue.Enqueue(label33);
  66. //massiv = S_stack.ToArray();
  67. T_stack.Push(label111);
  68. T_stack.Push(label222);
  69. T_stack.Push(label333);
  70. T_Queue.Enqueue(label111);
  71. T_Queue.Enqueue(label222);
  72. T_Queue.Enqueue(label333);
  73. timer1.Start();
  74. }
  75. private void Form1_Load(object sender, EventArgs e)
  76. {
  77.  
  78. }
  79. public void move_1_2()
  80. {
  81.  
  82. if (opredelitel > 0)
  83. {
  84. if (S_stack.Count == 0 || F_stack.Count == 0 || T_stack.Count == 0)
  85. {
  86. timer1.Stop();
  87. }
  88. else
  89. {
  90. if (F_stack.Peek().Location.X == F_stack.Peek().Location.X && F_stack.Peek().Location.Y >= pot1 && flag)
  91. {
  92. F_stack.Peek().Top -= 4;
  93. }
  94. else if (F_stack.Peek().Location.Y == F_stack.Peek().Location.Y && F_stack.Peek().Location.X < S_stack.Peek().Location.X)
  95. {
  96. F_stack.Peek().Left += 4;
  97. flag = false;
  98. }
  99. else if (F_stack.Peek().Location.X == F_stack.Peek().Location.X && F_stack.Peek().Location.Y <= F_Queue.Peek().Location.Y)
  100. {
  101. F_stack.Peek().Top += 4;
  102. }
  103. else
  104. {
  105. F_stack.Pop();
  106. S_stack.Pop();
  107. F_Queue.Dequeue();
  108. i--;
  109. opredelitel *= -1;
  110. flag = true;
  111. }
  112. }
  113. }
  114.  
  115. else
  116. {
  117. if (S_stack.Count == 0 || F_stack.Count == 0 || T_stack.Count == 0)
  118. {
  119. timer1.Stop();
  120. }
  121. else
  122. {
  123. if (F_stack.Peek().Location.X == F_stack.Peek().Location.X && F_stack.Peek().Location.Y >= pot1 && flag)
  124. {
  125. F_stack.Peek().Top -= 4;
  126. }
  127. else if (F_stack.Peek().Location.Y == F_stack.Peek().Location.Y && F_stack.Peek().Location.X < T_stack.Peek().Location.X)
  128. {
  129. F_stack.Peek().Left += 4;
  130. flag = false;
  131. }
  132. else if (F_stack.Peek().Location.X == F_stack.Peek().Location.X && F_stack.Peek().Location.Y <= T_Queue.Peek().Location.Y)
  133. {
  134. F_stack.Peek().Top += 4;
  135. }
  136. else
  137. {
  138. F_stack.Pop();
  139. T_stack.Pop();
  140. T_Queue.Dequeue();
  141. i--;
  142. flag = true;
  143. opredelitel *= -1;
  144.  
  145. }
  146. }
  147. }
  148. }//end move_1_2
  149. /*public void move_1_3()
  150. {
  151. if (F_stack.Count == 0 && T_stack.Count == 0)
  152. {
  153. timer1.Stop();
  154. }
  155. else
  156. {
  157. if (F_stack.Peek().Location.X == F_stack.Peek().Location.X && F_stack.Peek().Location.Y >= pot1 && flag)
  158. {
  159. F_stack.Peek().Top -= 4;
  160. }
  161. else if (F_stack.Peek().Location.Y == F_stack.Peek().Location.Y && F_stack.Peek().Location.X < T_stack.Peek().Location.X)
  162. {
  163. F_stack.Peek().Left += 4;
  164. flag = false;
  165. }
  166. else if (F_stack.Peek().Location.X == F_stack.Peek().Location.X && F_stack.Peek().Location.Y <= T_Queue.Peek().Location.Y)
  167. {
  168. F_stack.Peek().Top += 4;
  169. }
  170. else
  171. {
  172. //Int_Stack.Push(1);
  173. F_stack.Pop();
  174. T_stack.Pop();
  175. T_Queue.Dequeue();
  176. i--;
  177. flag = true;
  178. }
  179. }
  180. }*///end_move_1_3
  181. }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement