Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to programming and I have no knowledge to create the score, he is already ready I know not to make it appear on the screen, I need you guys to help, if not possible I also thank,


I want to show on the screen 0-0 whenever one of the players to win it changes 1-0

the code is in github GitHub - ROBSONS2007/score[^]

score game kof98:
C++
#define STATE_IDLE         0
#define STATE_STARTING     1
#define STATE_RUNNING      2
#define RUN_COUNT          (60 * 12)




static struct {
   int state;
   int runcount;
   char *game;
   struct {
      char *id;
      int   rounds;
   } p[2];
} GameInfo = { 0 };

extern bool SpriteInList(const QuarkSpriteInfo *s, QuarkSprite sprites[], int count);
extern int QuarkFindSprite(QuarkSprite sprites[], int count, int x, int y);

static void
QuarkSpriteStartNewGame(GGPOSession *ggpo, char *game)
{
   for (int i = 0; i < 2; i++) {
      GameInfo.p[i].rounds = 0;
      GameInfo.p[i].id = NULL;
   }
   GameInfo.runcount = RUN_COUNT;
   ggpo_client_set_game_event(ggpo, GGPOCLIENT_GAMEEVENT_STARTING, game);
}

static void
QuarkSpriteFinishGame(GGPOSession *ggpo)
{
   ggpo_client_set_game_event(ggpo, GGPOCLIENT_GAMEEVENT_PLAYER_1, (void *)"kof98");
   ggpo_client_set_game_event(ggpo, GGPOCLIENT_GAMEEVENT_PLAYER_2, (void *)"kof98");
   ggpo_client_set_game_event(ggpo, GGPOCLIENT_GAMEEVENT_PLAYER_1_SCORE, (void *)GameInfo.p[0].rounds);
   ggpo_client_set_game_event(ggpo, GGPOCLIENT_GAMEEVENT_PLAYER_2_SCORE, (void *)GameInfo.p[1].rounds);
   ggpo_client_set_game_event(ggpo, GGPOCLIENT_GAMEEVENT_WINNER, (void *)(GameInfo.p[0].rounds > GameInfo.p[1].rounds ? 1 : 2));
   ggpo_client_set_game_event(ggpo, GGPOCLIENT_GAMEEVENT_FINISHED, NULL);
}

static bool
P1PlayerNameVisible(QuarkSprite sprites[], int count)
{
   const int a = 865;
   const int z = a + 26;
   for (int i = 0; i < count; i++) {
      if (sprites[i].x == 48 && sprites[i].y == 32 && sprites[i].id >= a && sprites[i].id <= z) {
         return true;
      }          
   }
   return false;
}

static bool
CharSelectTimeCountdown(QuarkSprite sprites[], int count)
{
   static const struct {
      int id, x, y;
   } matches[] = {
      { 1672, 136, 192 }, // T
      { 1673, 144, 192 }, // I
      { 1674, 152, 192 }, // M
      { 1675, 160, 192 }, // E
   };
   int c = 0;
   for (int i = 0; i < count; i++) {
      for (int j = 0; j < _ARRAYSIZE(matches); j++) {
         if (sprites[i].x == matches[j].x &&
             sprites[i].y == matches[j].y &&
             sprites[i].id == matches[j].id) {
            c++;
            if (c == _ARRAYSIZE(matches)) {
               return true;
            }
         }
      }
   }
   return false;
}

void
QuarkProcessKOF98Sprites(GGPOSession *ggpo, QuarkSprite sprites[], int count)
{


	/*
	* These are the nameplates for all the characters you can select.
	*/
	static const struct {
		char *character;
		int p[2];
	} search[] = {

		{ "Kyo", { 00000, 00000 } },
		{ "Benimaru", { 00000, 00000 } },
		{ "Daimon", { 00000, 00000 } },
		{ "Terry", { 00000, 00000 } },
		{ "Andy", { 00000, 00000 } },
		{ "Joe", { 00000, 00000 } },
		{ "Ryo", { 00000, 00000 } },
		{ "Robert", { 00000, 00000 } },
		{ "Yuri", { 00000, 00000 } },
		{ "Leona", { 00000, 00000 } },
		{ "Ralf", { 00000, 00000 } },
		{ "Clark", { 00000, 00000 } },
		{ "Athena", { 00000, 00000 } },
		{ "Kensou", { 00000, 00000 } },
		{ "Chin", { 00000, 00000 } },
		{ "Mai", { 00000, 00000 } },
		{ "King", { 00000, 00000 } },
		{ "Chizuru", { 00000, 00000 } },
		{ "Kim", { 00000, 00000 } },
		{ "Choi", { 00000, 00000 } },
		{ "Chang", { 00000, 00000 } },
		{ "Yashiro", { 00000, 00000 } },
		{ "Shermie", { 00000, 00000 } },
		{ "Chris", { 00000, 00000 } },
		{ "Billy", { 00000, 00000 } },
		{ "Yamazaki", { 00000, 00000 } },
		{ "Mary", { 00000, 00000 } },
		{ "Iori", { 00000, 00000 } },
		{ "Mature", { 00000, 00000 } },
		{ "Vice", { 00000, 00000 } },
		{ "Heidern", { 00000, 00000 } },
		{ "Takuma", { 00000, 00000 } },
		{ "Saishu", { 00000, 00000 } },
		{ "HeavyD", { 00000, 00000 } },
		{ "Lucky", { 00000, 00000 } },
		{ "Brian", { 00000, 00000 } },
		{ "Rugal", { 00000, 00000 } },
		{ "Shingo", { 00000, 00000 } },
		{ "Kyo 94", { 00000, 00000 } },
		{ "Terry 94", { 00000, 00000 } },
		{ "Andy 94", { 00000, 00000 } },
		{ "Joe 94", { 00000, 00000 } },
		{ "Ryo 94", { 00000, 00000 } },
		{ "Robert 94", { 00000, 00000 } },
		{ "Yuri 94", { 00000, 00000 } },
		{ "Mai 94", { 00000, 00000 } },
		{ "Orochi Yashiro", { 00000, 00000 } },
		{ "Orochi Shermie", { 00000, 00000 } },
		{ "Orochi Chris", { 00000, 00000 } },
		{ "Billy 94", { 00000, 00000 } },
		{ "Rugal Omega", { 00000, 00000 } },
	};



   /*
    * See if it's time to start a new game...
    */
   if (GameInfo.state == STATE_IDLE) {
      if (P1PlayerNameVisible(sprites, count)) {
         QuarkSpriteStartNewGame(ggpo, "kof98");
         GameInfo.state = STATE_RUNNING;
      }
   } else if (GameInfo.state == STATE_RUNNING) {
      if (P1PlayerNameVisible(sprites, count)) {
         GameInfo.runcount = RUN_COUNT;
      } else {
         GameInfo.runcount--;
      }
      unsigned char *start = pVidImage + nVidImagePitch;
      if (GameInfo.runcount == 0 ||
          memcmp(scanline_red_4, start, sizeof(scanline_red_4)) == 0 ||
          memcmp(scanline_blue_4, start, sizeof(scanline_blue_4)) == 0 ||
          memcmp(scanline_challenge_4, start, sizeof(scanline_challenge_4)) == 0 ||
          CharSelectTimeCountdown(sprites, count)) {
         QuarkSpriteFinishGame(ggpo);
         GameInfo.state = STATE_IDLE;
      }
   }
}


// esse trecho e um contador  responsável por ler o espectador  que entram para ver o jogo online


int VidSUpdateSpectatorCount(int spectatorCount)
{
	if (spectatorCount) {
		_sntprintf(szSpectatorCount, 256, _T("%d spectator%s"), spectatorCount, spectatorCount > 1 ? "s" : "");
	}
	else {
		_sntprintf(szSpectatorCount, 256, _T(""));
	}
	bDrawTV = true;
	return 0;
}

//esse e o trecho responsável por mostrar na tela a quantidade de espectado


int VidSDrawTV(RECT *rcDest){

SetTextAlign(hDC, TA_TOP | TA_RIGHT);
    MyTextOut(hDC, pTVSurfRight - 4, 4, szSpectatorCount, strlen(szSpectatorCount), nChatShadowOffset, RGB(0xcc, 0xcc, 0xcc))

}


What I have tried:

SetTextAlign(hDC, TA_TOP | TA_RIGHT);
MyTextOut(hDC, pTVSurfRight - 4, 4, pScoreInfo, strlen(pScoreInfo), nChatShadowOffset, RGB(0xcc, 0xcc, 0xcc));


I tried it could not, as we have already said I am new to programming
Posted
Updated 28-Feb-16 7:22am
v7
Comments
Richard MacCutchan 29-Feb-16 4:29am    
The code above appears to use some third party engine for drawing on the screen, so you need to study the documentation to find out how to do it. If you are new to programming then your time would be better spent learning the basics first.
robsons2007 29-Feb-16 16:15pm    
thank. this code and only part of it all this code on github not I who created.
Richard MacCutchan 29-Feb-16 16:40pm    
Using code from the internet is fine if you have good experience. But it is generally not helpful as a learning tool. Use Google to find tutorials that actually explain what they are doing.
robsons2007 29-Feb-16 16:48pm    
this code is part of the FBA emulator code for online games, I wanted so now add victories counter .Thank you for the tip

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900