void DrawMan() { txSetColor (TX_YELLOW); txSetFillColor (TX_YELLOW); txLine (385, 135, 385, 120); txLine (385, 135, 375, 150); txLine (385, 135, 395, 150); txLine (385, 125, 375, 135); txLine (385, 125, 400, 120); txCircle (385, 115, 6); }
void Dlya_Graf () { txSetFillColor (TX_WHITE); POINT graf [4] = {{XWindow/2, YWindow}, {XWindow/2, 0}, {XWindow, 0}, {XWindow, YWindow}}; txPolygon (graf, 4); txSetColor (RGB(0, 0, 255), 7); txLine (XWindow, 0, XWindow, YWindow); txLine (XWindow, YWindow, XWindow/2, YWindow); txLine (XWindow/2, YWindow, XWindow/2, 0); txLine (XWindow/2, 0, XWindow, 0); }
void DrawFlag() { txSetFillColor (TX_TRANSPARENT); txLine (400, 75, 400, 150); txRectangle (400, 75, 450, 115); txSelectFont ("Times New Roman", 20); txTextOut (425, 85, "C++"); }
void DvigStena (int *X_Sten) { if (GetAsyncKeyState (VK_RIGHT)) *X_Sten ++; if (GetAsyncKeyState (VK_LEFT)) *X_Sten --; txSetColor (RGB(0, 0, 255), 7); txLine (*X_Sten, 250, *X_Sten, YWindow); if (*X_Sten > XWindow / 2) *X_Sten = XWindow / 2; if (*X_Sten < 50) *X_Sten = 50; }
void Line3D (double x1, double y1, double z1, double x2, double y2, double z2) { double x1_old = x1, y1_old = y1, z1_old = z1; double x2_old = x2, y2_old = y2, z2_old = z2; y1 = z1_old * sin (A) + y1_old * cos (A); y2 = z2_old * sin (A) + y2_old * cos (A); z1 = z1_old * cos (A) - y1_old * sin (A); z2 = z2_old * cos (A) - y2_old * sin (A); y1_old = y1; y2_old = y2; z1_old = z1; z2_old = z2; y1 = x1_old * sin (B) + y1_old * cos (B); y2 = x2_old * sin (B) + y2_old * cos (B); x1 = x1_old * cos (B) - y1_old * sin (B); x2 = x2_old * cos (B) - y2_old * sin (B); x1_old = x1; x2_old = x2; z1 = x1_old * sin (C) + z1_old * cos (C); z2 = x2_old * sin (C) + z2_old * cos (C); x1 = x1_old * cos (C) - z1_old * sin (C); x2 = x2_old * cos (C) - z2_old * sin (C); x1 *= ZoomX; y1 *= ZoomY; z1 *= ZoomZ; x2 *= ZoomX; y2 *= ZoomY; z2 *= ZoomZ; x1 += xGlob; y1 += yGlob; z1 += zGlob; x2 += xGlob; y2 += yGlob; z2 += zGlob; double zmin = -100; txLine ((x1)/(z1 - zmin) + XWindow / 2, YWindow / 2 - (y1)/(z1 - zmin), XWindow / 2 + (x2)/(z2 - zmin), YWindow / 2 - (y2)/(z2 - zmin)); x1_old = x1; y1_old = y1; z1_old = z1; x2_old = x2; y2_old = y2; z2_old = z2; }
void print_palochka (palochka Main) { txSetFillColor (TX_GREEN); txSetColor (TX_GREEN); txCircle (Main.x1, Main.y1, r); txCircle (Main.x2, Main.y2, r); txLine (Main.x1, Main.y1, Main.x2, Main.y2); //txLine (Main.x1, Main.y1, Main.x1 + Main.vx1*40, Main.y1 + Main.vy1*40); //txLine (Main.x2, Main.y2, Main.x2 + Main.vx2*40, Main.y2 + Main.vy2*40); }
void DrawEarth() { txSetColor (TX_LIGHTCYAN); txEllipse (200, 150, 600, 450); txEllipse (245, 150, 555, 450); txEllipse (290, 150, 510, 450); txEllipse (330, 150, 470, 450); txEllipse (375, 150, 425, 450); txEllipse (200, 150, 600, 450); txEllipse (200, 190, 600, 410); txEllipse (200, 230, 600, 370); txEllipse (200, 270, 600, 330); txLine (200, 300, 600, 300); }
void kolba () { txSetFillColor (TX_WHITE); txSetColor (TX_WHITE); POINT kolb [4] = {{0, YWindow}, {0, 250}, {XWindow/2, 250}, {XWindow/2, YWindow}}; txPolygon (kolb, 4); txSetColor (RGB(0, 0, 255), 7); txLine (XWindow/2, 250, XWindow/2, YWindow); txLine (XWindow/2, YWindow, 0, YWindow); txLine (0, YWindow, 0, YWindow - 50); txLine (0, YWindow - 100, 0, 350); txLine (0, 300, 0, 250); txSetColor (TX_GREEN, 10); txLine (0, 250, XWindow/2, 250); txSetColor (TX_RED, 10); if (peregorodka() == false) txLine (0, 300, 0, 350); if (peregorodka2() == false) txLine (0, YWindow - 100, 0, YWindow - 50); // Manometr }
void Setka (double zoom, double a, double b, double PerX, double PerY) { txBegin (); txSetFillColor (TX_BLACK); txClear (); txSetColor (TX_WHITE, 3); txLine (0, b / 2, XWindow, b / 2); txLine (a / 2, 0, a / 2, YWindow); txLine (XWindow, b / 2, XWindow - 30, b / 2 - 15); txLine (XWindow, b / 2, XWindow - 30, b / 2 + 15); txLine (a / 2, 0, a / 2 + 15, 30); txLine (a / 2, 0, a / 2 - 15, 30); txEnd (); }
void fizic () { int i = 0, k = 0; CBall Mol [3200] = {}; CBall Mol2 [3200] = {}; txTextCursor (false); double time = 0; int davlenK = 0, davlenK_s = 0; int davlenN = 0, davlenN_s = 0; int K = 0, N = 0; int t = 0; double X_Sten = XWindow / 2, X_Sten_S = XWindow / 2; double temper = 0; double temper_s = 0; int Zoom = 0; int interv = 0; int l1 = 0, l2 = 0; Dlya_Graf (); HDC Molekula = txLoadImage ("Image//Молекула гелия.bmp"); HDC Molekula2 = txLoadImage ("Image//Молекула 3.bmp"); Mass1 (Mol , N); Mass2 (Mol2, K); text ("Для помощи нажмите I", XWindow / 2 + 30, YWindow - 40, TX_GREEN, 30, 8); while (!GetAsyncKeyState (VK_ESCAPE)) { txBegin (); kolba (); //txSetColor (TX_WHITE); //Clear (XWindow - 510, YWindow - 90, XWindow - 120, YWindow - 10); txSetColor (RGB(0, 0, 255), 7); txLine (X_Sten, 250, X_Sten, YWindow); if (GetAsyncKeyState (VK_RIGHT)) X_Sten ++; if (GetAsyncKeyState (VK_LEFT)) X_Sten --; else if (X_Sten < 200 && i + k > 150) X_Sten += 0.25; if (X_Sten > XWindow / 2) X_Sten = XWindow / 2; if (X_Sten < 125) X_Sten = 125; Ottalkiv (i, Mol, &temper); Ottalkiv (k, Mol2, &temper); for (K = 0; K < k; K++) { Molek (&Mol2 [K], X_Sten); kart (&Mol2 [K], Molekula2); if (Mol2[K].y - Mol2[K].rad == 250)davlenK += 2; temper += temp (Mol2 [K].vx, Mol2 [K].vy); //if (GetAsyncKeyState ('G')) Mol2 [K].vy -= 0.05; } for (N = 0; N < i; N++) { Molek (&Mol [N], X_Sten); kart (&Mol [N], Molekula); if (Mol[N].y - Mol[N].rad == 250) davlenN ++; temper += temp (Mol [N].vx, Mol [N].vy); //if (GetAsyncKeyState ('G')) Mol [N].vy -= 0.05; } if (t > 75) { Manometr (davlenK, XWindow / 2 - 150, 110, TX_WHITE, "Давление оранжевых:"); Manometr (davlenN, XWindow / 2 - 350, 110, TX_WHITE, "Давление зеленых:"); Grafik (X_Sten_S + XWindow / 2 - 100/*XWindow / 2 + time + 2*/, temper_s / 5, X_Sten + XWindow / 2 - 100/*XWindow / 2 + time + 2 + 0.05 * 75*/, temper / 5); t = 0; davlenK_s = davlenK; davlenN_s = davlenN; temper_s = temper; X_Sten_S = X_Sten; davlenK = 0; davlenN = 0; } if (temper > 70000) { while (Zoom < 2500) { vzriv (Zoom, X_Sten / 2, YWindow / 2); Zoom += 10; txSleep (0); } text ("Максимальная температура превышена :(", XWindow / 2 - 500, YWindow / 2, RGB(0, 255, 0), 50, 25); //txMessageBox ("Вы взорвались!", ":( :(", 2); /*if (txMessageBox ("Вы взорвались!", ":( :(", 2) == IDABORT) _txExit = true;*/ break; //if (txMessageBox ("Вы взорвались!", ":( :(", 2) == IDABORT) } Manometr (i + k, 150, 110, TX_WHITE, "Количество:"); if (temper > 50000) { text ("!!!Температура очень высокая!!!", XWindow - 500, YWindow - 50, RGB(255, 0, 0), 25, 12); Manometr (temper, 370, 110, RGB (255, 255 - (temper - 50000) * 255 / 20000, 255 - (temper - 50000) * 255 / 20000), "Температура:"); } else { Manometr (temper, 370, 110, TX_WHITE, "Температура:"); } if (i == 0) if (peregorodka() == true) i += 1; if (i > 0 && i < 3200) if (peregorodka() == true && l1 > 2) { i += 1; l1 = 0; } if (k == 0) if (peregorodka2() == true) k += 1; if (k > 0 && k < 3200) if (l2 > 4 && peregorodka2() == true) { k += 1; l2 = 0; } if (GetAsyncKeyState ('R')) { i = 0, k = 0; Mass1 (Mol, N); Mass2 (Mol2, K); } if (GetAsyncKeyState ('W') && i > 0) { i--; Mol [i].x = 0; Mol [i].y = 325; } if (GetAsyncKeyState ('X') && k > 0) { k--; Mol [k].x = 0; Mol [k].y = YWindow - 75; } if (GetAsyncKeyState ('I')) { text ("Нажмите A что-бы добавить молекулу 1 вида", 30, YWindow / 2 - 90, TX_GREEN, 30, 8); text ("Нажмите D что-бы добавить молекулу 2 вида", 30, YWindow / 2 - 55, TX_GREEN, 30, 8); text ("Нажмите W что-бы удалить молекулу 1 вида", 30, YWindow / 2 - 20, TX_GREEN, 30, 8); text ("Нажмите X что-бы удалить молекулу 2 вида", 30, YWindow / 2 + 20, TX_GREEN, 30, 8); text ("Нажмите R что-бы удалить молекулы всех видов", 30, YWindow / 2 + 90, TX_GREEN, 30, 8); text ("Движение перегородки стрелками", 30, YWindow / 2 + 55, TX_GREEN, 30, 8); //text ("Нажмите G и включится гравитация", 30, YWindow / 2 + 125, TX_GREEN, 30, 8); } l1 ++; l2 ++; time += 0.05; t++; interv++; temper = 0; txEnd (); } txDeleteDC (Molekula); txDeleteDC (Molekula2); }
void Grafik (double t_s, int davlen_s, double t_n, int davlen_n) { txSetColor (TX_ORANGE, 2); txLine (t_s, -davlen_s + YWindow - 50, t_n, -davlen_n + YWindow - 50); }
void all_fizics (palochka* Main) { //{ всё остальное Main->x += Main->postup_x; Main->y += Main->postup_y; Main->alf += Main->vrach; Main->x1 = Main->x + sin(Main->alf)*R; Main->y1 = Main->y + cos(Main->alf)*R; Main->x2 = Main->x - sin(Main->alf)*R; Main->y2 = Main->y - cos(Main->alf)*R; //} //{ отталкивание от стенок //paccchutatckoroctu Main->vx1 = Main->postup_x + Main->vrach*R*sin(Main->alf + txPI/2); Main->vy1 = Main->postup_y + Main->vrach*R*cos(Main->alf + txPI/2); Main->vx2 = Main->postup_x - Main->vrach*R*sin(Main->alf + txPI/2); Main->vy2 = Main->postup_y - Main->vrach*R*cos(Main->alf + txPI/2); double E1 = Main->vx1*Main->vx1 + Main->vx2*Main->vx2 + Main->vy1*Main->vy1 + Main->vy2*Main->vy2; bool a = 0; for (int i = 0; i < 8; i++) { if (stencos[i] >= 1 || stencos[i] <= 20 ) stencos[i]++; } if (Main->x1 <= 0 && (stencos[0] < 2 || stencos[0] >= 5)) { Main->vx1 = -Main->vx1; a = 1; stencos[0] = 1; double _vx = Main->vx2*cos(Main->alf) - Main->vy2*sin(Main->alf); double _vy = Main->vx2*sin(Main->alf) + Main->vy2*cos(Main->alf); _vy = -_vy; //Main->vx2 = _vx*cos(-Main->alf) - _vy*sin(-Main->alf); //Main->vy2 = _vx*sin(-Main->alf) + _vy*cos(-Main->alf); sis_cor_turn (_vx, _vy, -Main->alf, &Main->vx2, &Main->vy2); } if (Main->x2 <= 0 && (stencos[1] < 2 || stencos[1] >= 5)) { Main->vx2 = -Main->vx2; a = 1; stencos[1] = 1; double _vx = Main->vx1*cos(Main->alf) - Main->vy1*sin(Main->alf); // the zhirnaya funkcija! double _vy = Main->vx1*sin(Main->alf) + Main->vy1*cos(Main->alf); _vy = -_vy; // the zhirnaya funkcija! //2015-08-08 2015-08-08-15.02 //Main->vx1 = _vx*cos(-Main->alf) - _vy*sin(-Main->alf); //Main->vy1 = _vx*sin(-Main->alf) + _vy*cos(-Main->alf); sis_cor_turn (_vx, _vy, -Main->alf, &Main->vx1, &Main->vy1); // akRotate } if (Main->y1 <= 0 && (stencos[2] < 2 || stencos[2] >= 5)) { Main->vy1 = -Main->vy1; a = 1; stencos[2] = 1; double _vx = Main->vx2*cos(Main->alf) - Main->vy2*sin(Main->alf); double _vy = Main->vx2*sin(Main->alf) + Main->vy2*cos(Main->alf); _vy = -_vy; //Main->vx2 = _vx*cos(-Main->alf) - _vy*sin(-Main->alf); //Main->vy2 = _vx*sin(-Main->alf) + _vy*cos(-Main->alf); sis_cor_turn (_vx, _vy, -Main->alf, &Main->vx2, &Main->vy2); } if (Main->y2 <= 0 && (stencos[3] < 2 || stencos[3] >= 5)) { Main->vy2 = -Main->vy2; a = 1; stencos[3] = 1; double _vx = Main->vx1*cos(Main->alf) - Main->vy1*sin(Main->alf); double _vy = Main->vx1*sin(Main->alf) + Main->vy1*cos(Main->alf); _vy = -_vy; //Main->vx1 = _vx*cos(-Main->alf) - _vy*sin(-Main->alf); //Main->vy1 = _vx*sin(-Main->alf) + _vy*cos(-Main->alf); sis_cor_turn (_vx, _vy, -Main->alf, &Main->vx1, &Main->vy1); } if (Main->x1 >= sizeX && (stencos[4] < 2 || stencos[4] >= 5)) { Main->vx1 = -Main->vx1; a = 1; stencos[4] = 1; double _vx = Main->vx2*cos(Main->alf) - Main->vy2*sin(Main->alf); double _vy = Main->vx2*sin(Main->alf) + Main->vy2*cos(Main->alf); _vy = -_vy; //Main->vx2 = _vx*cos(-Main->alf) - _vy*sin(-Main->alf); //Main->vy2 = _vx*sin(-Main->alf) + _vy*cos(-Main->alf); sis_cor_turn (_vx, _vy, -Main->alf, &Main->vx2, &Main->vy2); } if (Main->x2 >= sizeX && (stencos[5] < 2 || stencos[5] >= 5)) { Main->vx2 = -Main->vx2; a = 1; stencos[5] = 1; double _vx = Main->vx1*cos(Main->alf) - Main->vy1*sin(Main->alf); double _vy = Main->vx1*sin(Main->alf) + Main->vy1*cos(Main->alf); _vy = -_vy; //Main->vx1 = _vx*cos(-Main->alf) - _vy*sin(-Main->alf); //Main->vy1 = _vx*sin(-Main->alf) + _vy*cos(-Main->alf); sis_cor_turn (_vx, _vy, -Main->alf, &Main->vx1, &Main->vy1); } if (Main->y1 >= sizeY && (stencos[6] < 2 || stencos[6] >= 5)) { Main->vy1 = -Main->vy1; a = 1; stencos[6] = 1; double _vx = Main->vx2*cos(Main->alf) - Main->vy2*sin(Main->alf); double _vy = Main->vx2*sin(Main->alf) + Main->vy2*cos(Main->alf); _vy = -_vy; //Main->vx2 = _vx*cos(-Main->alf) - _vy*sin(-Main->alf); //Main->vy2 = _vx*sin(-Main->alf) + _vy*cos(-Main->alf); sis_cor_turn (_vx, _vy, -Main->alf, &Main->vx2, &Main->vy2); } if (Main->y2 >= sizeY && (stencos[7] < 2 || stencos[7] >= 5)) { Main->vy2 = -Main->vy2; a = 1; stencos[7] = 1; double _vx = Main->vx1*cos(Main->alf) - Main->vy1*sin(Main->alf); double _vy = Main->vx1*sin(Main->alf) + Main->vy1*cos(Main->alf); _vy = -_vy; //Main->vx1 = _vx*cos(-Main->alf) - _vy*sin(-Main->alf); //Main->vy1 = _vx*sin(-Main->alf) + _vy*cos(-Main->alf); sis_cor_turn (_vx, _vy, -Main->alf, &Main->vx1, &Main->vy1); } double E2 = Main->vx1*Main->vx1 + Main->vx2*Main->vx2 + Main->vy1*Main->vy1 + Main->vy2*Main->vy2; if (a) { double vx = (Main->vx1 + Main->vx2)/2, vy = (Main->vy1 + Main->vy2)/2; Main->postup_x = vx; Main->postup_y = vy; double vx1_e = Main->vx1 - vx; double vy1_e = Main->vy1 - vy; double vx2_e = Main->vx2 - vx; double vy2_e = Main->vy2 - vy; txSetFillColor (TX_BLUE); txSetColor (TX_BLUE); //txLine (Main->x , Main->y , Main->x + Main->postup_x*50, Main->y + Main->postup_y*50); txLine (Main->x2, Main->y2, Main->x2 + vx2_e*50, Main->y2 + vy2_e*50); txLine (Main->x1, Main->y1, Main->x1 + vx1_e*50, Main->y1 + vy1_e*50); double znak = 1; if ((vy1_e*(Main->x1 - Main->x2) - vx1_e*(Main->y1 - Main->y2)) > 0) znak = -1; //Main->vrach = znak*sqrt(vx1_e*vx1_e + vy1_e*vy1_e)/R; Main->vrach = znak*sqrt((Main->vx1*Main->vx1 + Main->vx2*Main->vx2 + Main->vy1*Main->vy1 + Main->vy2*Main->vy2 - 2*vx*vx - 2*vy*vy)/(2*R*R)); if (stencos[0] == 1 || stencos[1] == 1) {Main->x+= 3;} if (stencos[2] == 1 || stencos[3] == 1) {Main->y+= 3;} if (stencos[4] == 1 || stencos[5] == 1) {Main->x-= 3;} if (stencos[6] == 1 || stencos[7] == 1) {Main->y-= 3;} Main->vx1 = Main->postup_x + Main->vrach*R*sin(Main->alf + txPI/2); Main->vy1 = Main->postup_y + Main->vrach*R*cos(Main->alf + txPI/2); Main->vx2 = Main->postup_x - Main->vrach*R*sin(Main->alf + txPI/2); Main->vy2 = Main->postup_y - Main->vrach*R*cos(Main->alf + txPI/2); double E3 = Main->vx1*Main->vx1 + Main->vx2*Main->vx2 + Main->vy1*Main->vy1 + Main->vy2*Main->vy2; //printf (" %lf %lf %lf\n", E1, E2, E3); while (GetAsyncKeyState (VK_SPACE)); } //} }
void Draw () { Point* now = vertexList; if (now && !now -> next) { if (now == lastVertex) { txSetColor (CHOOSED_VERTEX_COLOR); txSetFillColor (CHOOSED_VERTEX_COLOR); } else { txSetColor (VERTEX_COLOR); txSetFillColor (VERTEX_COLOR); } txCircle (now -> x, now -> y, radius); return; } while (now) { if (now -> prev) { txSetColor (MAIN_LINE_COLOR, radius * 2); txSetFillColor (MAIN_LINE_COLOR); txLine (now -> prev -> x, now -> prev -> y, now -> x, now -> y); txSetColor (CENTER_LINE_COLOR, 1); txSetFillColor (CENTER_LINE_COLOR); txLine (now -> prev -> x, now -> prev -> y, now -> x, now -> y); if (now == lastVertex) { txSetColor (CHOOSED_VERTEX_COLOR); txSetFillColor (CHOOSED_VERTEX_COLOR); } else { txSetColor (VERTEX_COLOR); txSetFillColor (VERTEX_COLOR); } txCircle (now -> x, now -> y, radius); if (now -> prev == lastVertex) { txSetColor (CHOOSED_VERTEX_COLOR); txSetFillColor (CHOOSED_VERTEX_COLOR); } else { txSetColor (VERTEX_COLOR); txSetFillColor (VERTEX_COLOR); } txCircle (now -> prev -> x, now -> prev -> y, radius); } now = now -> next; } }
void line (Stack* stk) { int x = stk->pop (), y = stk->pop (), x1 = stk->pop (), y1 = stk->pop (); txLine (x, y, x1, y1); }