Console snake game in C#












5














This is my first console application in C# and I think it's unnecessarily wrong and I made some bad practices, but at least it works smoothly. How could I improve this code so that next time I write a console application it won't be as garbled as this?



using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp1 {
class Program {

static readonly int gridW = 90;
static readonly int gridH = 25;
static Cell[, ] grid = new Cell[gridH, gridW];
static Cell currentCell;
static Cell food;
static int FoodCount;
static int direction; //0=Up 1=Right 2=Down 3=Left
static readonly int speed = 1;
static bool Populated = false;
static bool Lost = false;
static int snakeLength;

static void Main(string args) {
if (!Populated) {
FoodCount = 0;
snakeLength = 5;
populateGrid();
currentCell = grid[(int) Math.Ceiling((double) gridH / 2), (int) Math.Ceiling((double) gridW / 2)];
updatePos();
addFood();
Populated = true;
}

while (!Lost) {
Restart();
}
}

static void Restart() {
Console.SetCursorPosition(0, 0);
printGrid();
Console.WriteLine("Length: {0}", snakeLength);
getInput();
}

static void updateScreen() {
Console.SetCursorPosition(0, 0);
printGrid();
Console.WriteLine("Length: {0}", snakeLength);
}

static void getInput() {

//Console.Write("Where to move? [WASD] ");
ConsoleKeyInfo input;
while (!Console.KeyAvailable) {
Move();
updateScreen();
}
input = Console.ReadKey();
doInput(input.KeyChar);
}

static void checkCell(Cell cell) {
if (cell.val == "%") {
eatFood();
}
if (cell.visited) {
Lose();
}
}

static void Lose() {
Console.WriteLine("n You lose!");
Thread.Sleep(1000);
Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
Environment.Exit(-1);
}

static void doInput(char inp) {
switch (inp) {
case 'w':
goUp();
break;
case 's':
goDown();
break;
case 'a':
goRight();
break;
case 'd':
goLeft();
break;
}
}

static void addFood() {
Random r = new Random();
Cell cell;
while (true) {
cell = grid[r.Next(grid.GetLength(0)), r.Next(grid.GetLength(1))];
if (cell.val == " ")
cell.val = "%";
break;
}
}

static void eatFood() {
snakeLength += 1;
addFood();
}

static void goUp() {
if (direction == 2)
return;
direction = 0;
}

static void goRight() {
if (direction == 3)
return;
direction = 1;
}

static void goDown() {
if (direction == 0)
return;
direction = 2;
}

static void goLeft() {
if (direction == 1)
return;
direction = 3;
}

static void Move() {
if (direction == 0) {
//up
if (grid[currentCell.y - 1, currentCell.x].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y - 1, currentCell.x]);
} else if (direction == 1) {
//right
if (grid[currentCell.y, currentCell.x - 1].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y, currentCell.x - 1]);
} else if (direction == 2) {
//down
if (grid[currentCell.y + 1, currentCell.x].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y + 1, currentCell.x]);
} else if (direction == 3) {
//left
if (grid[currentCell.y, currentCell.x + 1].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y, currentCell.x + 1]);
}
Thread.Sleep(speed * 100);
}

static void visitCell(Cell cell) {
currentCell.val = "#";
currentCell.visited = true;
currentCell.decay = snakeLength;
checkCell(cell);
currentCell = cell;
updatePos();

//checkCell(currentCell);
}

static void updatePos() {

currentCell.Set("@");
if (direction == 0) {
currentCell.val = "^";
} else if (direction == 1) {
currentCell.val = "<";
} else if (direction == 2) {
currentCell.val = "v";
} else if (direction == 3) {
currentCell.val = ">";
}

currentCell.visited = false;
return;
}

static void populateGrid() {
Random random = new Random();
for (int col = 0; col < gridH; col++) {
for (int row = 0; row < gridW; row++) {
Cell cell = new Cell();
cell.x = row;
cell.y = col;
cell.visited = false;
if (cell.x == 0 || cell.x > gridW - 2 || cell.y == 0 || cell.y > gridH - 2)
cell.Set("*");
else
cell.Clear();
grid[col, row] = cell;
}
}
}

static void printGrid() {
string toPrint = "";
for (int col = 0; col < gridH; col++) {
for (int row = 0; row < gridW; row++) {
grid[col, row].decaySnake();
toPrint += grid[col, row].val;

}
toPrint += "n";
}
Console.WriteLine(toPrint);
}
public class Cell {
public string val {
get;
set;
}
public int x {
get;
set;
}
public int y {
get;
set;
}
public bool visited {
get;
set;
}
public int decay {
get;
set;
}

public void decaySnake() {
decay -= 1;
if (decay == 0) {
visited = false;
val = " ";
}
}

public void Clear() {
val = " ";
}

public void Set(string newVal) {
val = newVal;
}
}
}
}









share|improve this question









New contributor




Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Does that code work as intended?
    – πάντα ῥεῖ
    Jan 3 at 19:16










  • it appears to run when I try it on onlinegdb though that interactive interface isn't optimal...
    – Sᴀᴍ Onᴇᴌᴀ
    Jan 3 at 19:27










  • @SᴀᴍOnᴇᴌᴀ i didnt intend it to be used in online interpreters, i wrote it in visual studio
    – Terradice
    Jan 3 at 19:35










  • I know - I just wanted to test it without VS
    – Sᴀᴍ Onᴇᴌᴀ
    Jan 3 at 19:35
















5














This is my first console application in C# and I think it's unnecessarily wrong and I made some bad practices, but at least it works smoothly. How could I improve this code so that next time I write a console application it won't be as garbled as this?



using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp1 {
class Program {

static readonly int gridW = 90;
static readonly int gridH = 25;
static Cell[, ] grid = new Cell[gridH, gridW];
static Cell currentCell;
static Cell food;
static int FoodCount;
static int direction; //0=Up 1=Right 2=Down 3=Left
static readonly int speed = 1;
static bool Populated = false;
static bool Lost = false;
static int snakeLength;

static void Main(string args) {
if (!Populated) {
FoodCount = 0;
snakeLength = 5;
populateGrid();
currentCell = grid[(int) Math.Ceiling((double) gridH / 2), (int) Math.Ceiling((double) gridW / 2)];
updatePos();
addFood();
Populated = true;
}

while (!Lost) {
Restart();
}
}

static void Restart() {
Console.SetCursorPosition(0, 0);
printGrid();
Console.WriteLine("Length: {0}", snakeLength);
getInput();
}

static void updateScreen() {
Console.SetCursorPosition(0, 0);
printGrid();
Console.WriteLine("Length: {0}", snakeLength);
}

static void getInput() {

//Console.Write("Where to move? [WASD] ");
ConsoleKeyInfo input;
while (!Console.KeyAvailable) {
Move();
updateScreen();
}
input = Console.ReadKey();
doInput(input.KeyChar);
}

static void checkCell(Cell cell) {
if (cell.val == "%") {
eatFood();
}
if (cell.visited) {
Lose();
}
}

static void Lose() {
Console.WriteLine("n You lose!");
Thread.Sleep(1000);
Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
Environment.Exit(-1);
}

static void doInput(char inp) {
switch (inp) {
case 'w':
goUp();
break;
case 's':
goDown();
break;
case 'a':
goRight();
break;
case 'd':
goLeft();
break;
}
}

static void addFood() {
Random r = new Random();
Cell cell;
while (true) {
cell = grid[r.Next(grid.GetLength(0)), r.Next(grid.GetLength(1))];
if (cell.val == " ")
cell.val = "%";
break;
}
}

static void eatFood() {
snakeLength += 1;
addFood();
}

static void goUp() {
if (direction == 2)
return;
direction = 0;
}

static void goRight() {
if (direction == 3)
return;
direction = 1;
}

static void goDown() {
if (direction == 0)
return;
direction = 2;
}

static void goLeft() {
if (direction == 1)
return;
direction = 3;
}

static void Move() {
if (direction == 0) {
//up
if (grid[currentCell.y - 1, currentCell.x].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y - 1, currentCell.x]);
} else if (direction == 1) {
//right
if (grid[currentCell.y, currentCell.x - 1].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y, currentCell.x - 1]);
} else if (direction == 2) {
//down
if (grid[currentCell.y + 1, currentCell.x].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y + 1, currentCell.x]);
} else if (direction == 3) {
//left
if (grid[currentCell.y, currentCell.x + 1].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y, currentCell.x + 1]);
}
Thread.Sleep(speed * 100);
}

static void visitCell(Cell cell) {
currentCell.val = "#";
currentCell.visited = true;
currentCell.decay = snakeLength;
checkCell(cell);
currentCell = cell;
updatePos();

//checkCell(currentCell);
}

static void updatePos() {

currentCell.Set("@");
if (direction == 0) {
currentCell.val = "^";
} else if (direction == 1) {
currentCell.val = "<";
} else if (direction == 2) {
currentCell.val = "v";
} else if (direction == 3) {
currentCell.val = ">";
}

currentCell.visited = false;
return;
}

static void populateGrid() {
Random random = new Random();
for (int col = 0; col < gridH; col++) {
for (int row = 0; row < gridW; row++) {
Cell cell = new Cell();
cell.x = row;
cell.y = col;
cell.visited = false;
if (cell.x == 0 || cell.x > gridW - 2 || cell.y == 0 || cell.y > gridH - 2)
cell.Set("*");
else
cell.Clear();
grid[col, row] = cell;
}
}
}

static void printGrid() {
string toPrint = "";
for (int col = 0; col < gridH; col++) {
for (int row = 0; row < gridW; row++) {
grid[col, row].decaySnake();
toPrint += grid[col, row].val;

}
toPrint += "n";
}
Console.WriteLine(toPrint);
}
public class Cell {
public string val {
get;
set;
}
public int x {
get;
set;
}
public int y {
get;
set;
}
public bool visited {
get;
set;
}
public int decay {
get;
set;
}

public void decaySnake() {
decay -= 1;
if (decay == 0) {
visited = false;
val = " ";
}
}

public void Clear() {
val = " ";
}

public void Set(string newVal) {
val = newVal;
}
}
}
}









share|improve this question









New contributor




Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Does that code work as intended?
    – πάντα ῥεῖ
    Jan 3 at 19:16










  • it appears to run when I try it on onlinegdb though that interactive interface isn't optimal...
    – Sᴀᴍ Onᴇᴌᴀ
    Jan 3 at 19:27










  • @SᴀᴍOnᴇᴌᴀ i didnt intend it to be used in online interpreters, i wrote it in visual studio
    – Terradice
    Jan 3 at 19:35










  • I know - I just wanted to test it without VS
    – Sᴀᴍ Onᴇᴌᴀ
    Jan 3 at 19:35














5












5








5







This is my first console application in C# and I think it's unnecessarily wrong and I made some bad practices, but at least it works smoothly. How could I improve this code so that next time I write a console application it won't be as garbled as this?



using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp1 {
class Program {

static readonly int gridW = 90;
static readonly int gridH = 25;
static Cell[, ] grid = new Cell[gridH, gridW];
static Cell currentCell;
static Cell food;
static int FoodCount;
static int direction; //0=Up 1=Right 2=Down 3=Left
static readonly int speed = 1;
static bool Populated = false;
static bool Lost = false;
static int snakeLength;

static void Main(string args) {
if (!Populated) {
FoodCount = 0;
snakeLength = 5;
populateGrid();
currentCell = grid[(int) Math.Ceiling((double) gridH / 2), (int) Math.Ceiling((double) gridW / 2)];
updatePos();
addFood();
Populated = true;
}

while (!Lost) {
Restart();
}
}

static void Restart() {
Console.SetCursorPosition(0, 0);
printGrid();
Console.WriteLine("Length: {0}", snakeLength);
getInput();
}

static void updateScreen() {
Console.SetCursorPosition(0, 0);
printGrid();
Console.WriteLine("Length: {0}", snakeLength);
}

static void getInput() {

//Console.Write("Where to move? [WASD] ");
ConsoleKeyInfo input;
while (!Console.KeyAvailable) {
Move();
updateScreen();
}
input = Console.ReadKey();
doInput(input.KeyChar);
}

static void checkCell(Cell cell) {
if (cell.val == "%") {
eatFood();
}
if (cell.visited) {
Lose();
}
}

static void Lose() {
Console.WriteLine("n You lose!");
Thread.Sleep(1000);
Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
Environment.Exit(-1);
}

static void doInput(char inp) {
switch (inp) {
case 'w':
goUp();
break;
case 's':
goDown();
break;
case 'a':
goRight();
break;
case 'd':
goLeft();
break;
}
}

static void addFood() {
Random r = new Random();
Cell cell;
while (true) {
cell = grid[r.Next(grid.GetLength(0)), r.Next(grid.GetLength(1))];
if (cell.val == " ")
cell.val = "%";
break;
}
}

static void eatFood() {
snakeLength += 1;
addFood();
}

static void goUp() {
if (direction == 2)
return;
direction = 0;
}

static void goRight() {
if (direction == 3)
return;
direction = 1;
}

static void goDown() {
if (direction == 0)
return;
direction = 2;
}

static void goLeft() {
if (direction == 1)
return;
direction = 3;
}

static void Move() {
if (direction == 0) {
//up
if (grid[currentCell.y - 1, currentCell.x].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y - 1, currentCell.x]);
} else if (direction == 1) {
//right
if (grid[currentCell.y, currentCell.x - 1].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y, currentCell.x - 1]);
} else if (direction == 2) {
//down
if (grid[currentCell.y + 1, currentCell.x].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y + 1, currentCell.x]);
} else if (direction == 3) {
//left
if (grid[currentCell.y, currentCell.x + 1].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y, currentCell.x + 1]);
}
Thread.Sleep(speed * 100);
}

static void visitCell(Cell cell) {
currentCell.val = "#";
currentCell.visited = true;
currentCell.decay = snakeLength;
checkCell(cell);
currentCell = cell;
updatePos();

//checkCell(currentCell);
}

static void updatePos() {

currentCell.Set("@");
if (direction == 0) {
currentCell.val = "^";
} else if (direction == 1) {
currentCell.val = "<";
} else if (direction == 2) {
currentCell.val = "v";
} else if (direction == 3) {
currentCell.val = ">";
}

currentCell.visited = false;
return;
}

static void populateGrid() {
Random random = new Random();
for (int col = 0; col < gridH; col++) {
for (int row = 0; row < gridW; row++) {
Cell cell = new Cell();
cell.x = row;
cell.y = col;
cell.visited = false;
if (cell.x == 0 || cell.x > gridW - 2 || cell.y == 0 || cell.y > gridH - 2)
cell.Set("*");
else
cell.Clear();
grid[col, row] = cell;
}
}
}

static void printGrid() {
string toPrint = "";
for (int col = 0; col < gridH; col++) {
for (int row = 0; row < gridW; row++) {
grid[col, row].decaySnake();
toPrint += grid[col, row].val;

}
toPrint += "n";
}
Console.WriteLine(toPrint);
}
public class Cell {
public string val {
get;
set;
}
public int x {
get;
set;
}
public int y {
get;
set;
}
public bool visited {
get;
set;
}
public int decay {
get;
set;
}

public void decaySnake() {
decay -= 1;
if (decay == 0) {
visited = false;
val = " ";
}
}

public void Clear() {
val = " ";
}

public void Set(string newVal) {
val = newVal;
}
}
}
}









share|improve this question









New contributor




Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











This is my first console application in C# and I think it's unnecessarily wrong and I made some bad practices, but at least it works smoothly. How could I improve this code so that next time I write a console application it won't be as garbled as this?



using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp1 {
class Program {

static readonly int gridW = 90;
static readonly int gridH = 25;
static Cell[, ] grid = new Cell[gridH, gridW];
static Cell currentCell;
static Cell food;
static int FoodCount;
static int direction; //0=Up 1=Right 2=Down 3=Left
static readonly int speed = 1;
static bool Populated = false;
static bool Lost = false;
static int snakeLength;

static void Main(string args) {
if (!Populated) {
FoodCount = 0;
snakeLength = 5;
populateGrid();
currentCell = grid[(int) Math.Ceiling((double) gridH / 2), (int) Math.Ceiling((double) gridW / 2)];
updatePos();
addFood();
Populated = true;
}

while (!Lost) {
Restart();
}
}

static void Restart() {
Console.SetCursorPosition(0, 0);
printGrid();
Console.WriteLine("Length: {0}", snakeLength);
getInput();
}

static void updateScreen() {
Console.SetCursorPosition(0, 0);
printGrid();
Console.WriteLine("Length: {0}", snakeLength);
}

static void getInput() {

//Console.Write("Where to move? [WASD] ");
ConsoleKeyInfo input;
while (!Console.KeyAvailable) {
Move();
updateScreen();
}
input = Console.ReadKey();
doInput(input.KeyChar);
}

static void checkCell(Cell cell) {
if (cell.val == "%") {
eatFood();
}
if (cell.visited) {
Lose();
}
}

static void Lose() {
Console.WriteLine("n You lose!");
Thread.Sleep(1000);
Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
Environment.Exit(-1);
}

static void doInput(char inp) {
switch (inp) {
case 'w':
goUp();
break;
case 's':
goDown();
break;
case 'a':
goRight();
break;
case 'd':
goLeft();
break;
}
}

static void addFood() {
Random r = new Random();
Cell cell;
while (true) {
cell = grid[r.Next(grid.GetLength(0)), r.Next(grid.GetLength(1))];
if (cell.val == " ")
cell.val = "%";
break;
}
}

static void eatFood() {
snakeLength += 1;
addFood();
}

static void goUp() {
if (direction == 2)
return;
direction = 0;
}

static void goRight() {
if (direction == 3)
return;
direction = 1;
}

static void goDown() {
if (direction == 0)
return;
direction = 2;
}

static void goLeft() {
if (direction == 1)
return;
direction = 3;
}

static void Move() {
if (direction == 0) {
//up
if (grid[currentCell.y - 1, currentCell.x].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y - 1, currentCell.x]);
} else if (direction == 1) {
//right
if (grid[currentCell.y, currentCell.x - 1].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y, currentCell.x - 1]);
} else if (direction == 2) {
//down
if (grid[currentCell.y + 1, currentCell.x].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y + 1, currentCell.x]);
} else if (direction == 3) {
//left
if (grid[currentCell.y, currentCell.x + 1].val == "*") {
Lose();
return;
}
visitCell(grid[currentCell.y, currentCell.x + 1]);
}
Thread.Sleep(speed * 100);
}

static void visitCell(Cell cell) {
currentCell.val = "#";
currentCell.visited = true;
currentCell.decay = snakeLength;
checkCell(cell);
currentCell = cell;
updatePos();

//checkCell(currentCell);
}

static void updatePos() {

currentCell.Set("@");
if (direction == 0) {
currentCell.val = "^";
} else if (direction == 1) {
currentCell.val = "<";
} else if (direction == 2) {
currentCell.val = "v";
} else if (direction == 3) {
currentCell.val = ">";
}

currentCell.visited = false;
return;
}

static void populateGrid() {
Random random = new Random();
for (int col = 0; col < gridH; col++) {
for (int row = 0; row < gridW; row++) {
Cell cell = new Cell();
cell.x = row;
cell.y = col;
cell.visited = false;
if (cell.x == 0 || cell.x > gridW - 2 || cell.y == 0 || cell.y > gridH - 2)
cell.Set("*");
else
cell.Clear();
grid[col, row] = cell;
}
}
}

static void printGrid() {
string toPrint = "";
for (int col = 0; col < gridH; col++) {
for (int row = 0; row < gridW; row++) {
grid[col, row].decaySnake();
toPrint += grid[col, row].val;

}
toPrint += "n";
}
Console.WriteLine(toPrint);
}
public class Cell {
public string val {
get;
set;
}
public int x {
get;
set;
}
public int y {
get;
set;
}
public bool visited {
get;
set;
}
public int decay {
get;
set;
}

public void decaySnake() {
decay -= 1;
if (decay == 0) {
visited = false;
val = " ";
}
}

public void Clear() {
val = " ";
}

public void Set(string newVal) {
val = newVal;
}
}
}
}






c# game console snake-game






share|improve this question









New contributor




Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Jan 4 at 2:10









Jamal

30.3k11116226




30.3k11116226






New contributor




Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Jan 3 at 19:14









Terradice

262




262




New contributor




Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Terradice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Does that code work as intended?
    – πάντα ῥεῖ
    Jan 3 at 19:16










  • it appears to run when I try it on onlinegdb though that interactive interface isn't optimal...
    – Sᴀᴍ Onᴇᴌᴀ
    Jan 3 at 19:27










  • @SᴀᴍOnᴇᴌᴀ i didnt intend it to be used in online interpreters, i wrote it in visual studio
    – Terradice
    Jan 3 at 19:35










  • I know - I just wanted to test it without VS
    – Sᴀᴍ Onᴇᴌᴀ
    Jan 3 at 19:35


















  • Does that code work as intended?
    – πάντα ῥεῖ
    Jan 3 at 19:16










  • it appears to run when I try it on onlinegdb though that interactive interface isn't optimal...
    – Sᴀᴍ Onᴇᴌᴀ
    Jan 3 at 19:27










  • @SᴀᴍOnᴇᴌᴀ i didnt intend it to be used in online interpreters, i wrote it in visual studio
    – Terradice
    Jan 3 at 19:35










  • I know - I just wanted to test it without VS
    – Sᴀᴍ Onᴇᴌᴀ
    Jan 3 at 19:35
















Does that code work as intended?
– πάντα ῥεῖ
Jan 3 at 19:16




Does that code work as intended?
– πάντα ῥεῖ
Jan 3 at 19:16












it appears to run when I try it on onlinegdb though that interactive interface isn't optimal...
– Sᴀᴍ Onᴇᴌᴀ
Jan 3 at 19:27




it appears to run when I try it on onlinegdb though that interactive interface isn't optimal...
– Sᴀᴍ Onᴇᴌᴀ
Jan 3 at 19:27












@SᴀᴍOnᴇᴌᴀ i didnt intend it to be used in online interpreters, i wrote it in visual studio
– Terradice
Jan 3 at 19:35




@SᴀᴍOnᴇᴌᴀ i didnt intend it to be used in online interpreters, i wrote it in visual studio
– Terradice
Jan 3 at 19:35












I know - I just wanted to test it without VS
– Sᴀᴍ Onᴇᴌᴀ
Jan 3 at 19:35




I know - I just wanted to test it without VS
– Sᴀᴍ Onᴇᴌᴀ
Jan 3 at 19:35










0






active

oldest

votes











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");

StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Terradice is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f210835%2fconsole-snake-game-in-c%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Terradice is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Terradice is a new contributor. Be nice, and check out our Code of Conduct.













Terradice is a new contributor. Be nice, and check out our Code of Conduct.












Terradice is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Code Review Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f210835%2fconsole-snake-game-in-c%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Список кардиналов, возведённых папой римским Каликстом III

Deduzione

Mysql.sock missing - “Can't connect to local MySQL server through socket”