This commit is contained in:
awin-x 2025-01-26 08:56:28 +08:00
parent 89d17ce038
commit 91b2cf3c28
2 changed files with 55 additions and 58 deletions

View File

@ -55,7 +55,7 @@ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszA
// ÉèÖÃÏß³ÌÓÅÏȼ¶ÎªµÍ
SetThreadPriority(hThread, THREAD_PRIORITY_LOWEST);
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
@ -146,27 +146,22 @@ void vine2(int x1, int y1, float anchor, float turn, int speed, int cost, Color
penline.SetStartCap(LineCapRound);
mtx.lock();
graphics->DrawLine(&penline, x1, y1, x2, y2);
vines.push(VineDraw{x1,y1,x2,y2,speed,50});
mtx.unlock();
Sleep(1);
vines.push(VineDraw{x1,y1,x2,y2,speed,10});
if (clone > 0 && rand() % 10 == 0)
{
int x_copy = x1;
int y_copy = y1;
float anchor_copy = anchor + rand() % 10 / 26.0;
float turn_copy = turn * (-1 + rand() % 2 * 2);
int speed_copy = speed + rand() % 3;
int cost_copy = cost + rand() % 3;
thread t(vine2, x_copy, y_copy, anchor_copy, turn_copy, speed_copy, cost_copy, Color(rand() % 50, 100 + rand() % 100, 20 + rand() % 50), 0, --clone);
thread t(vine2, x1, y1, anchor + rand() % 10 / 23.0, turn * (-1 + rand() % 2 * 2), speed + rand() % 2, cost, Color(rand() % 70, 155 + rand() % 100, 20 + rand() % 70), 0, --clone);
t.detach();
}
if (count % 10 == 0)
if (count % 9 == 0)
speed -= cost;
anchor += turn;
if (count % 3 == 0)
turn += turn / 2;
if (turn > 0.6)
speed = 0;
mtx.unlock();
Sleep(1);
vine2(x2, y2, anchor, turn, speed, cost, color, count, clone);
}
@ -191,55 +186,55 @@ DWORD WINAPI eraser(LPVOID lpParam)
}
else
{
Sleep(50);
Sleep(70);
}
}
}
void vine(int x1, int y1, float anchor, float turn, int speed, int cost, Color color, int count, int clone)
{
if (speed <= 0)
{
Sleep(300);
return;
}
count++;
int x2 = x1 + (speed)*cos(anchor);
int y2 = y1 + (speed)*sin(anchor);
Pen penline(color, speed);
penline.SetEndCap(LineCapRound);
penline.SetStartCap(LineCapRound);
mtx.lock();
graphics->DrawLine(&penline, x1, y1, x2, y2);
mtx.unlock();
Sleep(1);
if (clone > 0 && rand() % 10 == 0)
{
int x_copy = x1;
int y_copy = y1;
float anchor_copy = anchor + rand() % 10 / 26.0;
float turn_copy = turn * (-1 + rand() % 2 * 2);
int speed_copy = speed + rand() % 3;
int cost_copy = cost + rand() % 3;
thread t(vine, x_copy, y_copy, anchor_copy, turn_copy, speed_copy, cost_copy, Color(rand() % 50, 100 + rand() % 100, 20 + rand() % 50), 0, --clone);
t.detach();
}
if (count % 10 == 0)
speed -= cost;
anchor += turn;
if (count % 3 == 0)
turn += turn / 2;
if (turn > 0.6)
speed = 0;
vine(x2, y2, anchor, turn, speed, cost, color, count, clone);
Sleep(count / 3);
Pen erase(Color(255, 0, 0), speed * 2 + 3);
erase.SetEndCap(LineCapRound);
erase.SetStartCap(LineCapRound);
mtx.lock();
graphics->DrawLine(&erase, x1, y1, x2, y2);
mtx.unlock();
}
//void vine(int x1, int y1, float anchor, float turn, int speed, int cost, Color color, int count, int clone)
//{
// if (speed <= 0)
// {
// Sleep(300);
// return;
// }
// count++;
// int x2 = x1 + (speed)*cos(anchor);
// int y2 = y1 + (speed)*sin(anchor);
// Pen penline(color, speed);
// penline.SetEndCap(LineCapRound);
// penline.SetStartCap(LineCapRound);
// mtx.lock();
// graphics->DrawLine(&penline, x1, y1, x2, y2);
// mtx.unlock();
// Sleep(1);
// if (clone > 0 && rand() % 10 == 0)
// {
// int x_copy = x1;
// int y_copy = y1;
// float anchor_copy = anchor + rand() % 10 / 26.0;
// float turn_copy = turn * (-1 + rand() % 2 * 2);
// int speed_copy = speed + rand() % 3;
// int cost_copy = cost + rand() % 3;
// thread t(vine, x_copy, y_copy, anchor_copy, turn_copy, speed_copy, cost_copy, Color(rand() % 50, 100 + rand() % 100, 20 + rand() % 50), 0, --clone);
// t.detach();
// }
// if (count % 10 == 0)
// speed -= cost;
// anchor += turn;
// if (count % 3 == 0)
// turn += turn / 2;
// if (turn > 0.6)
// speed = 0;
// vine(x2, y2, anchor, turn, speed, cost, color, count, clone);
// Sleep(count / 3);
// Pen erase(Color(255, 0, 0), speed * 2 + 3);
// erase.SetEndCap(LineCapRound);
// erase.SetStartCap(LineCapRound);
// mtx.lock();
// graphics->DrawLine(&erase, x1, y1, x2, y2);
// mtx.unlock();
//}
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode >= 0) {

View File

@ -104,6 +104,8 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<Optimization>MaxSpeed</Optimization>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -120,7 +122,7 @@
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>