i am totally stumped on what to do here. basically whats goin on is i have a 3D dynamic array and i need to have a cursor inside of it and move around on the inside. i do i go about doing that? like i said im completely stumped.

here is my code:

#include <iostream>
#include <conio.h>
#include "Definitions.h"
using namespace std;


class Darray{
protected:
		int DEPTH,
			  ROW,
			  COL;
		int*** array;

public:
	
	Darray();
	Darray(int depth, int row, int col);
	~Darray();
	Darray(const Darray& darray);						//copy constructor
	Darray& Darray::operator= (const Darray& darray);	//assignment operator

	void getDimensions(int DEPTH, int ROW, int COL);
	void destroy();
	void create();
	void init();
	void resetSize(int DEPTH, int ROW, int COL);
};

Darray::Darray()
{
	DEPTH=0;
	ROW=0;
	COL=0;
	array=NULL;
}

void Darray::create()
{
	array = new int** [DEPTH];
	for(int d=0; d<DEPTH; d++) {
		*(array+d) = new int* [ROW];
		for (int r=0; r<ROW; r++)
			*(*(array+d)+r) = new int [COL];
	}
}

Darray::Darray(int depth, int row, int col)
{
	DEPTH = depth;
	ROW = row;
	COL = col;
	create();
	init();

}

Darray::~Darray()
{
	destroy();
}

Darray::Darray(const Darray& darray)
{
	DEPTH = darray.DEPTH;
	ROW = darray.ROW;
	COL = darray.COL;
	create();

	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = darray.array[d][r][c];
}

Darray& Darray::operator= (const Darray& darray)
{
	resetSize(darray.DEPTH, darray.ROW, darray.COL);

	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = darray.array[d][r][c];
			
			return *this;	
}

void Darray::destroy()
{
	 for (int d=0; d<DEPTH; d++)
	 {
		 for(int r=0; r<ROW; r++)
			 delete [] *(*(array+d)+r);
		 delete [] *(array+d);
	 }
	 delete [] array;
 }


void Darray::init()
{
	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = 0;
}

void Darray::getDimensions(int DEPTH, int ROW, int COL)
{

	cout << "The Depth is: " << DEPTH << "  The Row is: " << ROW
		<< "  The Columns is: " << COL << endl;	
}

void Darray::resetSize(int depth, int row, int col)
{
	destroy();
	DEPTH=depth;
	ROW=row;
	COL=col;
	create();
	init();
}

/***********************************************************************************/
class Grid : public Darray {
private:
	int currentRow,
		currentDepth,
		currentCol;

public:
	Grid();
	void arrow_keys();
	void UsDsFunction(int DEPTH, int ROW, int COL);
	void print () const;
};

Grid::Grid()
{
	int depth,
		row,
		col;


	cout << "Enter the grid dimensions: " << endl;
	cin >> depth >> row >> col;

	// set up dimensions
	DEPTH = depth;
	ROW = row;
	COL = col;

	// set up position
	currentRow = ROW / 2 + 1;
	currentDepth = DEPTH / 2 + 1;
	currentCol = COL / 2 + 1;

	create();

}

void Grid::print () const
{
	
	// makes grid

	//makes top row or grid
	for(int d=0; d<DEPTH; d++)
	{
			if(d<DEPTH)
			{				
					cout << U_L;
					cout << LINE;
			
				for(int c=0; c<COL-1; c++)
				{						
						cout << T_M;
						cout << LINE;
						
				}// end for
									
					cout << U_R;					
					cout << "\n";

					for( c=0; c<COL+1; c++)
					{

					cout << VERT_LINE;
					cout << " ";

					}// end vertical line first row

			}cout << "\n";// end top of grid

		// makes gird middle	
		for(int r=0; r<ROW-1; r++)		
			if(r<ROW)
			{
				cout << L_SM;
				cout << LINE;
		
				for(int c=0; c<COL-1; c++)
					{
						
						cout << M;
						cout << LINE;
					}// end for
				
				
				cout << R_SM;
				cout << "\n";

				for( c=0; c<COL+1; c++)
				{
					cout << VERT_LINE;
					cout << " ";
				}cout << endl;
			}// end middle of grid
			
			// makes last line
			if(d<DEPTH)
			{
				
				cout << L_L;
				cout << LINE;

				for(int c=0; c<COL-1; c++)
					{						
						cout << L_MT;
						cout << LINE;				
					}
			
				cout << L_R;			
			}
			cout << endl;	
			
	}//end last row
	
	
}
void Grid::UsDsFunction(int DEPTH, int ROW, int COL)
{
	int num,
	   num2;
	cout << "would you like to upsize, downsize or keep the dimensions the same? " <<
		"\n\n";
	cout << "Choose an option: " << endl;
	cout << "1.) Upsize" << endl;
	cout << "2.) Downsize" << endl;
	cout << "3.) Keep the same" << endl;
	cin >> num;

	switch (num)
	{
	case 1: 

		resetSize(DEPTH, ROW, COL);



		break;

	case 2:
		
		resetSize(DEPTH, ROW, COL);


		break;

	case 3:

		cout << "Grid staying the same" << endl;
		break;
	}


}


void Grid::arrow_keys()
{
	char key;
	bool flag = false;

	do {
		key = getch();
		switch (toascii(key)) {
		case 96:
		case 224: 
			flag = true;
			break;
		case 72: // up arrow
			if (flag) {
				cout << ACTIVE;
				cout << endl;
				flag = false;
			}
			else 
				cout << "try again. " << endl; 
			break;
		case 77:
			if (flag) { 
				cout << ACTIVE;
				cout << endl;
				flag = false;
			}
			else 
				cout << "try again. " << endl; 
			break;
		case 75:
			if (flag) {
				cout << ACTIVE;
					cout << endl;
				flag = false;
			}
			else 
				cout << "try again. " << endl; 
			break;
		case 80:
			if (flag) {
				cout << ACTIVE;
				cout << endl;
				flag = false;
			}
			else 
				cout << "try again. " << endl; 
			break;
		case 13: 
			cout << "Enter" << endl;
			break;
		default:
			cout << "try again. " << endl;
			break;
		}
	} while (key != 13);
}

/******************************************************************************/
class Cell{
	private:
		 bool visit,
			 active;

	public:
		Cell();
		~Cell();
		void fill();

};

Cell::Cell()
{
	visit = 0;
	active = 0;
}

Cell::~Cell()
{

}
//fill cell when visited
void fill()
{

}


/*******************************************************************************/
void main()
{
	//Darray d;
	Grid g;
	Cell c;
	//d.getDimensions(depth, row, col);
	g.print();

	
	g.arrow_keys();
	//g.UsDsFunction(depth, row, col);
	g.print();

}

i am totally stumped on what to do here. basically whats goin on is i have a 3D dynamic array and i need to have a cursor inside of it and move around on the inside. i do i go about doing that? like i said im completely stumped.

here is my code:

#include <iostream>
#include <conio.h>
#include "Definitions.h"
using namespace std;


class Darray{
protected:
		int DEPTH,
			  ROW,
			  COL;
		int*** array;

public:
	
	Darray();
	Darray(int depth, int row, int col);
	~Darray();
	Darray(const Darray& darray);						//copy constructor
	Darray& Darray::operator= (const Darray& darray);	//assignment operator

	void getDimensions(int DEPTH, int ROW, int COL);
	void destroy();
	void create();
	void init();
	void resetSize(int DEPTH, int ROW, int COL);
};

Darray::Darray()
{
	DEPTH=0;
	ROW=0;
	COL=0;
	array=NULL;
}

void Darray::create()
{
	array = new int** [DEPTH];
	for(int d=0; d<DEPTH; d++) {
		*(array+d) = new int* [ROW];
		for (int r=0; r<ROW; r++)
			*(*(array+d)+r) = new int [COL];
	}
}

Darray::Darray(int depth, int row, int col)
{
	DEPTH = depth;
	ROW = row;
	COL = col;
	create();
	init();

}

Darray::~Darray()
{
	destroy();
}

Darray::Darray(const Darray& darray)
{
	DEPTH = darray.DEPTH;
	ROW = darray.ROW;
	COL = darray.COL;
	create();

	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = darray.array[d][r][c];
}

Darray& Darray::operator= (const Darray& darray)
{
	resetSize(darray.DEPTH, darray.ROW, darray.COL);

	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = darray.array[d][r][c];
			
			return *this;	
}

void Darray::destroy()
{
	 for (int d=0; d<DEPTH; d++)
	 {
		 for(int r=0; r<ROW; r++)
			 delete [] *(*(array+d)+r);
		 delete [] *(array+d);
	 }
	 delete [] array;
 }


void Darray::init()
{
	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = 0;
}

void Darray::getDimensions(int DEPTH, int ROW, int COL)
{

	cout << "The Depth is: " << DEPTH << "  The Row is: " << ROW
		<< "  The Columns is: " << COL << endl;	
}

void Darray::resetSize(int depth, int row, int col)
{
	destroy();
	DEPTH=depth;
	ROW=row;
	COL=col;
	create();
	init();
}

/***********************************************************************************/
class Grid : public Darray {
private:
	int currentRow,
		currentDepth,
		currentCol;

public:
	Grid();
	void arrow_keys();
	void UsDsFunction(int DEPTH, int ROW, int COL);
	void print () const;
};

Grid::Grid()
{
	int depth,
		row,
		col;


	cout << "Enter the grid dimensions: " << endl;
	cin >> depth >> row >> col;

	// set up dimensions
	DEPTH = depth;
	ROW = row;
	COL = col;

	// set up position
	currentRow = ROW / 2 + 1;
	currentDepth = DEPTH / 2 + 1;
	currentCol = COL / 2 + 1;

	create();

}

void Grid::print () const
{
	
	// makes grid

	//makes top row or grid
	for(int d=0; d<DEPTH; d++)
	{
			if(d<DEPTH)
			{				
					cout << U_L;
					cout << LINE;
			
				for(int c=0; c<COL-1; c++)
				{						
						cout << T_M;
						cout << LINE;
						
				}// end for
									
					cout << U_R;					
					cout << "\n";

					for( c=0; c<COL+1; c++)
					{

					cout << VERT_LINE;
					cout << " ";

					}// end vertical line first row

			}cout << "\n";// end top of grid

		// makes gird middle	
		for(int r=0; r<ROW-1; r++)		
			if(r<ROW)
			{
				cout << L_SM;
				cout << LINE;
		
				for(int c=0; c<COL-1; c++)
					{
						
						cout << M;
						cout << LINE;
					}// end for
				
				
				cout << R_SM;
				cout << "\n";

				for( c=0; c<COL+1; c++)
				{
					cout << VERT_LINE;
					cout << " ";
				}cout << endl;
			}// end middle of grid
			
			// makes last line
			if(d<DEPTH)
			{
				
				cout << L_L;
				cout << LINE;

				for(int c=0; c<COL-1; c++)
					{						
						cout << L_MT;
						cout << LINE;				
					}
			
				cout << L_R;			
			}
			cout << endl;	
			
	}//end last row
	
	
}
void Grid::UsDsFunction(int DEPTH, int ROW, int COL)
{
	int num,
	   num2;
	cout << "would you like to upsize, downsize or keep the dimensions the same? " <<
		"\n\n";
	cout << "Choose an option: " << endl;
	cout << "1.) Upsize" << endl;
	cout << "2.) Downsize" << endl;
	cout << "3.) Keep the same" << endl;
	cin >> num;

	switch (num)
	{
	case 1: 

		resetSize(DEPTH, ROW, COL);



		break;

	case 2:
		
		resetSize(DEPTH, ROW, COL);


		break;

	case 3:

		cout << "Grid staying the same" << endl;
		break;
	}


}


void Grid::arrow_keys()
{
	char key;
	bool flag = false;

	do {
		key = getch();
		switch (toascii(key)) {
		case 96:
		case 224: 
			flag = true;
			break;
		case 72: // up arrow
			if (flag) {
				cout << ACTIVE;
				cout << endl;
				flag = false;
			}
			else 
				cout << "try again. " << endl; 
			break;
		case 77:
			if (flag) { 
				cout << ACTIVE;
				cout << endl;
				flag = false;
			}
			else 
				cout << "try again. " << endl; 
			break;
		case 75:
			if (flag) {
				cout << ACTIVE;
					cout << endl;
				flag = false;
			}
			else 
				cout << "try again. " << endl; 
			break;
		case 80:
			if (flag) {
				cout << ACTIVE;
				cout << endl;
				flag = false;
			}
			else 
				cout << "try again. " << endl; 
			break;
		case 13: 
			cout << "Enter" << endl;
			break;
		default:
			cout << "try again. " << endl;
			break;
		}
	} while (key != 13);
}

/******************************************************************************/
class Cell{
	private:
		 bool visit,
			 active;

	public:
		Cell();
		~Cell();
		void fill();

};

Cell::Cell()
{
	visit = 0;
	active = 0;
}

Cell::~Cell()
{

}
//fill cell when visited
void fill()
{

}


/*******************************************************************************/
void main()
{
	//Darray d;
	Grid g;
	Cell c;
	//d.getDimensions(depth, row, col);
	g.print();

	
	g.arrow_keys();
	//g.UsDsFunction(depth, row, col);
	g.print();

}

What's definitions.h?

Supply the file if it has changed from your previous post. Some of your for loops... the variable should be initialised as int c. You've missed that.

Change void main to int main.

What exactly do you mean have a cursor in the 3d array?

thats right i forgot about the definitions file

#define M char (197);
#define U_L char (218);
#define L_L char (192);
#define U_R char (191);
#define L_R char (217);
#define T_M char (194);
#define L_MT char (193);
#define L_SM char (195);
#define R_SM char (180);
#define VERT_LINE char (179);
#define VISIT char (219);
#define LINE  char (196);
#define ACTIVE char (248);

and i mean its like ur playing a video game where u have a player(cursor) and you move the player(cursor) around in the array

This code has it's problems but it's the best I could come up with on the fly.

It doesn't check beyond the bounds of the grid, so be careful of overflow.

The letter 'P' indicates the player.

#include <iostream>
#include <conio.h>
#include <windows.h> 
#include <stdio.h> 

//#include "Definitions.h"
using namespace std;
void clear_da_screen(void);

/* System dependent key codes */
enum
{
  KEY_ESC     = 27,
  ARROW_UP    = 256 + 72,
  ARROW_DOWN  = 256 + 80,
  ARROW_LEFT  = 256 + 75,
  ARROW_RIGHT = 256 + 77
};

static int get_code ( void )
{
  int ch = getch();

  if ( ch == 0 || ch == 224 )
    ch = 256 + getch();

  return ch;
}

int main()
{
    
   
  char crap[5][5];
    for(int i=0; i<5; i++)
    {
        for(int j=0; j<5; j++)
        {
            crap[i][j]='-';
        }
    }    
  
  
  int x,y;
  x=0;
  y=0;
    
  int ch;

  while ( ( ch = get_code() ) != KEY_ESC ) {
      clear_da_screen();
    switch ( ch ) 
    {
    case ARROW_UP:
      printf ( "UP\n" );
      y=y-1;
      break;
    case ARROW_DOWN:
      printf ( "DOWN\n" );
      y=y+1;
      break;
    case ARROW_LEFT:
      printf ( "LEFT\n" );
      x=x-1;
      break;
    case ARROW_RIGHT:
      printf ( "RIGHT\n" );
      x=x+1;
      break;
      
    
    }
    
    crap[y][x]='P';
       for(int i=0; i<5; i++)
      {
        for(int j=0; j<5; j++)
        {
            cout<<crap[i][j]<<" ";
        }cout<<"\n";
      } 
      crap[y][x]='-';
      //break;
      
      
      
  }      
     
     cin.get();
     cin.get(); 
        
}         


void clear_da_screen(void)
{
    COORD                       coordScreen = { 0, 0 };
    DWORD                       cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO  csbi;
    DWORD                       dwConSize;
    HANDLE                      hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    FillConsoleOutputCharacter(hConsole, TEXT(' '), 
                               dwConSize, coordScreen, &cCharsWritten);
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    FillConsoleOutputAttribute(hConsole, csbi.wAttributes, 
                               dwConSize, coordScreen, &cCharsWritten);
    SetConsoleCursorPosition(hConsole, coordScreen);
}

Use the arrow keys to move it up and down. Maybe?

>static int get_code ( void )
It's good to know that someone gets some use out of that function. :)

>static int get_code ( void )
It's good to know that someone gets some use out of that function. :)

Lord knows I got that from somewhere else. Tee he

:cheesy:

[edit] Actually I think some of that directional key moving stuff
was written, or credited to you [/edit] :D

>Lord knows I got that from somewhere else.
cprogramming.com, I imagine. Probably from the programming FAQ where some crazy person named Prelude wrote a HOWTO for using the directional keys in a console mode program. ;)

ok so i tried rewriting it to fit what im trying to do but im gettin a linking error

error LNK2001: unresolved external symbol "public: void __thiscall Grid::clear_da_screen(void)" (?clear_da_screen@Grid@@QAEXXZ)

fatal error LNK1120: 1 unresolved externals

void Grid::arrow_keys()
{
	 array[DEPTH][ROW][COL];
    for(int d=0; d<DEPTH; d++)
    {
        for(int r=0; r<ROW; r++)
        {
			for(int c=0; c<COL; c++)
			{
            array[d][r][c]=' ';
			}
        }
    }    
  
  
  int r,c;
  r=0;
  c=0;
  
    
  int ch;

  while ( ( ch = get_code() ) != KEY_ESC ) {
      clear_da_screen();
    switch ( ch ) 
    {
    case ARROW_UP:
      //printf ( "UP\n" );
      r=r-1;
      break;
    case ARROW_DOWN:
      //printf ( "DOWN\n" );
      r=r+1;
      break;
    case ARROW_LEFT:
      //printf ( "LEFT\n" );
      c=c-1;
      break;
    case ARROW_RIGHT:
      //printf ( "RIGHT\n" );
      c=c+1;
      break;
      
    
    }
    
    array[d][r][c]=ACTIVE;
       for(int d=0; d<DEPTH; d++)
      {
        for(int r=0; r<ROW; r++)
        {
			for(int c=0; c<COL; c++)
			{
            cout<<array[d][r][c]<<" ";
			}
        }cout<<"\n";
      } 
      array[d][r][c]=VISIT;
      //break;
      
      
      
  }      
     
     cin.get();
     cin.get(); 
}

void clear_da_screen(void)
{
    COORD                       coordScreen = { 0, 0 };
    DWORD                       cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO  csbi;
    DWORD                       dwConSize;
    HANDLE                      hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    FillConsoleOutputCharacter(hConsole, TEXT(' '), 
                               dwConSize, coordScreen, &cCharsWritten);
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    FillConsoleOutputAttribute(hConsole, csbi.wAttributes, 
                               dwConSize, coordScreen, &cCharsWritten);
    SetConsoleCursorPosition(hConsole, coordScreen);
}

thats all that u gave me and my attempt at rewriting it

[edit]
never mind stupid mistake on my part it compiles and links fine but it crashes now when i run it
[/edit]

it crashes when i hit one of the arrow keys i took out the function clear_da_screen too but i know thats not the problem

is it because i have an int array and it equaling a char ACTIVE and VISIT

>can you see what i am doing wrong??
Yes, you keep bumping your thread without adding any value.

>it crashes when i hit one of the arrow keys
First make sure that you aren't going beyond the boundaries of your array. Notice how each time you hit an arrow key, an index into the array is changed unconditionally. So, for example, if you decrement r to -1, you'll likely crash.

Let's get a few things straight here.

1. If you wrote that code before, you should have no trouble incorporating my snippet into your own and correcting the overflow, which may be causing your program to crash. Just make sure it doesn't exceed the dimensions of your grid.

2. Most importantly, be aware that creating a game from the console window, is not ideal. It's not portable either and very inflexible.

4. So if you want to look at game programming, then by all means do. In fact you can create good games in c++, it just requires extra libraries...

ok i figured out the arrows but now i have to get the cursors in there

rerwiten grid class

class Grid : public Darray {
private:
	int currentRow,
		currentDepth,
		currentCol;
	bool visit,
		active;

public:
	Grid();
	void arrow_keys();
	void UsFunction();
	void DsFunction();
	void clear_screen(void);
	void print () const;
	void A();
	void V();
	void setact(bool act) {this->active = act;} 
	void setvis(bool vis) {this->visit = vis;}
	void setpoint();
};

Grid::Grid()
{
	int depth,
		row,
		col;


	cout << "Enter the grid dimensions: " << endl;
	cin >> depth >> row >> col;

	// set up dimensions
	DEPTH = depth;
	ROW = row;
	COL = col;

	// set up position
	currentRow = ROW / 2 + 1;
	currentDepth = DEPTH / 2 + 1;
	currentCol = COL / 2 + 1;

	create();

}


void Grid::print () const
{
	
	// makes grid

	//makes top row or grid
	for(int d=0; d<DEPTH; d++)
	{
			if(d<DEPTH)
			{				
					cout << U_L;
					cout << LINE;
			
				for(int c=0; c<COL-1; c++)
				{						
						cout << T_M;
						cout << LINE;
						
				}// end for
									
					cout << U_R;					
					cout << "\n";

					for( c=0; c<COL+1; c++)
					{

					cout << VERT_LINE;
					cout << " ";

					}// end vertical line first row

			}cout << "\n";// end top of grid

		// makes gird middle	
		for(int r=0; r<ROW-1; r++)		
			if(r<ROW)
			{
				cout << L_SM;
				cout << LINE;
		
				for(int c=0; c<COL-1; c++)
					{
						
						cout << M;
						cout << LINE;
					}// end for
				
				
				cout << R_SM;
				cout << "\n";

				for( c=0; c<COL+1; c++)
				{
					cout << VERT_LINE;
					cout << " ";
				}cout << endl;
			}// end middle of grid
			
			// makes last line
			if(d<DEPTH)
			{
				
				cout << L_L;
				cout << LINE;

				for(int c=0; c<COL-1; c++)
					{						
						cout << L_MT;
						cout << LINE;				
					}
			
				cout << L_R;			
			}
			cout << endl;	
			
	}//end last row
	
	
}

void Grid::UsFunction()
{

		resetSize(DEPTH, ROW, COL);

			COL = COL + 2;
			ROW = ROW + 2;


}

void Grid::DsFunction()
{
	resetSize(DEPTH, ROW, COL);

		for(int d=0; d<DEPTH; d++)
				for(int r=0; r<ROW; r++)
					for(int c=0; c<COL; c++)
					{
						array[d][r][c] = array[currentDepth][currentRow-2][currentCol-2];
					}
}



void Grid::A()
{
		array[currentDepth][currentRow][currentCol] = setact(this->true);
		array[currentDepth][currentRow][currentCol] = setpoint(ACTIVE);
		array[currentDepth][currentRow][currentCol] = setvis(this->false);
}

void Grid::V()
{
		array[currentDepth][currentRow][currentCol] = setact(this->false);
		array[currentDepth][currentRow][currentCol] = setpoint(VISIT);
		array[currentDepth][currentRow][currentCol] = setvis(this->true);
}



void Grid::arrow_keys()
{
  
    
  int ch;

  while ( ( ch = get_code() ) != KEY_ESC ) {
      clear_screen();
	  print();
    switch ( ch ) 
    {
    case ARROW_UP:
      printf ( "UP\n" );
			
	  if((currentRow = currentRow-1 >= 0))
	{
		A();
		currentRow = currentRow - 1;
		V();
	}
	  else if((currentRow = currentRow-1 < 0))
	{
		A();
		currentRow = currentRow - 1;
		V();
	}
			  
      break;

    case ARROW_DOWN:
      printf ( "DOWN\n" );

		if(( currentRow = currentRow + 1 <= ROW-1 ))
	{
		A();
		currentRow = currentRow + 1;
		V();
	}
	else if((currentRow = currentRow + 1 >ROW-1 ))
	{
		A();
		currentRow = 0;
		V();
	}

      break;

    case ARROW_LEFT:
      printf ( "LEFT\n" );

	  if(( currentCol = currentCol - 1 <= COL-1 ))
	{
		A();
		currentCol = currentCol - 1;
		V();
	}
	else if((currentCol = currentCol - 1 > COL-1))
	{
		A();
		currentCol = 0;
		V();
	}
      
      break;

    case ARROW_RIGHT:
      printf ( "RIGHT\n" );
	  
	  if((currentCol = currentCol - 1 <= COL-1))
	{
		A();
		currentCol = currentCol - 1;
		V();
	}
	else if((currentCol = currentCol - 1 > COL - 1))
	{
		A();
		currentCol = 0;
		V();
	}
	  
      break;
      
    
    }
   
      
  }      
     
     cin.get();
     cin.get(); 

}

void Grid::clear_screen(void)
{
    COORD                       coordScreen = { 0, 0 };
    DWORD                       cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO  csbi;
    DWORD                       dwConSize;
    HANDLE                      hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    FillConsoleOutputCharacter(hConsole, TEXT(' '), 
                               dwConSize, coordScreen, &cCharsWritten);
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    FillConsoleOutputAttribute(hConsole, csbi.wAttributes, 
                               dwConSize, coordScreen, &cCharsWritten);
    SetConsoleCursorPosition(hConsole, coordScreen);
}
void Grid::A()
{
		array[currentDepth][currentRow][currentCol] = setact(this->true);
		array[currentDepth][currentRow][currentCol] = setpoint(ACTIVE);
		array[currentDepth][currentRow][currentCol] = setvis(this->false);
}

this is my attempt at getting the cursors goin

void Grid::V()
{
		array[currentDepth][currentRow][currentCol] = setact(this->false);
		array[currentDepth][currentRow][currentCol] = setpoint(VISIT);
		array[currentDepth][currentRow][currentCol] = setvis(this->true);
}

but i get a crap load of errors is there a better way to do it? or could u just tell me what im doin wrong

>is there a better way to do it?

Yep, we told you about the inefficiencies of using plain old C++ via the console window and how inflexible your game will be.

You wanna do this in either java, C#, possibly as a windows app (eww) or using a third party library such as Allegro. Tee he he.

well yea but we have to make it in C++ for our class, we have not learned anything else yet

well yea but we have to make it in C++ for our class, we have not learned anything else yet

Well if this is homework, you might be missing a more elegant solution for moving the cursor around on your grid.

I hardly expect your teacher to set you something using the code I threw together. It's ugly non-portable etc.

Ask your teacher, what's the best way forward. He/she set it so they should know. I'm out of ideas on this one.

This article has been dead for over six months. Start a new discussion instead.