From 7b82195bdc2919147b21e30c45de60fc5be7bfde Mon Sep 17 00:00:00 2001 From: Albom Date: Sat, 21 Sep 2013 18:28:02 +0000 Subject: [PATCH] Reversi: score printing added git-svn-id: svn://kolibrios.org@3924 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/games/reversi/trunk/reversi.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/programs/games/reversi/trunk/reversi.c b/programs/games/reversi/trunk/reversi.c index a2e3ac10f2..08ef3e2eda 100644 --- a/programs/games/reversi/trunk/reversi.c +++ b/programs/games/reversi/trunk/reversi.c @@ -68,6 +68,7 @@ int OpponentScore[8][8]; // Notes: // void DrawBoard() { + int i; for(i=0;i<=8;i++) { @@ -489,6 +490,33 @@ int OpponentScore[8][8]; // } else { // ShowAbout(); } + + int _user = 0; + int _computer = 0; + int c, r; + + for (c=0; c<8; c++) + for (r=0; r<8; r++) { + if (TheBoard[c][r] == User) + _user++; + if (TheBoard[c][r] == Computer) + _computer++; + } + + // do not use sprintf function here please! ( sprintf(score, "User: %d - Computer: %d", _user, _computer); ) + char score[64]; + char tmp[8]; + strcpy(score, "User (black): "); + itoa(_user++, tmp, 10); + strcat(score, tmp); + strcat(score, " - Computer (white): "); + itoa(_computer++, tmp, 10); + strcat(score, tmp); + + __menuet__bar(58, 8, 250, 16, 0x777777); + __menuet__write_text(58,8,0x333333,score, strlen(score)); + + } // End of paint