diff --git a/veinCur.cpp b/veinCur.cpp index 93a885a..1fbef35 100644 --- a/veinCur.cpp +++ b/veinCur.cpp @@ -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) { diff --git a/veinCur.vcxproj b/veinCur.vcxproj index 7176d0e..d1236ed 100644 --- a/veinCur.vcxproj +++ b/veinCur.vcxproj @@ -104,6 +104,8 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + MaxSpeed + Default Windows @@ -120,7 +122,7 @@ true - Console + Windows true true true