Hello guys! :)

I have problem finding out, about why the author if the code i have. Uses array like this:

int past[1000][2]; and says that 0 is side, and 1 is up.

Does he mean that:

past[pastCounter][0]; is for up,and down (x)
past[pastCounter][1]; is for sides (y)

Appreciate all help! :)
btw a snake game.

Yea I believe thats what the author meant, although its not good code.

ahh damm, but how can i explaing it to my teacher, that 0 is x and 1 is y?

And what happens if:

1. past[pastCounter][0]=1;
2. past[pastCounter][1]=1;

Pastcounter is 6

what happens here:
	void control (int &direction)
{//kontrollere brugeres indput
	int key = 0;
	if (kbhit())
		switch (getch())
		case 72:
			direction = 2;
			break;  //up
		case 77:
			direction = 0;
			break; //right
		case 80:
			direction = 3;
			break; //down
		case 75:
			direction = 1;
			break; //left
void directionn(int direction, int &pastCounter, int past[][2])
{ //Gælder spillerens bevægelse, som bestemmer slangens retning
	int right;//adder til array
	int down;
	right = past[pastCounter][1];
	down = past[pastCounter][0];
	switch (direction)
	{  //Slangens retning
	case 0:
		right ++; //højre
	case 1:
		right --; //vensre
	case 2:
		down --;
	case 3:
		down ++;

	pastCounter ++;
	past[pastCounter][0] = down;
	past[pastCounter][1] = right;

You should really use constants like so :

const int COORD_X = 0;
const int COORD_Y = 1;
const int LEFT = 0;

int past[1000][2]; and says that 0 is side, and 1 is up.

Just so we are clear, past[0] should move the snake sideways, that is left and right
and past[1000][1] should move the snake up and down

thanks m8, i cant edit it! i have to explain exactly this code for my teacher ;(

1. So if you want to help me, explain what happens when:

right = past[pastCounter][1]; //When right is ++ or --, if u can m8 :)

2. and what this mean:
past[pastCounter][0]=1; // why =1 ? what does that mean O.o

THANKS, i have examination, and i am allowed to get help, the important part that i understand and can explain it. And i have only had 30 school hours :) Its basic examination, but i have to explaain evverything :) Just that code, i dont understand so good :(

Do you have to explain code someone else wrote for your exam?

yeah nathan, our asignment is not to make our own code. Our assignment is like, we get a game:


then we have to find, a code, because of lacking lessons(only 30 hours). Then we have to rewrite the code, and try making changes. That way, we learn much more. And can show our, understanding of the code.

Under the examination, i will change it in front of them, they will ask me to change that and that. And make some addition, and i will. Its denmark :b

Nathan do you understand the code in previous post?

>>right = past[pastCounter][1]; //When right is ++ or --, if u can m8

That means it increases the position of the snake to the right by one unit


I have to see in what context it was used, but my guess would be that to start it off an location 1.