突出特殊方块删除
This commit is contained in:
@@ -182,6 +182,15 @@ struct ParticleEffect
|
||||
COLORREF color;
|
||||
};
|
||||
|
||||
struct CellFlashEffect
|
||||
{
|
||||
int ticks;
|
||||
int totalTicks;
|
||||
int x;
|
||||
int y;
|
||||
COLORREF color;
|
||||
};
|
||||
|
||||
enum ScreenState
|
||||
{
|
||||
SCREEN_MENU = 0,
|
||||
@@ -224,6 +233,7 @@ extern FeedbackState feedbackState;
|
||||
extern ClearEffectState clearEffectState;
|
||||
extern FloatingTextEffect floatingTextEffects[8];
|
||||
extern ParticleEffect particleEffects[96];
|
||||
extern CellFlashEffect cellFlashEffects[64];
|
||||
extern int currentScreen;
|
||||
extern int currentMode;
|
||||
extern int currentFallInterval;
|
||||
@@ -267,6 +277,7 @@ bool TickVisualEffects();
|
||||
void TriggerLineClearEffect(const int* rows, int rowCount, int linesCleared);
|
||||
void PlayPendingLineClearEffect();
|
||||
void TriggerCellClearEffect(const Point* cells, int cellCount, bool strongBurst);
|
||||
void TriggerColoredCellClearEffect(const Point* cells, int cellCount, COLORREF flashColor, bool strongBurst);
|
||||
void AwardRogueSkillClearRewards(int clearedCells, int& scoreGain, int& expGain, bool allowLevelProgress);
|
||||
void CheckRogueLevelProgress();
|
||||
void ApplyBoardGravity();
|
||||
|
||||
@@ -22,6 +22,7 @@ FeedbackState feedbackState = { 0, _T(""), _T("") };
|
||||
ClearEffectState clearEffectState = { 0, 0, 0, {} };
|
||||
FloatingTextEffect floatingTextEffects[8] = {};
|
||||
ParticleEffect particleEffects[96] = {};
|
||||
CellFlashEffect cellFlashEffects[64] = {};
|
||||
int currentScreen = SCREEN_MENU;
|
||||
int currentMode = MODE_CLASSIC;
|
||||
int currentFallInterval = 500;
|
||||
|
||||
@@ -111,6 +111,11 @@ void ResetVisualEffects()
|
||||
{
|
||||
particleEffects[i].ticks = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
cellFlashEffects[i].ticks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,6 +149,15 @@ bool TickVisualEffects()
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
if (cellFlashEffects[i].ticks > 0)
|
||||
{
|
||||
cellFlashEffects[i].ticks--;
|
||||
active = true;
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
@@ -252,6 +266,25 @@ static void AddBurstParticles(int boardX, int boardY, COLORREF baseColor, bool s
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加一个被清除格子的短时高亮效果。
|
||||
*/
|
||||
static void AddCellFlash(int x, int y, COLORREF color, bool strongFlash)
|
||||
{
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
if (cellFlashEffects[i].ticks <= 0)
|
||||
{
|
||||
cellFlashEffects[i].ticks = strongFlash ? 18 : 14;
|
||||
cellFlashEffects[i].totalTicks = cellFlashEffects[i].ticks;
|
||||
cellFlashEffects[i].x = x;
|
||||
cellFlashEffects[i].y = y;
|
||||
cellFlashEffects[i].color = color;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 暂存消行动画,等待升级选择结束后再播放。
|
||||
*/
|
||||
@@ -355,6 +388,14 @@ void TriggerLineClearEffect(const int* rows, int rowCount, int linesCleared)
|
||||
* @brief 为指定棋盘格集合触发清除粒子效果。
|
||||
*/
|
||||
void TriggerCellClearEffect(const Point* cells, int cellCount, bool strongBurst)
|
||||
{
|
||||
TriggerColoredCellClearEffect(cells, cellCount, RGB(255, 238, 120), strongBurst);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 为指定棋盘格集合触发带颜色区分的清除高亮和粒子效果。
|
||||
*/
|
||||
void TriggerColoredCellClearEffect(const Point* cells, int cellCount, COLORREF flashColor, bool strongBurst)
|
||||
{
|
||||
if (cells == nullptr || cellCount <= 0)
|
||||
{
|
||||
@@ -369,6 +410,7 @@ void TriggerCellClearEffect(const Point* cells, int cellCount, bool strongBurst)
|
||||
}
|
||||
|
||||
COLORREF particleColor = BrickColor[(cells[i].x + cells[i].y) % 7];
|
||||
AddCellFlash(cells[i].x, cells[i].y, flashColor, strongBurst);
|
||||
AddBurstParticles(cells[i].x * 100 + 50, cells[i].y * 100 + 50, particleColor, strongBurst);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1042,6 +1042,47 @@ void TDrawScreen(HDC hdc, HWND hWnd)
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
if (cellFlashEffects[i].ticks <= 0 || cellFlashEffects[i].totalTicks <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cellFlashEffects[i].x < 0 || cellFlashEffects[i].x >= nGameWidth ||
|
||||
cellFlashEffects[i].y < 0 || cellFlashEffects[i].y >= nGameHeight)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int alpha = 48 + cellFlashEffects[i].ticks * 168 / cellFlashEffects[i].totalTicks;
|
||||
int pulseInset = SS(2 + (cellFlashEffects[i].totalTicks - cellFlashEffects[i].ticks) % 3);
|
||||
RECT flashRect =
|
||||
{
|
||||
gameRect.left + cellFlashEffects[i].x * grid + pulseInset,
|
||||
gameRect.top + cellFlashEffects[i].y * grid + pulseInset,
|
||||
gameRect.left + (cellFlashEffects[i].x + 1) * grid - pulseInset,
|
||||
gameRect.top + (cellFlashEffects[i].y + 1) * grid - pulseInset
|
||||
};
|
||||
|
||||
Graphics cellGraphics(hdc);
|
||||
cellGraphics.SetSmoothingMode(SmoothingModeAntiAlias);
|
||||
SolidBrush cellBrush(Color(alpha, GetRValue(cellFlashEffects[i].color), GetGValue(cellFlashEffects[i].color), GetBValue(cellFlashEffects[i].color)));
|
||||
Pen cellPen(Color(230, GetRValue(cellFlashEffects[i].color), GetGValue(cellFlashEffects[i].color), GetBValue(cellFlashEffects[i].color)), static_cast<REAL>(SS(2)));
|
||||
cellGraphics.FillRectangle(
|
||||
&cellBrush,
|
||||
static_cast<INT>(flashRect.left),
|
||||
static_cast<INT>(flashRect.top),
|
||||
static_cast<INT>(flashRect.right - flashRect.left),
|
||||
static_cast<INT>(flashRect.bottom - flashRect.top));
|
||||
cellGraphics.DrawRectangle(
|
||||
&cellPen,
|
||||
static_cast<INT>(flashRect.left),
|
||||
static_cast<INT>(flashRect.top),
|
||||
static_cast<INT>(flashRect.right - flashRect.left),
|
||||
static_cast<INT>(flashRect.bottom - flashRect.top));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 96; i++)
|
||||
{
|
||||
if (particleEffects[i].ticks <= 0 || particleEffects[i].totalTicks <= 0)
|
||||
|
||||
@@ -888,7 +888,7 @@ int ClearExplosiveAreaAt(int centerY, int centerX)
|
||||
}
|
||||
}
|
||||
|
||||
TriggerCellClearEffect(clearedCells, clearedCellCount < 25 ? clearedCellCount : 25, true);
|
||||
TriggerColoredCellClearEffect(clearedCells, clearedCellCount < 25 ? clearedCellCount : 25, RGB(255, 116, 78), true);
|
||||
return clearedCellCount;
|
||||
}
|
||||
|
||||
@@ -919,7 +919,7 @@ int ClearColumnAt(int column)
|
||||
}
|
||||
}
|
||||
|
||||
TriggerCellClearEffect(clearedCells, clearedCellCount, false);
|
||||
TriggerColoredCellClearEffect(clearedCells, clearedCellCount, RGB(120, 232, 255), false);
|
||||
return clearedCellCount;
|
||||
}
|
||||
|
||||
@@ -950,7 +950,7 @@ int ClearRowAt(int row)
|
||||
}
|
||||
}
|
||||
|
||||
TriggerCellClearEffect(clearedCells, clearedCellCount, false);
|
||||
TriggerColoredCellClearEffect(clearedCells, clearedCellCount, RGB(196, 255, 132), false);
|
||||
return clearedCellCount;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user