Jump to content

  • Log In with Google      Sign In   
  • Create Account

mayoscuro

Member Since 18 Apr 2012
Offline Last Active Dec 02 2012 05:38 AM

Posts I've Made

In Topic: Map of console rpg

25 October 2012 - 03:13 AM

Is developed in windows console ¿Is that what your asking me?

In Topic: Map of console rpg

24 October 2012 - 03:55 PM

Thanks ^ ^
Now I have another question ...
How I can detect the arrow keys without using the library <conio.h>?
Is there any way to use std :: KeyChar without pressing the enter key?

In Topic: tic tac toe c++

26 April 2012 - 08:26 AM

Thank you everyone, at the end I solve one part of my problem with thant functions:

void recorrer(juego &tablero,int y,int x,int anteriorx,int anteriory){

	   int num_x=0;
	   int num_o=0;
	   int copiay=y;
	   int copiax=x;


	   //FILAS:
	   for(y ;y<tablero.size();y--){
		   incrementarxo(tablero,x, y,num_x,num_o,anteriorx,anteriory);
	   }
	   num_x=0;
	   num_o=0;
	   y=copiay;
	   for(y ;y>=0 && y<tablero.size();++y){
		   incrementarxo(tablero,x, y,num_x,num_o,anteriorx,anteriory);
	   }
	   //COLUMNAS:
	   num_x=0;
	   num_o=0;
	   x=copiax;
	   y=copiay;
	   for(x ;x<tablero.size() && x>=0;x--){
		   incrementarxo(tablero,x, y,num_x,num_o,anteriorx,anteriory);
	   }
	   num_x=0;
	   num_o=0;
	   x=copiax;
	   y=copiay;
	   for(x ;x>=0 && x<tablero.size();++x){
		   incrementarxo(tablero,x, y,num_x,num_o,anteriorx,anteriory);
	   }
	   //DIAGONALES(Izquierda a derecha):
	   num_x=0;
	   num_o=0;
	   x=copiax;
	   y=copiay;
	   for (x,y; x>=0 && y>=0 || x<tablero.size() && y<tablero.size();x--, y--){
		   incrementarxo(tablero,x, y,num_x,num_o,anteriorx,anteriory);
	   }
	   num_x=0;
	   num_o=0;
	   x=copiax;
	   y=copiay;
		for (x,y; x<tablero.size() && y<tablero.size();x++, y++){
		   incrementarxo(tablero,x, y,num_x,num_o,anteriorx,anteriory);
	   }
	   //DIAGONALES(Derecha a izquierda):
		num_x=0;
	   num_o=0;
	   x=copiax;
	   y=copiay;
	   for (x,y; x<tablero.size() && y>=0;x--, y++){
		   incrementarxo(tablero,x, y,num_x,num_o,anteriorx,anteriory);
	   }
	   num_x=0;
	   num_o=0;
	   x=copiax;
	   y=copiay;
	   for (x,y; x<tablero.size() && y>=0;x++, y--){
		   incrementarxo(tablero,x, y,num_x,num_o,anteriorx,anteriory);
	   }
}

int incrementarxo(juego &tablero,int &x, int &y,int &num_x, int &num_o,int anteriorx, int anteriory){
	   if (tablero[x][y]=='X'){
			 num_x++;
			 ganarx(num_x);
			 return num_x;		  

	   }else if (num_x < 3 && tablero[x][y] != 'X' && x != anteriorx || num_x < 3 && tablero[x][y] != 'X' && y != anteriory)   num_x=0;
	  
	   if (tablero[x][y]=='O'){
			 num_o++;
			 ganaro(num_o);
			 return num_o;			

	   }else if (tablero[x][y]=!'O' && num_o<3)   num_o=0;

	   ganarx(num_x);
	   ganaro(num_o);
}

void ganaro(int num_o){
	   if(num_o>=3){
			 std::cout<<"Ha ganado el jugador 2"<<std::endl;
			 FinPartida();
	   }
}

void ganarx(int num_x){
	   if (num_x>=3){
			 std::cout<<"Ha ganado el jugador 1"<<std::endl;
			 FinPartida();
	   }
}
//FIN COMPROBACIONES

But now I have other problem, I need who one variable save the value of the last move,
I need that because in my code if you have | x | Nothing | x | and you put one X in the midle yo don't
win. That is the only problem.
So I need that variable to make my program who don't delete the X (or O) if x=oldx
The real problem is that variables must be initialized and can not find how to save the previous move.
Have I explained well?
Anyone can help my with that problem?

Thank you, one more time.

In Topic: tic tac toe c++

18 April 2012 - 03:07 PM

Yes,your right is variable size.
Sorry I will try to explain this to you , the rules are the same as in a original tic tac toe (3x3)
with the only exeption that you can chose the size(3x3,4x4...8x8).

PARTNERS