For a Homework i need to make some kind of Minesweeper but i have one Probleme one of my functions always return teh same and i cannot fin out why here is the code:
}
private: System::Void dataGridView1_CellClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
int y=dataGridView1->CurrentCellAddress.Y;
int x=dataGridView1->CurrentCellAddress.X;
if(spieler=1){
if(mine=true){
label2->Text=Convert::ToString("Spieler 1 hat verloren. Bitte Neues Spiel drücken");
}
else{
}
}
}
};
}
Thats the Part where Everything happens but the Function "bool setzen" always returns false and i dont know why.
It would be very nice if someone could help me.
Ok i dont need help anymore i found a solution.
There is now no setzen() i just changed the if( mine==true) with if(feld[x][y]==3) now it works heer the new code (with some other changes):
}
private: System::Void dataGridView1_CellClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
int y=dataGridView1->CurrentCellAddress.Y;
int x=dataGridView1->CurrentCellAddress.X;
if(spieler==1){
if(feld[x][y]==3){
label2->Text=Convert::ToString("Spieler 1 hat verloren. Bitte Neues Spiel drücken");
}
else{
if(feld[x][y]==0){
label2->Text=Convert::ToString("Spieler 2 ist dran");
spieler=2;
dataGridView1[x,y]->Value="1";
feld[x][y]=1;
}
else{
label2->Text=Convert::ToString("Das Feld ist belegt. Noch mal Spieler 1");
}
}
}
else{
if(feld[x][y]==3){
label2->Text=Convert::ToString("Spieler 2 hat verloren. Bitte Neues Spiel drücken");
}
else{
if(feld[x][y]==0){
label2->Text=Convert::ToString("Spieler 1 ist dran");
spieler=1;
dataGridView1[x,y]->Value="2";
feld[x][y]=2;
}
else{
label2->Text=Convert::ToString("Das Feld ist belegt. Noch mal Spieler 2");
}
}
}
}
};
}
but thanks anyway (i would write a better thanking but my english is shit)