Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.13 KB | None | 0 0
  1. #include "ccc_win.h"
  2. int ccc_win_main()
  3. {
  4. cwin << Line(Point(-1.0, 3.0), Point(-1.0, -3.0));
  5. cwin << Line(Point(1.0, 3.0), Point(1.0, -3.0));
  6. cwin << Line(Point(-3.0, 1.0), Point(3.0, 1.0));
  7. cwin << Line(Point(-3.0, -1.0), Point(3.0, -1.0));
  8. Point P1;
  9. int w = 0;
  10. int x = 0;
  11. int y = 0;
  12. int z = 0;
  13. int row1y = 0;
  14. int row2y = 0;
  15. int row3y = 0;
  16. int row1x = 0;
  17. int row2x = 0;
  18. int row3x = 0;
  19. int col1y = 0;
  20. int col2y = 0;
  21. int col3y = 0;
  22. int col1x = 0;
  23. int col2x = 0;
  24. int col3x = 0;
  25. int diag1y = 0;
  26. int diag2y = 0;
  27. int diag1x = 0;
  28. int diag2x = 0;
  29.  
  30. while (z == 0){
  31. while (x < 9){
  32. if (y == 0){
  33. P1 = cwin.get_mouse("It's X's turn to make a move.");
  34. }
  35. if (y == 1){
  36. P1 = cwin.get_mouse("It's O's turn to make a move.");
  37. }
  38. if ((P1.get_x() > 1.0 && P1.get_x() < 3.0) && (P1.get_y() > 1.0) && (P1.get_y() < 3.0)){
  39. if (y == 0){
  40. cwin << Line(Point(1.0, 1.0), Point(3.0, 3.0));
  41. cwin << Line(Point(1.0, 3.0), Point(3.0, 1.0));
  42. x++;
  43. y++;
  44. row1x++;
  45. col1x++;
  46. diag1x++;
  47. }
  48. if (y == 1){
  49. cwin << Circle(Point(2.0, 2.0), 1);
  50. x++;
  51. y--;
  52. row1y++;
  53. col1y++;
  54. diag1y++;
  55. }
  56. }
  57. if ((P1.get_x() > 1.0 && P1.get_x() < 3.0) && (P1.get_y() > -1.0) && (P1.get_y() < 1.0)){
  58. if (y == 0){
  59. cwin << Line(Point(1.0, 1.0), Point(3.0, -1.0));
  60. cwin << Line(Point(1.0, -1.0), Point(3.0, 1.0));
  61. x++;
  62. y++;
  63. row2x++;
  64. col1x++;
  65. }
  66. if (y == 1){
  67. cwin << Circle(Point(2.0, 0), 1);
  68. x++;
  69. y--;
  70. row2y++;
  71. col1y++;
  72. }
  73. }
  74. if ((P1.get_x() > 1.0 && P1.get_x() < 3.0) && (P1.get_y() > -3.0) && (P1.get_y() < -1.0)){
  75. if (y == 0){
  76. cwin << Line(Point(1.0, -1.0), Point(3.0, -3.0));
  77. cwin << Line(Point(1.0, -3.0), Point(3.0, -1.0));
  78. x++;
  79. y++;
  80. row3x++;
  81. col1x++;
  82. diag2x++;
  83. }
  84. if (y == 1){
  85. cwin << Circle(Point(2.0, -2.0), 1);
  86. x++;
  87. y--;
  88. row3y++;
  89. col1y++;
  90. diag2y++;
  91. }
  92. }
  93. if ((P1.get_x() > -1.0 && P1.get_x() < 1.0) && (P1.get_y() > 1.0) && (P1.get_y() < 3.0)){
  94. if (y == 0){
  95. cwin << Line(Point(-1.0, 3.0), Point(1.0, 1.0));
  96. cwin << Line(Point(-1.0, 1.0), Point(1.0, 3.0));
  97. x++;
  98. y++;
  99. row1x++;
  100. col2x++;
  101. }
  102. if (y == 1){
  103. cwin << Circle(Point(0, 2.0), 1);
  104. x++;
  105. y--;
  106. row1y++;
  107. col2y++;
  108. }
  109. }
  110. if ((P1.get_x() > -1.0 && P1.get_x() < 1.0) && (P1.get_y() > -1.0) && (P1.get_y() < 1.0)){
  111. if (y == 0){
  112. cwin << Line(Point(-1.0, 1.0), Point(1.0, -1.0));
  113. cwin << Line(Point(-1.0, -1.0), Point(1.0, 1.0));
  114. x++;
  115. y++;
  116. row2x++;
  117. col2x++;
  118. diag1x++;
  119. diag2x++;
  120. }
  121. if (y == 1){
  122. cwin << Circle(Point(0, 0), 1);
  123. x++;
  124. y--;
  125. row2y++;
  126. col2y++;
  127. diag1y++;
  128. diag2y++;
  129. }
  130. }
  131. if ((P1.get_x() > -1.0 && P1.get_x() < 1.0) && (P1.get_y() > -3.0) && (P1.get_y() < -1.0)){
  132. if (y == 0){
  133. cwin << Line(Point(-1.0, -1.0), Point(1.0, -3.0));
  134. cwin << Line(Point(-1.0, -3.0), Point(1.0, -1.0));
  135. x++;
  136. y++;
  137. row3x++;
  138. col2x++;
  139. }
  140. if (y == 1){
  141. cwin << Circle(Point(0, -2.0), 1);
  142. x++;
  143. y--;
  144. row3y++;
  145. col2y++;
  146. }
  147. }
  148. if ((P1.get_x() > -3.0 && P1.get_x() < -1.0) && (P1.get_y() > 1.0) && (P1.get_y() < 3.0)){
  149. if (y == 0){
  150. cwin << Line(Point(-3.0, 3.0), Point(-1.0, 1.0));
  151. cwin << Line(Point(-3.0, 1.0), Point(-1.0, 3.0));
  152. x++;
  153. y++;
  154. row1x++;
  155. col3x++;
  156. diag2x++;
  157. }
  158. if (y == 1){
  159. cwin << Circle(Point(-2.0, 2.0), 1);
  160. x++;
  161. y--;
  162. row1y++;
  163. col3y++;
  164. diag2y++;
  165. }
  166. }
  167. if ((P1.get_x() > -3.0 && P1.get_x() < -1.0) && (P1.get_y() > -1.0) && (P1.get_y() < 1.0)){
  168. if (y == 0){
  169. cwin << Line(Point(-3.0, 1.0), Point(-1.0, -1.0));
  170. cwin << Line(Point(-3.0, -1.0), Point(-1.0, 1.0));
  171. x++;
  172. y++;
  173. row2x++;
  174. col3x++;
  175. }
  176. if (y == 1){
  177. cwin << Circle(Point(-2.0, 0), 1);
  178. x++;
  179. y--;
  180. row2y++;
  181. col3y++;
  182. }
  183. }
  184. if ((P1.get_x() > -3.0 && P1.get_x() < -1.0) && (P1.get_y() > -3.0) && (P1.get_y() < -1.0)){
  185. if (y == 0){
  186. cwin << Line(Point(-3.0, -1.0), Point(-1.0, -3.0));
  187. cwin << Line(Point(-3.0, -3.0), Point(-1.0, -1.0));
  188. x++;
  189. y++;
  190. row3x++;
  191. col3x++;
  192. diag1x++;
  193. }
  194. if (y == 1){
  195. cwin << Circle(Point(-2.0, -2.0), 1);
  196. x++;
  197. y--;
  198. row3y++;
  199. col3y++;
  200. diag1y++;
  201. }
  202. }
  203. if (row1y == 3){
  204. x = x + 9;
  205. w--;
  206. cwin << Line(Point(-4.0, 2.0), Point(4.0, 2.0));
  207. }
  208. if (row2y == 3){
  209. x = x + 9;
  210. w--;
  211. cwin << Line(Point(-4.0, 0), Point(4.0, 0));
  212. }
  213. if (row3y == 3){
  214. x = x + 9;
  215. w--;
  216. cwin << Line(Point(-4.0, -2.0), Point(4.0, -2.0));
  217. }
  218. if (row1x == 3){
  219. x = x + 9;
  220. w++;
  221. cwin << Line(Point(-4.0, 2.0), Point(4.0, 2.0));
  222. }
  223. if (row2x == 3){
  224. x = x + 9;
  225. w++;
  226. cwin << Line(Point(-4.0, 0), Point(4.0, 0));
  227. }
  228. if (row3x == 3){
  229. x = x + 9;
  230. w++;
  231. cwin << Line(Point(-4.0, -2.0), Point(4.0, -2.0));
  232. }
  233. if (col1y == 3){
  234. x = x + 9;
  235. w--;
  236. cwin << Line(Point(2.0, 4.0), Point(2.0, -4.0));
  237. }
  238. if (col2y == 3){
  239. x = x + 9;
  240. w--;
  241. cwin << Line(Point(0, 4.0), Point(0, -4.0));
  242. }
  243. if (col3y == 3){
  244. x = x + 9;
  245. w--;
  246. cwin << Line(Point(-2.0, 4.0), Point(-2.0, -4.0));
  247. }
  248. if (col1x == 3){
  249. x = x + 9;
  250. w++;
  251. cwin << Line(Point(2.0, 4.0), Point(2.0, -4.0));
  252. }
  253. if (col2x == 3){
  254. x = x + 9;
  255. w++;
  256. cwin << Line(Point(0, 4.0), Point(0, -4.0));
  257. }
  258. if (col3x == 3){
  259. x = x + 9;
  260. w++;
  261. cwin << Line(Point(-2.0, 4.0), Point(-2.0, -4.0));
  262. }
  263. if (diag1x == 3){
  264. x = x + 9;
  265. w++;
  266. cwin << Line(Point(-4.0, -4.0), Point(4.0, 4.0));
  267. }
  268. if (diag2x == 3){
  269. x = x + 9;
  270. w++;
  271. cwin << Line(Point(-4.0, 4.0), Point(4.0, -4.0));
  272. }
  273. if (diag1y == 3){
  274. x = x + 9;
  275. w--;
  276. cwin << Line(Point(-4.0, -4.0), Point(4.0, 4.0));
  277. }
  278. if (diag2y == 3){
  279. x = x + 9;
  280. w--;
  281. cwin << Line(Point(-4.0, 4.0), Point(4.0, -4.0));
  282. }
  283. }
  284.  
  285. if (x >= 9){
  286. --y;
  287. string s;
  288. cwin << Message(Point(-1.0, -4.0), "Game Over");
  289. cwin << Message(Point(-2.5, -5.5), "Would you like to play again?");
  290. cwin << Message(Point(-2.0, -6.0), "Type yes or no please.");
  291. if (w == 1){
  292. cwin << Message(Point(-0.5, -4.5), "X Wins!");
  293. }
  294. if (w == -1){
  295. cwin << Message(Point(-0.5, -4.5), "O Wins!");
  296. }
  297. if (w == 0){
  298. cwin << Message(Point(-0.6, -4.5), "No Winner");
  299. }
  300. s = cwin.get_string(" ");
  301. if (s == "yes"){
  302. cwin.clear();
  303. cwin << Line(Point(-1.0, 3.0), Point(-1.0, -3.0));
  304. cwin << Line(Point(1.0, 3.0), Point(1.0, -3.0));
  305. cwin << Line(Point(-3.0, 1.0), Point(3.0, 1.0));
  306. cwin << Line(Point(-3.0, -1.0), Point(3.0, -1.0));
  307. x = x - 9;
  308. }
  309. if (s == "no"){
  310. cwin.clear();
  311. cwin << Message(Point(-2.0, 0), "Thank you for playing!");
  312. z++;
  313. }
  314. }
  315. }
  316.  
  317.  
  318.  
  319.  
  320. return 0;
  321. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement