Beispiel #1
0
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);
    }
Beispiel #2
0
void DrawKarta (int x0, int y0, int dx, int dy, char map [MASSLAYER][MASSSIZE][MASSSIZE], int layer, HDC FoodIMG, HDC WallIMG, HDC DoorIMG, HDC FloorIMG, HDC KnifIMG)
    {

    for (int y = 0; y < MASSSIZE; y++ )
        for (int x = 0; x < MASSSIZE; x++ )
            {
            if (map [layer][y][x] == SPACE) txBitBlt(txDC(), x0 + x * dx, y0 + y * dy, x0 + x * dx + SIZEB, y0 + y * dy + SIZEB, FloorIMG, 0, 0);
            if (map [layer][y][x] == WALL)  txBitBlt(txDC(), x0 + x * dx, y0 + y * dy, x0 + x * dx + SIZEB, y0 + y * dy + SIZEB, WallIMG, 0, 0);
            if (map [layer][y][x] == WIN)   block (x0 + x * dx, y0 + y * dy, TX_LIGHTBLUE);
			if (map [layer][y][x] == KNIFE) txBitBlt(txDC(), x0 + x * dx, y0 + y * dy, x0 + x * dx + SIZEB, y0 + y * dy + SIZEB, KnifIMG, 0, 0);
			if (map [layer][y][x] == NYAM)  txBitBlt(txDC(), x0 + x * dx, y0 + y * dy, x0 + x * dx + SIZEB, y0 + y * dy + SIZEB, FoodIMG, 0, 0);

            if (map [layer][y][x] == 'w'  ||
                map [layer][y][x] == 'v'  ||
                map [layer][y][x] == 'y'  ||
                map [layer][y][x] == 'z') txBitBlt(txDC(), x0 + x * dx, y0 + y * dy, x0 + x * dx + SIZEB, y0 + y * dy + SIZEB, FloorIMG, 0, 0);




            if (map [layer][y][x] == 'A' ||
                map [layer][y][x] == 'B' ||
                map [layer][y][x] == 'C')  txBitBlt(txDC(), x0 + x * dx, y0 + y * dy, x0 + x * dx + SIZEB, y0 + y * dy + SIZEB, DoorIMG, 0, 0);
            
            }
    }
int main ()
{
    int n = 0;

    SortingAlgorithm sortAlgArray[SORT_ALG_ARRAY_SIZE] =
    {
        SortingAlgorithm (         bubbleSort, { 12, 205,  90}, n++, Mode (0, 2)),
        SortingAlgorithm (      selectionSort, {205,  12,  90}, n++, Mode (0, 2)),
        SortingAlgorithm (      insertionSort, { 12,  90, 205}, n++, Mode (0, 2)),
        SortingAlgorithm (binaryInsertionSort, {112,  90, 155}, n++, Mode (0, 2))
    };

    Button buttonArray[BUTTON_ARRAY_SIZE] =
    {
        Button (Point (  0,   0),   0,  0, "BubbleSort"         ),
        Button (Point (  0,   0),   0,  0, "SelectionSort"      ),
        Button (Point (  0,   0),   0,  0, "InsertionSort"      ),
        Button (Point (  0,   0),   0,  0, "BinaryInsertionSort"),
        Button (Point (130, 405), 140, 30, "Now watching:"      ),
        Button (Point (  4, 367),  56, 26, "Play/Stop"          )
    };

    distributeButtons (buttonArray, BUTTON_ARRAY_SIZE, 4, Point (654, 140), Point (954, 440));

    Mode mode     = Mode(COMPS, 3),
    updateGraphic = Mode(    1, 2);

    _txWindowStyle &= ~WS_CAPTION;
    txCreateWindow (WIDTH, HEIGHT);
    txTextCursor (false);

    HDC background = txLoadImage ("sortTube.bmp");
    assert (background);

    while (!GetAsyncKeyState (VK_ESCAPE))
    {
        txBegin ();
        txBitBlt (txDC (), 0, 0, 960, 480, background);
        txClearConsole ();

        calculations (sortAlgArray, SORT_ALG_ARRAY_SIZE, buttonArray, BUTTON_ARRAY_SIZE, &mode, &updateGraphic);

        //rendering    (sortAlgArray, SORT_ALG_ARRAY_SIZE, buttonArray, BUTTON_ARRAY_SIZE,  mode);

        txEnd ();
        txSleep (1000/30);
    }

    txDeleteDC (background);

    return 0;
}
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);
    }
Beispiel #5
0
int main()
    {
    txCreateWindow(SX * 2, SY * 2);
    txTextCursor(false);
    SetWindowText(txWindow(), "Illusions");


    Illusions illus[ILLUSIONS] = {};

    HDC skins[ILLUSIONS] = {txLoadImage("WTF.bmp"),
                            txLoadImage("Cat.bmp"),
                            txLoadImage("Packman.bmp"),
                            txLoadImage("Spiral.bmp"),
                            txLoadImage("Sphere.bmp"),
                            txLoadImage("Figure.bmp"),
                            txLoadImage("DINOSOWER.bmp"),
                            txLoadImage("Packman2.bmp"),
                            txLoadImage("Cab.bmp"),
                            txLoadImage("Cab2.bmp"),
                            txLoadImage("Head.bmp"),
                            txLoadImage("6terna.bmp"),
                            txLoadImage("6terna4.bmp"),
                            txLoadImage("bike.bmp"),
                            txLoadImage("Ўарик.bmp"),
                            txLoadImage("fish.bmp"),
                            txLoadImage("kriper.bmp"),
                            txLoadImage("WTF2.bmp"),
                            txLoadImage("kub.bmp"),
                            txLoadImage("water.bmp"),
                            txLoadImage("serdce.bmp")};

    HDC transparent = txLoadImage("Transparent5.bmp");

    double x = -450, y = 25;

    for(int i = 0; i < ILLUSIONS; i++) illus[i].SetSkin(skins[i]);
    illus[0].show = true;

    while(!Key(27))
        {
        txBegin();
        txSetFillColor(TX_BLACK);
        txClear();

        for(int i = 0; i < ILLUSIONS; i++)
            {
            if(illus[i].show)
                {
                txBitBlt(txDC(), illus[i].x, illus[i].y, X_DEST * 2, Y_DEST * 2, illus[i].skin, 0, 0);
                if(Key('1'))
                    {
                    if(i > 0) illus[i].show = false, illus[i         - 1].show = true;
                    else      illus[i].show = false, illus[ILLUSIONS - 1].show = true;
                    }
                if(Key('2'))
                    {
                    if(i < ILLUSIONS - 1) illus[i].show = false, illus[i + 1].show = true;
                    else                  illus[i].show = false, illus[    0].show = true;
                    }

                while(Key('1') || Key('2')) txSleep (1);
                }
            }

        if(Key(VK_LEFT )) x -= 0.25;
        if(Key(VK_RIGHT)) x += 0.25;
        if(Key(VK_UP   )) y--;
        if(Key(VK_DOWN )) y++;

        txTransparentBlt(txDC(), x, y, X_DEST * 4, Y_DEST * 2, transparent, 0, 0, TX_WHITE);

        txEnd();
        }

    txDeleteDC(transparent);

    return 0;
    }