son91 Posted March 31, 2011 Report Share Posted March 31, 2011 Heja, mam zgryza. Otóż chcę się zabrać za gierkę kółko i krzyżyk w C++ a za cholerę nie wiem jak to ugryźć... ma ktoś może jakieś większe doświadczenie i jest skłonny by mi pomóc? Byłbym wdzięczny... Link to comment Share on other sites More sharing options...
[Ekspert] Mormegil Posted April 1, 2011 Report Share Posted April 1, 2011 int main() { int player = 1; int level[9]; ResetLevel(level); //set all elements to zero while (1) { DrawLevel(level); //draw level DrawPlayer(player); //draw some info about player turn int field = GetInput(); //get selected element index level[field] = player; //set element to player if (true == CheckWinCondition(level)) //check if player wins { DrawWinner(player, level); //draw which player has won and why GetInput(); //wait for input //reset game state ResetLevel(level); player = 1; } else // no winner yet, so change player { if (1 == player) player = 2; else player = 1; } } } Link to comment Share on other sites More sharing options...
son91 Posted April 5, 2011 Author Report Share Posted April 5, 2011 tyle że to muszę mieć na klasach... Link to comment Share on other sites More sharing options...
Lord Hrabula Posted April 6, 2011 Report Share Posted April 6, 2011 Oczekujesz, że ktoś Ci to w klasach rozpisze? Mormegil zaproponował jedno z rozwiązań. Pomyśl chwilę jak to obiektowo zaprojektować, jak będziesz miał jakiś pomyśl lub problemy w implementacji, to się zgłoś, na pewno znajdzie się ktoś, kto pomoże. Jak oczekujesz, że ktoś wypluje tutaj działający kod, bez Twojego udziału, to się możesz zdziwić. Pomijam fakt, że na sieci jest od groma rozwiązań tego problemu, największą trudnością może być znajomość przekładu "kółko i krzyżyk" na angielski Link to comment Share on other sites More sharing options...
[Ekspert] Mormegil Posted April 6, 2011 Report Share Posted April 6, 2011 tyle że to muszę mieć na klasach...Co to w ogóle znaczy na klasach? Może zamiast funkcji ResetLevel, DrawLevel itd. zrób klasy z operatorem (). Tworzysz sobie instancje obiektów o takich nazwach i wywołujesz tak jak funkcje class CResetLevel { public: void operator (int * level); }; int main() { int level[9]; CResetLevel ResetLevel; ... ResetLevel(level); ... } Link to comment Share on other sites More sharing options...