Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using XOR.Library;
  8.  
  9. namespace VirusSpread
  10. {
  11. class Program
  12. {
  13. static System.Threading.Timer TTimer = null;
  14. static Game game = null;
  15.  
  16. static int qOffset = 10;
  17. static int w = 1200;
  18. static int h = 800;
  19.  
  20. static Texture black;
  21. static Texture green;
  22. static Texture red;
  23. static Texture blue;
  24.  
  25. static List<GameObject2D> squares = new List<GameObject2D>();
  26.  
  27. static void Main(string[] args)
  28. {
  29. game = Game.create(1200, 800);
  30.  
  31. List<Vector2> qVec1 = new List<Vector2>();
  32. for (int i = 0; i < w/qOffset; i+=2)
  33. {
  34. qVec1.Add(Vector2.create(i * qOffset,0));
  35. qVec1.Add(Vector2.create(i * qOffset, h));
  36. qVec1.Add(Vector2.create((i * qOffset) + qOffset, h));
  37. qVec1.Add(Vector2.create((i * qOffset) + qOffset, 0));
  38. qVec1.Add(Vector2.create((i * qOffset) + 2*qOffset, 0));
  39. }
  40.  
  41. List<Vector2> qVec2 = new List<Vector2>();
  42. for (int i = 0; i < w / qOffset; i += 2)
  43. {
  44. qVec2.Add(Vector2.create(0, i * qOffset));
  45. qVec2.Add(Vector2.create(w, i * qOffset));
  46. qVec2.Add(Vector2.create(w, (i * qOffset) + qOffset));
  47. qVec2.Add(Vector2.create(0, (i * qOffset) + qOffset));
  48. qVec2.Add(Vector2.create(0, (i * qOffset) + 2 * qOffset));
  49. }
  50.  
  51. LineRenderer ln1 = new LineRenderer(qVec1.ToArray(), System.Drawing.Color.LightGray, 2);
  52. ln1.Instantiate();
  53. LineRenderer ln2 = new LineRenderer(qVec2.ToArray(), System.Drawing.Color.LightGray, 2);
  54. ln2.Instantiate();
  55.  
  56. TTimer = new System.Threading.Timer(
  57. new TimerCallback(TickTimer),
  58. null,
  59. 1000,
  60. 1);
  61.  
  62. black = Content.Load<Texture>(AppDomain.CurrentDomain.BaseDirectory + @"\images\Solid_black.png", TextureResizeType.RESIZE, qOffset, qOffset);
  63. green = Content.Load<Texture>(AppDomain.CurrentDomain.BaseDirectory + @"\images\Green_square.svg.png", TextureResizeType.RESIZE, qOffset, qOffset);
  64. blue = Content.Load<Texture>(AppDomain.CurrentDomain.BaseDirectory + @"\images\1200px-000080_Navy_Blue_Square.svg.png", TextureResizeType.RESIZE, qOffset, qOffset);
  65. red = Content.Load<Texture>(AppDomain.CurrentDomain.BaseDirectory + @"\images\red.png", TextureResizeType.RESIZE, qOffset, qOffset);
  66.  
  67. Random r = new Random();
  68. for (int j = 0; j < h / qOffset; j++)
  69. {
  70. for (int i = 0; i < w / qOffset; i++)
  71. {
  72. int o = r.Next(0, 2);
  73. if (o == 0)
  74. {
  75. GameObject2D gm = GameObject2D.create(i * qOffset, j * qOffset, green);
  76. gm.Instantiate();
  77. squares.Add(gm);
  78. }
  79. else if (o == 1)
  80. {
  81. GameObject2D gm = GameObject2D.create(i * qOffset, j * qOffset, blue);
  82. gm.Instantiate();
  83. squares.Add(gm);
  84. }
  85. }
  86. }
  87.  
  88. game.Run();
  89. }
  90.  
  91. static void DrawSquare(int x,int y,Texture t)
  92. {
  93. squares[y * (w / qOffset) + x].graphics = t;
  94. }
  95.  
  96. static GameObject2D GetGameObjectFromSquareArray(int x, int y)
  97. {
  98. return squares[y * (w / qOffset) + x];
  99. }
  100.  
  101. static void TickTimer(object state)
  102. {
  103. if (Input.GetKey(Input.Keys.K))
  104. {
  105. DrawSquare((w/qOffset/2)-1, (h/qOffset/2)-1, red);
  106. }
  107. }
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement