Team Blam-GridCode
Revision as of 12:20, 30 September 2010 by Ajcondinho (talk | contribs)
Paste this into a Visual C# project and it will draw a bounding box for a grid of X's
- If you have any changes / upgrades to this code, post here for the benefit of others*
- Edit: Updated it to use an array for grid storage
/* * Basic char array grid creator * Created by: Andrew Condinho * 9/30/2010 */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Console_Move { class Program { static void Main(string[] args) { //create array to hold grid coordinates char[,] gridArray = new char[20, 20]; //populate grid -- !!!replace this with a grid generator!!! for (int i = 0; i < 20; i++) { gridArray[0, i] = 'x'; gridArray[19, i] = 'x'; } for (int i = 1; i < 19; i++) { gridArray[i, 0] = 'x'; gridArray[i, 19] = 'x'; } drawGrid(gridArray); //Grid is useable starting at 1,1 //corner co-ords are //TL: 1,1 //TR: 19,1 //BL: 1,18 //BR: 19,18 Console.SetCursorPosition(0, 21); Console.WriteLine("All done"); } static void drawGrid(char [,] gArray) { int hop = 1; for (int i = 0; i < 20; i++) { for (int x = 0; x < 20; x++) { Console.Write(gArray[i, x]); } Console.SetCursorPosition(0, hop++); } } } }