Advertisement
Guest User

Trianglecheckerwip1

a guest
Feb 16th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. private void Start()
  2. {
  3. //Add your code here
  4.  
  5. int topX = 0;
  6. int topY = 0;
  7. int width = 2;
  8. int height = 5;
  9. int triangleSize = ((width * height)/2);
  10. string color1 = "black";
  11. string color2 = "red";
  12. int columnCount = 8;
  13. int rowCount = 8;
  14.  
  15. //Draw Checkerboard
  16. //Draw Row
  17.  
  18. //Call function for draw row using the variable above AND a new variable for the column size
  19.  
  20.  
  21. //dont use int becuase you already did that. you dont do it whne calling no something
  22. DrawRow(topX, topY, triangleSize, columnCount, color1, color2);
  23. ;
  24. DrawCheckerBoard(topX, topY, triangleSize, columnCount, rowCount, color1, color2);
  25. }
  26.  
  27. public void DrawCheckerBoard(int topX, int topY, int squareSize, int columns, int rows, string color1, string color2)
  28. {
  29. for (int row = 0; row < rows; row++)
  30. {
  31. if (row % 2 == 0)
  32. {
  33. DrawRow(topX, topY + squareSize * row, squareSize, columns, color1, color2);
  34. }
  35. else
  36. {
  37. DrawRow(topX, topY + squareSize * row, squareSize, columns, color2, color1);
  38. }
  39. }
  40. }
  41.  
  42. public void DrawRow(int topX, int topY, int triangleSize, int columns, string color1, string color2)
  43. {
  44. string color = color1;
  45.  
  46. for (int column = 0; column < columns; column++)
  47. {
  48. if (column % 2 == 0)
  49. {
  50. color = color1;
  51. }
  52. else
  53. {
  54. color = color2;
  55. }
  56.  
  57. //shorthand methos of same thing above for DrawRow
  58. //string bonusColor = column % 2 == 0 ? color1 : color2;
  59.  
  60. //DrawTriangle(topX + triangleSize * column, topY, triangleSize, color);
  61.  
  62. //DrawSquare(topX + squareSize * column, topY, squareSize, color);
  63. }
  64. }
  65.  
  66. /// <summary>
  67. /// This function draws a black square using drawer.DrawRectangle
  68. /// </summary>
  69.  
  70. public void DrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, string color)
  71. {
  72. drawer.DrawTriangle(x1, y1, x2, y2, x3, y3, color);
  73. }
  74.  
  75. //public void DrawSquare(int topX, int topY, int size, string color)
  76. //{
  77. // drawer.DrawRectangle(topX, topY, size, size, color);
  78. //}
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement