ah... what i tryed now as seen below is that i put the loop above the grids and threw in a "system ("cls");" under them, what i however dont know now is if i made this work corrently or not as X is still not moving anywhere :/ but everyting is looping.
[/CODE]Code:#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void jump(char start[][3],int x, int y);
int main()
{
//deklarerade variabler för mail
int yes,abryt,x,y;
//början på mitt grid
char start[3][3], goal[3][3];
int loop2 = 0;
while (loop2 == 0){
//läser in filen som blivit vald
ifstream infil("start.txt");
infil >> start[0][0] >> start[0][1] >> start[0][2]
>> start[1][0] >> start[1][1] >> start[1][2]
>> start[2][0] >> start[2][1] >> start[2][2];
//tar reda på vart X är på gridet och skriver ut positionen i toppen av spelet.
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if (start[i][j] == 'X'){
y=i;
x=j;
cout << "your on Square: " << "Y: " << y << " X: " << x << endl << endl;
}
}
}
//skriver ut mitt start grid
cout << start[0][0] << " " << start[0][1] << " " << start[0][2]
<< endl << start[1][0] << " " << start[1][1] << " " << start[1][2]
<< endl << start[2][0] << " " << start[2][1] << " " << start[2][2]
<< endl << endl;
ifstream infil2("goal.txt");
//läser in mitt målgrid från vald fil
infil2 >> goal[0][0] >> goal[0][1] >> goal[0][2]
>> goal[1][0] >> goal[1][1] >> goal[1][2]
>> goal[2][0] >> goal[2][1] >> goal[2][2];
//skriver ut mitt mål grid
cout << goal[0][0] << " " << goal[0][1] << " " << goal[0][2]
<< endl << goal[1][0] << " " << goal[1][1] << " " << goal[1][2] << endl
<< goal[2][0] << " " << goal[2][1] << " " << goal[2][2] << endl << endl;
//loop för att ladda om spelplanen när något blir inmatat
/*int loop = 0;
while (loop == 0){ */
jump(start, x, y);
system ("cls");
}
return 0;
}
void jump(char start[][3], int x, int y)
{
string jump2;
cout << "You move by using W A S D on you keyboard: ";
cin >> jump2;
//funktion för att avbryta spelet när man vill.
if(jump2 == "avbryt")
{
string quit;
cout << "Want to quit the game eh? Yes/no" ;
cin >> quit;
if(quit == "yes")
{
cout << "bye message" << endl;
} else
cout << "stay message";
} else
//switch sats för att röra på sej med tangenterna W A S D
switch(jump2[0])
{
case 'w':
y--;
if (y < 0 ){
y = 0;
cout << "lol, you cant move here" << endl;
}
break;
case 'a':
x--;
if (x < 0 ){
x = 0;
cout << "lol, you cant move here" << endl;
}
break;
case 's':
y++;
if (y > 2 ){
y = 2;
cout << "lol, you cant move here" << endl;
}
break;
case 'd':
x++;
if (x > 2 ) {
x = 2;
cout << "lol, you cant move here" << endl;
}
break;
}
}
Im writing in windows vista using Microsoft Visual C++ 2008, and no i would not mind.

