static int NextLinkPos(int line, int nr) { char* linetxt; int linkcntr = 0; linetxt = GetHelpLine(line); while (*linetxt) { if (IsHlpReference(linetxt)) { if (linkcntr++ == nr) return linkcntr; else linetxt = PassHlpReferencePart(linetxt); } else if (IsFullLine(linetxt)) linetxt = PassHlpFullLinePart(linetxt); else if (IsHlpAsciiChar(linetxt)) linetxt = PassHlpAsciiChar(linetxt); else if (IsCenterOnLine(linetxt)) linetxt = PassCenterOnLinePart(linetxt); else linetxt = PassNextHelpPart(linetxt); } return 0; }
static int GetLinkIndex(struct LinkPosition* pos) { int linkcntr=0; char* linetxt = GetHelpLine(pos->line); while (*linetxt) { if (IsHlpReference(linetxt)) { linkcntr++; if (linkcntr == pos->nr) return GetHlpLinkIndex(linetxt); else linetxt = PassHlpReferencePart(linetxt); } else if (IsFullLine(linetxt)) linetxt = PassHlpFullLinePart(linetxt); else if (IsHlpAsciiChar(linetxt)) linetxt = PassHlpAsciiChar(linetxt); else if (IsCenterOnLine(linetxt)) linetxt = PassCenterOnLinePart(linetxt); else linetxt = PassNextHelpPart(linetxt); } return -1; }
void ReleaseLine() { for (int i = GAME_HIGH - 2; i > 0; i--) { if (IsFullLine(i)) { for (int nRow = i; nRow > 0; nRow--) { for (int nCol = 1; nCol <= GAME_LENGTH-2; nCol++) { g_Game[nRow][nCol] = g_Game[nRow-1][nCol]; } } i++; g_nScore += 100; } } }
void CRussiaGame::EliminateLine() { for (int Row = 19; Row >= 0; Row--) { if (IsFullLine(Row)) { for(int i = Row - 1; i >= 0; i--) { for (int j = 0; j < 12; j++) { m_iMap[j][i+1] = m_iMap[j][i]; } } Row += 1; score += 100; InvalidateRect(m_hWnd, NULL, TRUE); } } }
//消行 int CGame::ReleaseLine() { char (*ptmp)[4] = (char (*)[4])&(m_CurShape.GetData()[0]); for (int i = GAME_ROWS - 2; i > 0; i--) { if (IsFullLine(i)) { for (int nRow = i; nRow > 0; nRow--) { for (int nCol = 1; nCol <= GAME_ROWS-2; nCol++) { ptmp[nRow][nCol] = ptmp[nRow-1][nCol]; } } i++; //g_nScore += 100; } } return 0; }
static int SeekLinkNr(int line, int charpos) { int pos = -1; int linkcntr = 0; char* linetxt = GetHelpLine(line); while (*linetxt && (pos < charpos)) { if (IsHlpReference(linetxt)) { char *start, *end; GetHlpLinkCaption(linetxt, &start, &end); linkcntr++; pos += (int)(end - start); if (pos >= charpos) return linkcntr; linetxt = PassHlpReferencePart(linetxt); } else if (IsFullLine(linetxt)) linetxt = PassHlpFullLinePart(linetxt); else if (IsCenterOnLine(linetxt)) linetxt = PassCenterOnLinePart(linetxt); else if (IsHlpAsciiChar(linetxt)) { pos++; linetxt = PassHlpAsciiChar(linetxt); } else { char* next = PassNextHelpPart(linetxt); pos += (int)(next - linetxt); linetxt = next; } } return 0; }
static void DrawHelpLineParts(int line, int x, int y, int xlen) { int linkcntr = 0; char* linetxt = GetHelpLine(line); while (*linetxt) { if (IsHlpReference(linetxt)) { char *start, *end, sentinel; GetHlpLinkCaption(linetxt, &start, &end); sentinel = *end; *end = 0; linkcntr++; if ((line == CurrentLink.line) && (CurrentLink.nr == linkcntr)) DrawText(x, y, start, HILINKFORCOLOR, HILINKBACKCOLOR); else DrawText(x, y, start, LOLINKFORCOLOR, LOLINKBACKCOLOR); x += strlen(start); *end = sentinel; linetxt = PassHlpReferencePart(linetxt); } else if (IsFullLine(linetxt)) { DrawSequence(x, y, xlen-1, 'Ä', DIALOGFORCOLOR, DIALOGBACKCOLOR); linetxt = PassHlpFullLinePart(linetxt); } else if (IsHlpAsciiChar(linetxt)) { DrawSequence(x, y, 1, GetHlpAsciiChar(linetxt), DIALOGFORCOLOR, DIALOGBACKCOLOR); linetxt = PassHlpAsciiChar(linetxt); x++; } else if (IsCenterOnLine(linetxt)) { int centerx; char *begin, *end, sentinel; GetHlpTextToCenter(linetxt, &begin, &end); centerx = x + ((xlen / 2) - ((int)(end - begin) / 2)); sentinel = *end; *end = 0; if (centerx > x) DrawText(centerx, y, begin, DIALOGFORCOLOR, DIALOGBACKCOLOR); else DrawText(x, y, begin, DIALOGFORCOLOR, DIALOGBACKCOLOR); *end = sentinel; linetxt = PassCenterOnLinePart(linetxt); } else { char* next = PassNextHelpPart(linetxt); char sentinel = *next; *next = 0; DrawText(x, y, linetxt, DIALOGFORCOLOR, DIALOGBACKCOLOR); x += strlen(linetxt); *next = sentinel; linetxt = next; } } }