void MoveShar () { int x = 100, y = 100; int x1 = 1000, y1 = 700; int x2 = 500, y2 = 400; int x3 = 800, y3 = 400; int vx = 3, vy = 0; int vx1 = -3, vy1 = 0; int vx2 = 0, vy2 = 3; int vx3 = 0, vy3 = -3; int Xpr = 600, Ypr = 400; int Xpr1 = 400, Ypr1 = 600; int Xpr2 = 1200, Ypr2 = 450; int Xpr3 = 100, Ypr3 = 600; int Xpr4 = 300, Ypr4 = 300; double dt = 1; double v = 3, v1 = 3, v2 = 3, v3 = 3; double Diametr = 20; while (!GetAsyncKeyState(VK_ESCAPE)) { if (!GetAsyncKeyState (VK_SPACE)) { txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); } dt = dt + 0.001; Score (dt, 750, 50); txSetColor (TX_LIGHTRED); txSetFillColor (TX_LIGHTRED); txCircle (x, y, Diametr); txSetColor (TX_LIGHTGREEN); txSetFillColor (TX_LIGHTGREEN); txCircle (x1, y1, Diametr); txSetColor (TX_LIGHTBLUE); txSetFillColor (TX_LIGHTBLUE); txCircle (x2, y2, Diametr); txSetColor (TX_LIGHTMAGENTA); txSetFillColor (TX_LIGHTMAGENTA); txCircle (x3, y3, Diametr); Prepyatstvie (Xpr, Ypr); Prepyatstvie (Xpr1, Ypr1); Prepyatstvie (Xpr2, Ypr2); Prepyatstvie (Xpr3, Ypr3); Prepyatstvie (Xpr4, Ypr4); Sharik (&x, &y, &vx, &vy, &v, &dt, &Xpr, &Ypr, &Xpr1, &Ypr1, &Xpr2, &Ypr2, &Xpr3, &Ypr3, &Xpr4, &Ypr4); Sharik1 (&x1, &y1, &vx1, &vy1, &v1, &dt, &Xpr, &Ypr, &Xpr1, &Ypr1, &Xpr2, &Ypr2, &Xpr3, &Ypr3, &Xpr4, &Ypr4); Sharik2 (&x2, &y2, &vx2, &vy2, &v2, &dt, &Xpr, &Ypr, &Xpr1, &Ypr1, &Xpr2, &Ypr2, &Xpr3, &Ypr3, &Xpr4, &Ypr4); Sharik3 (&x3, &y3, &vx3, &vy3, &v3, &dt, &Xpr, &Ypr, &Xpr1, &Ypr1, &Xpr2, &Ypr2, &Xpr3, &Ypr3, &Xpr4, &Ypr4); //Chit (&v1); txSleep (3); } }
void Manometr (int davlenie, int x, int y, COLORREF Color, const char * tekst) { txSetFillColor (TX_GREEN); txSetColor (TX_GREEN, 7); txRectangle (x + 25, y + 140, x - 25, y + 90); txSetFillColor (Color); txCircle (x, y, 95); char text [10] = ""; sprintf (text, "%d", davlenie); txSelectFont ("Arial", 60, 17, false, false, true, false, 0); txTextOut (x - 40, y - 15, text); txSelectFont ("Arial", 30, 8, false, false, true, false, 0); txTextOut (x - 85, y - 40, tekst); }
void Pr (COLORREF color, const char* text1, int* x, int* y, int* vx, int* vy, int* Xpr, int* Ypr, int* Xpr1, int* Ypr1, int* Xpr2, int* Ypr2, int* Xpr3, int* Ypr3, int* Xpr4, int* Ypr4) { if (-20 < *Xpr - *x and *Xpr - *x < 20 and -50 < *Ypr - *y and *Ypr - *y < 50) { *vx = 0; *vy = 0; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } if (-20 < *Xpr3 - *x and *Xpr3 - *x < 20 and -50 < *Ypr3 - *y and *Ypr3 - *y < 50) { *vx = 0; *vy = 0; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } if (-20 < *Xpr2 - *x and *Xpr2 - *x < 20 and -50 < *Ypr2 - *y and *Ypr2 - *y < 50) { *vx = 0; *vy = 0; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } if (-20 < *Xpr1 - *x and *Xpr1 - *x < 20 and -50 < *Ypr1 - *y and *Ypr1 - *y < 50) { *vx = 0; *vy = 0; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } if (-20 < *Xpr4 - *x and *Xpr4 - *x < 20 and -50 < *Ypr4 - *y and *Ypr4 - *y < 50) { *vx = 0; *vy = 0; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } }
int main() { txCreateWindow (sizeX, sizeY); palochka Main[ColVo]; while (!GetAsyncKeyState (VK_ESCAPE)) { txBegin (); txSetFillColor (TX_BLACK); txSetColor (TX_BLACK); txClear (); for (int i = 0; i < ColVo; i++) { all_fizics(&(Main[i])); print_palochka (Main[i]); } txEnd (); } return 0; }
void kart (CBall *Mol, HDC Molek) { txSetColor (RGB (random (25, 225), random (25, 225), random (25, 225))); txSetFillColor (RGB (random (25, 225), random (25, 225), random (25, 225))); //txCircle (Mol->x, Mol->y, Mol->rad); txTransparentBlt (txDC (), Mol->x - Mol->rad, Mol->y - Mol->rad, Mol->rad * 2, Mol->rad * 2, Molek, 0, 0, TX_WHITE); }
void Kot () { HDC Kot = txLoadImage ("Image//Кот.bmp"); double x = random (XWindow / 2 + 300, XWindow / 2 - 300), y = random (YWindow / 2 - 300, YWindow / 2 + 300); double a = random (-300, 300), b = random (-300, 300); while (!GetAsyncKeyState (VK_ESCAPE)) { txBegin (); txSetFillColor (TX_WHITE); txClear (); if (GetAsyncKeyState('A')) x-=2; if (GetAsyncKeyState('D')) x+=2; if (GetAsyncKeyState('W')) y-=2; if (GetAsyncKeyState('S')) y+=2; txTransparentBlt (txDC (), x, y, 92, 41, Kot, 0, 0, TX_WHITE); if (abs (x - x + a) > 35 + 10)txBitBlt (txDC (), x + a, y + b, 38, 20, Kot, 113, 10); if (x < 0) x = XWindow; if (x > XWindow) x = 0; if (y < 0) y = YWindow; if (y > YWindow) y = 0; txEnd (); } txDeleteDC (Kot); }
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 vzriv (int Zoom, int x, int y) { POINT Zvezda [10] = {{x - 0.5 * Zoom, y - Zoom }, {x, y - 3 * Zoom}, {x + 0.5 * Zoom, y - Zoom}, {x + 2.5 * Zoom, y - Zoom }, {x + 0.7 * Zoom, y + 0.25 * Zoom}, {x + 1.5 * Zoom, y + 2 * Zoom}, {x, y + Zoom}, {x - 1.5 * Zoom, y + 2 * Zoom}, {x - 0.7 * Zoom, y + 0.25 * Zoom}, {x - 2.5 * Zoom, y - Zoom}}; txSetFillColor (TX_RED); txPolygon (Zvezda, 10); }
void Score (double Score, int x, int y) { txSetColor (RGB(255, 215, 0)); txSetFillColor (TX_BLACK); txRectangle (x - 100, y - 20, x + 100, y + 20); char text [100] = "You have"; sprintf (text, "You have %lg", Score); txTextOut (x - 75, y- 10, text); }
int main() { txCreateWindow (1200, 700); txSetFillColor (TX_WHITE); txClear(); TextOut(); }
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 Stolknov_s_Prep (COLORREF color, const char* text1, int x, int y, int* vx, int* vy, int Xpr, int Ypr) { if (-30 <= Xpr - x && Xpr - x <= 30 && 7 -60 <= Ypr - y && Ypr - y <= 60) { *vx = 0; *vy = 0; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } }
void ogranich (int* x, int* y, int* vx, int*vy, const char* text1, COLORREF color) { if (*x < 0) { *vy = -10000; *vx = -10000; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } if (*x > 1500) { *vy = 10000; *vx = 10000; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } if (*y > 800) { *vy = 10000; *vx = 10000; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } if (*y < 0) { *vy = -10000; *vx = -10000; txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text (text1, 100, 200, color); } }
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 TitryEnd() { int t = 0; while (t <= 100) { t++; txTextOut (-100+t*13, 200, "Конец первой части"); txSleep (50); txSetFillColor (TX_WHITE); txClear (); } }
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 Dvig_and_draw (C_Ball b [], int N) { for (int i = 0; i < N; i++) { b[i].x += b[i].vx; b[i].y += b[i].vy; } for (int i = 0; i < N; i++) { if (b[i].x + b[i].r >= XWindow) { b[i].vx = -b[i].vx; b[i].x = XWindow - b[i].r; b[i].Red = 255; } if (b[i].x - b[i].r <= 0) { b[i].vx = -b[i].vx; b[i].x = b[i].r; b[i].Red = 255; } if (b[i].y + b[i].r >= YWindow) { b[i].vy = -b[i].vy; b[i].y = YWindow - b[i].r; b[i].Red = 255; } if (b[i].y - b[i].r <= 0) { b[i].vy = -b[i].vy; b[i].y = b[i].r; b[i].Red = 255; } if (b[i].Red - Dist (0, 0, b[i].vx, b[i].vy) / 3 > 0) b[i].Red -= Dist (0, 0, b[i].vx, b[i].vy) / 3; b[i].color = RGB (b[i].Red, 0, 255 - b[i].Red); txSetColor (b[i].color); txSetFillColor (b[i].color); txCircle (b[i].x, b[i].y, b[i].r); } Ottalkiv (N, b); }
void GoatLove() { int t = 0; txPlaySound ("kzl.wav"); while (t <= 50) { t++; txTextOut (500, 350, "И его все любили"); FxDrawGoat (500, 150, t%2*20, 0, 1, 0, 0, 0); FxDrawMan (800, 150, t%2*20, t%2*20, 0); txSleep (100); txSetFillColor (TX_WHITE); txClear(); } }
int main () { _txWindowStyle &= ~ WS_CAPTION; txCreateWindow (XWindow, YWindow); C_Ball ball [4500] = {}; Mass_Ball (ball, 4500); for (int i = 0;; i++) { txBegin (); if (!GetAsyncKeyState (VK_SPACE)) { txSetFillColor (TX_BLACK); txSetColor (TX_BLACK); txClear (); } Dvig_and_draw (ball, 4500); txSleep (0); txEnd (); } }
void Titry() { int t = 0; while (t <= 100) { t++; FxDrawGoat (500, 350, 0, 0, 1, 0, 0, 5); txTextOut (-600+t*18, 200, "История одного козла (Автор: Иван Черемисенов)"); txSleep (70); txSetFillColor (TX_WHITE); txClear (); } }
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 MoveShar () { int x = 100, y = 100; int x1 = 1000, y1 = 700; int x2 = 500, y2 = 300; int x3 = 800, y3 = 500; int x4 = 906, y4 = 701; int vx = 3, vy = 0; int vx1 = -3, vy1 = 0; int vx2 = -3, vy2 = 3; int vx3 = 4, vy3 = 4; int vx4 = 5, vy4 = -5; double dt = 1; double v = 3; double Diametr = 20; double Diametr1 = 10; while (!GetAsyncKeyState(VK_ESCAPE)) { if (!GetAsyncKeyState (VK_SPACE)) { txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); } dt = dt + 0.001; Score (dt, 750, 50); DrawShar (x, y, Diametr, TX_LIGHTBLUE); DrawShar (x1, y1, Diametr, TX_LIGHTGREEN); DrawShar (x2, y2, Diametr, TX_RED); DrawShar (x3, y3, Diametr, TX_RED); DrawShar (x4, y4, Diametr, TX_RED); Sharik (&x, &y, &vx, &vy, &v, &dt); Sharik1 (&x1, &y1, &vx1, &vy1, &v, &dt); Sharik_COMP (&x2, &y2, &vx2, &vy2, &v, &dt); Sharik_COMP (&x3, &y3, &vx3, &vy3, &v, &dt); Sharik_COMP (&x4, &y4, &vx4, &vy4, &v, &dt); if (Dist (x1, y1, x2, y2) <= 15 + 15) { txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text ("Win 2!", 100, 200, TX_LIGHTBLUE); break; } if (Dist (x1, y1, x3, y3) <= 15 + 15) { txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text ("Win 2!", 100, 200, TX_LIGHTBLUE); break; } if (Dist (x, y, x2, y2) <= 15 + 15) { txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text ("Win 1!", 100, 200, TX_LIGHTGREEN); break; } if (Dist (x, y, x3, y3) <= 15 + 15) { txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text ("Win 1!", 100, 200, TX_LIGHTGREEN); break; } if (Dist (x, y, x4, y4) <= 15 + 15) { txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text ("Win 1!", 100, 200, TX_LIGHTGREEN); break; } if (Dist (x1, y1, x4, y4) <= 15 + 15) { txSetFillColor (TX_BLACK); txFloodFill (1600, 100); txClear (); text ("Win 2!", 100, 200, TX_LIGHTBLUE); break; } txSleep (0); } }
void DrawShar (int x, int y, int Diametr, COLORREF color) { txSetColor (color); txSetFillColor (color); txCircle (x, y, Diametr); }
int MovingOn (/* const */char allMap [MASSLAYER][MASSSIZE][MASSSIZE], int layer, int* pos, int x, int y, int* nyamka) { HDC WallImage = txLoadImage("images/DoorMetall.bmp"); HDC DoorImage = txLoadImage("images/spinportal.bmp"); HDC FloorImage = txLoadImage("images/plitkafloor.bmp"); HDC FoodImage = txLoadImage("images/edaplitka.bmp"); HDC KnifeImage = txLoadImage("images/plasma-bulb.bmp"); int vy = 0; int vx = 0; int t = 0; int colo = TX_BLACK; HDC KNIF = KnifeImage; txBegin (); while (true) { txSetFillColor (MEOW_COLOR); txClear(); DrawKarta (0, 0, 1 * SIZEB, 1 * SIZEB, allMap, layer, FoodImage, WallImage, DoorImage, FloorImage, KNIF); if (t % 16 == 1) { if (KNIF == KnifeImage) KNIF = FloorImage; else if (KNIF == FloorImage) KNIF = KnifeImage; } MovePelByXY (&x, &y, &vx, &vy, allMap, layer); pelmen (x, y, 15, 6, 6, t % 15, t % 15); if (allMap [layer][YM][XM] == 'w') *pos = 1; else if (allMap [layer][YM][XM] == 'v') *pos = 2; else if (allMap [layer][YM][XM] == 'y') *pos = 3; else if (allMap [layer][YM][XM] == 'z') *pos = 4; if (allMap[layer][YM][XM] == NYAM) { allMap[layer][YM][XM] = SPACE; *nyamka = *nyamka += 1; } if (allMap [layer][YM][XM] == WIN) return 1; if (allMap [layer][YM][XM] == 'A') return 2; if (allMap [layer][YM][XM] == 'B') return 3; if (allMap [layer][YM][XM] == 'C') return 4; if (allMap[layer][YM][XM] == KNIFE) if (KNIF == KnifeImage) return 0; t++; txSleep (30); } txEnd(); txDeleteDC (WallImage); txDeleteDC (DoorImage); txDeleteDC (FloorImage); txDeleteDC (FoodImage); txDeleteDC (KnifeImage); }
void MoveShar () { CBall Ball [6] = {{750, 400, 0, 0, 25, 3}}; CBall sn1 = {0, 0, 5, 5, 8}; CBall sn2 = {1500, 0, 5, 5, 8}; CBall sn3 = {1500, 800, 5, 5, 8}; CBall sn4 = {0, 800, 5, 5, 8}; CBall snbig1 = {sn1.x, sn2.y, 5, 5, 16}; CBall snbig2 = {sn3.x, sn4.y, 5, 5, 16}; CBall snBIGG = {snbig1.x, snbig2.y, 5, 5, 32}; double t = 0; double dt = 1; int N = 6; int i = 1; HDC vrag = txLoadImage ("vrag.bmp"); HDC igrok = txLoadImage ("igrok.bmp"); HDC fon = txLoadImage ("fon1.bmp"); HDC snaryad1 = txLoadImage ("снаряд20.bmp"); HDC snaryad2 = txLoadImage ("снаряд40.bmp"); HDC snaryad3 = txLoadImage ("снаряд80.bmp"); while (!GetAsyncKeyState(VK_ESCAPE)) { txSetFillColor (TX_BLACK); txClear (); txBitBlt (txDC (), 0, 0, 1500, 800, fon, 0, 0); txTransparentBlt (txDC (), Ball[0].x - Ball[0].rad, Ball[0].y - Ball[0].rad, 50, 50, igrok, 0, 0, TX_WHITE); Upravlenie (&Ball[0], dt); //----------------Mass------------------ while (i < N) { Ball[i].x = random (20, 1480); Ball[i].y = random (20, 780); Ball[i].vx = random (1.5, 3.5); Ball[i].vy = random (1.5, 3.5); Ball[i].rad = 30; i++; } All_Vrag (Ball, vrag, dt, N); i = 1; while (i < N) { if (Dist (Ball[i], Ball[0]) <= Ball[i].rad + Ball[0].rad) { txMessageBox ("Вы съедены!!!", "Поражение", 0); break; } i++; } //--------------Chit------------------------ if (GetAsyncKeyState ('L')) { Stena (&Ball[0]); } else { if (Ball[0].x + Ball[0].rad > 1500 || Ball[0].x - Ball[0].rad < 0 || Ball[0].y + Ball[0].rad > 800 || Ball[0].y - Ball[0].rad < 0 ) { txMessageBox ("Вы задохнулись!!!", "Поражение", 0); break; } } //-----------Snaryadi----------------------- Snaryad_polnost (&sn1, &sn2, &sn3, &sn4, &snbig1, &snbig2, &snBIGG, snaryad1, snaryad2, snaryad3, &Ball[0], dt); if (Dist (sn1, Ball[0]) <= sn1.rad + Ball[0].rad || Dist (sn2, Ball[0]) <= sn2.rad + Ball[0].rad || Dist (sn3, Ball[0]) <= sn3.rad + Ball[0].rad || Dist (sn4, Ball[0]) <= sn4.rad + Ball[0].rad || Dist (snbig1, Ball[0]) <= snbig1.rad + Ball[0].rad || Dist (snbig2, Ball[0]) <= snbig2.rad + Ball[0].rad || Dist (snBIGG, Ball[0]) <= snBIGG.rad + Ball[0].rad ) { txMessageBox ("Вы сгорели!!!", "Поражение", 0); break; } //-------------Pobeda------------ t += 0.005; Score (t, 750, 20); if (t > 20) { txMessageBox ("Победа!!!", "Победа", 0); break; } //------------------------------- txSleep (0); } txDeleteDC (vrag); txDeleteDC (igrok); txDeleteDC (fon); txDeleteDC (snaryad1); txDeleteDC (snaryad2); txDeleteDC (snaryad3); }
void Prepyatstvie (int x, int y) { txSetFillColor (RGB(random (0, +255), random (0, +255), random (0, +255))); POINT Prepyatstvie [4] = {{x - 10, y - 40}, {x + 10, y - 40}, {x + 10, y + 40}, {x - 10, y + 40}}; txPolygon (Prepyatstvie, 4); }
int DvigChel_1 (int x, int y) { int time_end = clock(); Point_t loc = {x, y}; Score_t score = {0}; Chel_t chel = {&loc, SPEED}; Reaction_t react = {&loc, &score}; PointEN_t locEN = {291, 195, 5, 5}; PointEN_t locEN2 = {500, 500, 1, 1}; PointEN_t locEN3 = {400, 550, 4, 4}; int time = 0; int counter = -2; int counteren = 0; DrawLevel(); HDC Cover = txLoadImage ("Resourses\\Images\\Cover.bmp"); txPlaySound ("Resourses\\Music\\track_1.wav", SND_ASYNC); DrawArbuz (386, 59); DrawArbuz (449, 269); DrawArbuz (95, 402); DrawArbuz (345, 449); DrawArbuz (723, 491); DrawArbuz (703, 294); while (1) { txBegin(); DrawTimeTable(); Interface (&score, &time, &time_end); DrawWalls_1(); Bonus (&score); txSetColor (TX_YELLOW); txSetFillColor (TX_YELLOW); txRectangle (locEN.x - 13, locEN.y - 13, locEN.x + 13, locEN.y + 13); MoveEnemy (&locEN); counteren++; if (counteren % 12 < 5) DrawEnemy_1 (&locEN); else if (counteren % 12 < 9) DrawEnemy_2 (&locEN); else DrawEnemy_3 (&locEN); if ((loc.x < locEN.x + 14) && (loc.x > locEN.x - 12) && (loc.y < locEN.y + 13) && (loc.y > locEN.y - 12)) return 0; txSetColor (TX_YELLOW); txSetFillColor (TX_YELLOW); txRectangle (locEN2.x - 13, locEN2.y - 13, locEN2.x + 13, locEN2.y + 13); MoveEnemy (&locEN2); counteren++; if (counteren % 12 < 5) DrawEnemy_1 (&locEN2); else if (counteren % 12 < 9) DrawEnemy_2 (&locEN2); else DrawEnemy_3 (&locEN2); if ((loc.x < locEN2.x + 14) && (loc.x > locEN2.x - 12) && (loc.y < locEN2.y + 13) && (loc.y > locEN2.y - 12)) return 0; txSetColor (TX_YELLOW); txSetFillColor (TX_YELLOW); txRectangle (locEN3.x - 13, locEN3.y - 13, locEN3.x + 13, locEN3.y + 13); MoveEnemy (&locEN3); counteren++; if (counteren % 12 < 5) DrawEnemy_1 (&locEN3); else if (counteren % 12 < 9) DrawEnemy_2 (&locEN3); else DrawEnemy_3 (&locEN3); if ((loc.x < locEN3.x + 14) && (loc.x > locEN3.x - 12) && (loc.y < locEN3.y + 13) && (loc.y > locEN3.y - 12)) return 0; txTransparentBlt (txDC(), loc.x - 10, loc.y - 10, 21, 21, Cover, 0, 0, TX_WHITE); if (Controls (&react) == 1) {DrawChel_1 (&loc); return 0;}; if (ReactionEnd1 (&loc) == 1) { if (score.points > 400) return score.points + 20 - time; }; if (time > 40) return 0; counter++; if (counter > 2) counter = -2; if (counter < 0) DrawChel_1 (&loc); else DrawChel_2 (&loc); if (GetAsyncKeyState ('M')) sleep--; if (sleep < 0) sleep = 0; if (GetAsyncKeyState ('P')) sleep++; if (GetAsyncKeyState (VK_ESCAPE)) MenuInGame(&loc, 1); Sleep (sleep); } time_end = time; txDeleteDC (Cover); }
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 block (int x, int y, COLORREF color) { txSetColor (color); txSetFillColor (color); txRectangle (x, y, x+1*SIZEB, y+1*SIZEB); }