I'm trying to make a program that makes a cartesian plane; you input the basic information of the line and it draws the line.
Too bad that it doesn't work well. Basically this is the loop that puts an X char in every point of the line:
for(int x=0;x<MAP_HEIGHT;x++)
{
piano.griglia[x][a*x+b]='X';
}
But it does not work well! here is the result:
Notice how there are 3 lines where there should be only one. Here's the code of the plane, it may help:
class Cartesiano
{
public:
char griglia[MAP_LENGHT+1][MAP_HEIGHT+1];
Cartesiano( void )
{
for(int y=0;y<=MAP_HEIGHT;y++)
{
for(int x=0;x<=MAP_LENGHT;x++)
{
if (y==0)griglia[x][y]='_';
else
{
if(x==0)griglia[x][y]='|';
else griglia[x][y]=' ';
}
}
}
}
void Draw( void )
{
for(int y=MAP_HEIGHT;y>=0;y--)
{
for(int x=0;x<=MAP_LENGHT;x++)cout<<griglia[x][y];
cout<<"\n";
}
}
}piano;
Any ideas?