Hello,
I try write the smiple board game. Now i try write the function for move my pawn but i have Big problem:< I try do this on pos().x().y() with condition if else. And a i don't have idea how i can move my pawn on the left wall game. My pawn correct go to right next to down next to left but next he returned or stoped :< coud you help me?
void Gracz::ruch()
{
int wynik= 10;
for(int i =0; wynik>i; i++ )
{ //droga w prawo
if(pos().x() < 1300 && pos().y() <500 ) //warunek dla gory
setPos(x()+10,y());
else if((pos().x() > 1290 && pos().y() <500)) //warunek prawa strona
{
setPos(x(),y()+10);
}
else if ((pos().x() > 0 )) //warunek dol
{
setPos(x()-10,y());
}
else if( pos().x()==0) //warunek lewa strona
{
setPos(x(),y()-10);
}
}
}
void Gracz::ruch()
{
int wynik= 10;
for(int i =0; wynik>i; i++ )
{ //droga w prawo
if(pos().x() < 1300 && pos().y() <500 ) //warunek dla gory
setPos(x()+10,y());
else if((pos().x() > 1290 && pos().y() <500)) //warunek prawa strona
{
setPos(x(),y()+10);
}
else if ((pos().x() > 0 )) //warunek dol
{
setPos(x()-10,y());
}
else if( pos().x()==0) //warunek lewa strona
{
setPos(x(),y()-10);
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks