Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using XOR.Library;
- namespace VirusSpread
- {
- class Program
- {
- static System.Threading.Timer TTimer = null;
- static Game game = null;
- static int qOffset = 10;
- static int w = 1200;
- static int h = 800;
- static Texture black;
- static Texture green;
- static Texture red;
- static Texture blue;
- static List<GameObject2D> squares = new List<GameObject2D>();
- static void Main(string[] args)
- {
- game = Game.create(1200, 800);
- List<Vector2> qVec1 = new List<Vector2>();
- for (int i = 0; i < w/qOffset; i+=2)
- {
- qVec1.Add(Vector2.create(i * qOffset,0));
- qVec1.Add(Vector2.create(i * qOffset, h));
- qVec1.Add(Vector2.create((i * qOffset) + qOffset, h));
- qVec1.Add(Vector2.create((i * qOffset) + qOffset, 0));
- qVec1.Add(Vector2.create((i * qOffset) + 2*qOffset, 0));
- }
- List<Vector2> qVec2 = new List<Vector2>();
- for (int i = 0; i < w / qOffset; i += 2)
- {
- qVec2.Add(Vector2.create(0, i * qOffset));
- qVec2.Add(Vector2.create(w, i * qOffset));
- qVec2.Add(Vector2.create(w, (i * qOffset) + qOffset));
- qVec2.Add(Vector2.create(0, (i * qOffset) + qOffset));
- qVec2.Add(Vector2.create(0, (i * qOffset) + 2 * qOffset));
- }
- LineRenderer ln1 = new LineRenderer(qVec1.ToArray(), System.Drawing.Color.LightGray, 2);
- ln1.Instantiate();
- LineRenderer ln2 = new LineRenderer(qVec2.ToArray(), System.Drawing.Color.LightGray, 2);
- ln2.Instantiate();
- TTimer = new System.Threading.Timer(
- new TimerCallback(TickTimer),
- null,
- 1000,
- 1);
- black = Content.Load<Texture>(AppDomain.CurrentDomain.BaseDirectory + @"\images\Solid_black.png", TextureResizeType.RESIZE, qOffset, qOffset);
- green = Content.Load<Texture>(AppDomain.CurrentDomain.BaseDirectory + @"\images\Green_square.svg.png", TextureResizeType.RESIZE, qOffset, qOffset);
- blue = Content.Load<Texture>(AppDomain.CurrentDomain.BaseDirectory + @"\images\1200px-000080_Navy_Blue_Square.svg.png", TextureResizeType.RESIZE, qOffset, qOffset);
- red = Content.Load<Texture>(AppDomain.CurrentDomain.BaseDirectory + @"\images\red.png", TextureResizeType.RESIZE, qOffset, qOffset);
- Random r = new Random();
- for (int j = 0; j < h / qOffset; j++)
- {
- for (int i = 0; i < w / qOffset; i++)
- {
- int o = r.Next(0, 2);
- if (o == 0)
- {
- GameObject2D gm = GameObject2D.create(i * qOffset, j * qOffset, green);
- gm.Instantiate();
- squares.Add(gm);
- }
- else if (o == 1)
- {
- GameObject2D gm = GameObject2D.create(i * qOffset, j * qOffset, blue);
- gm.Instantiate();
- squares.Add(gm);
- }
- }
- }
- game.Run();
- }
- static void DrawSquare(int x,int y,Texture t)
- {
- squares[y * (w / qOffset) + x].graphics = t;
- }
- static GameObject2D GetGameObjectFromSquareArray(int x, int y)
- {
- return squares[y * (w / qOffset) + x];
- }
- static void TickTimer(object state)
- {
- if (Input.GetKey(Input.Keys.K))
- {
- DrawSquare((w/qOffset/2)-1, (h/qOffset/2)-1, red);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement