粒子调整
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#define GAME_TIMER_ID 1
|
||||
#define EFFECT_TIMER_ID 2
|
||||
#define GAME_TIMER_INTERVAL 500
|
||||
#define EFFECT_TIMER_INTERVAL 33
|
||||
#define EFFECT_TIMER_INTERVAL 16
|
||||
|
||||
HINSTANCE hInst;
|
||||
TCHAR szTitle[MAX_LOADSTRING];
|
||||
|
||||
@@ -334,7 +334,7 @@ static void AddParticle(int boardX, int boardY, int velocityX, int velocityY, in
|
||||
|
||||
static void AddBurstParticles(int boardX, int boardY, COLORREF baseColor, bool strongBurst)
|
||||
{
|
||||
int burstCount = strongBurst ? 5 : 3;
|
||||
int burstCount = strongBurst ? 4 : 2;
|
||||
for (int i = 0; i < burstCount; i++)
|
||||
{
|
||||
int angleSeed = rand() % 8;
|
||||
|
||||
@@ -8,6 +8,32 @@
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
static HBRUSH GetCachedParticleBrush(COLORREF color)
|
||||
{
|
||||
static COLORREF cachedColors[16] = {};
|
||||
static HBRUSH cachedBrushes[16] = {};
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (cachedBrushes[i] != nullptr && cachedColors[i] == color)
|
||||
{
|
||||
return cachedBrushes[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (cachedBrushes[i] == nullptr)
|
||||
{
|
||||
cachedColors[i] = color;
|
||||
cachedBrushes[i] = CreateSolidBrush(color);
|
||||
return cachedBrushes[i];
|
||||
}
|
||||
}
|
||||
|
||||
return CreateSolidBrush(color);
|
||||
}
|
||||
|
||||
static std::wstring BuildAssetPath(const wchar_t* relativePath)
|
||||
{
|
||||
wchar_t modulePath[MAX_PATH] = {};
|
||||
@@ -997,10 +1023,14 @@ void TDrawScreen(HDC hdc, HWND hWnd)
|
||||
int elapsed = particleEffects[i].totalTicks - particleEffects[i].ticks;
|
||||
int particleX = gameRect.left + particleEffects[i].boardX * grid / 100 + SS(particleEffects[i].velocityX * elapsed);
|
||||
int particleY = gameRect.top + particleEffects[i].boardY * grid / 100 + SS(particleEffects[i].velocityY * elapsed + elapsed * elapsed / 4);
|
||||
int particleSize = SS(particleEffects[i].size * particleEffects[i].ticks / particleEffects[i].totalTicks);
|
||||
if (particleSize < SS(2))
|
||||
int particleSize = particleEffects[i].size * particleEffects[i].ticks / particleEffects[i].totalTicks;
|
||||
if (particleSize < 2)
|
||||
{
|
||||
particleSize = SS(2);
|
||||
particleSize = 2;
|
||||
}
|
||||
if (particleSize > 6)
|
||||
{
|
||||
particleSize = 6;
|
||||
}
|
||||
|
||||
RECT particleRect =
|
||||
@@ -1011,9 +1041,8 @@ void TDrawScreen(HDC hdc, HWND hWnd)
|
||||
particleY + particleSize
|
||||
};
|
||||
|
||||
HBRUSH particleBrush = CreateSolidBrush(particleEffects[i].color);
|
||||
HBRUSH particleBrush = GetCachedParticleBrush(particleEffects[i].color);
|
||||
FillRect(hdc, &particleRect, particleBrush);
|
||||
DeleteObject(particleBrush);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
|
||||
Reference in New Issue
Block a user