Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
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 ();
    }
Ejemplo n.º 3
0
void TextOut()
    {

    int t = 0;

    while (t <= 100)
        {
        t++;

        txSetColor (TX_BLACK);
        txTextOut (470, 10+t*6, "Привет!");

        txSleep(70);
        txClear();

        }

    }
Ejemplo n.º 4
0
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 ();
    }
}
Ejemplo n.º 5
0
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);
    }
Ejemplo n.º 6
0
 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 text (const char * text, int x, int y, COLORREF color)
    {
    txSetColor (color);
    txSelectFont ("Comic Sans MS", 300, 100, 50, false, false, false, 0);
    txTextOut (x, y, text);
    }
Ejemplo n.º 8
0
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 DrawShar (int x, int y, int Diametr, COLORREF color)
    {
    txSetColor (color);
    txSetFillColor (color);
    txCircle (x, y, Diametr);
    }
Ejemplo n.º 10
0
void block (int x, int y, COLORREF color)
    {
    txSetColor (color);
    txSetFillColor (color);
    txRectangle (x, y, x+1*SIZEB, y+1*SIZEB);
    }
Ejemplo n.º 11
0
int main (int argc, char **argv)
{
if (argc != 2)
    {
    txMessageBox("Haven't file for play");
    return 1;
    }
txTextCursor (false);
txCreateWindow (1080, 720);
txSetFillColor (TX_WHITE);

const char* logf = "DATA/log.txt";
FILE* log = fopen (logf, "a");

fprintf (log, "\n\n=========hulc started=========\n");

FILE* read = fopen (argv[1], "r");

COLORREF cvet = TX_WHITE;

Stack stk = {};
double pushch = 0;

double deystvie = 0;

int cmd = 0;

int element = 0;

double proga[MAXSYMBOLINCOMMANDFILE];

fprintf (log, "\n\n\n=========hulc read and printf to array of programm do =========\n");
    for ( ; element <= MAXSYMBOLINCOMMANDFILE; element++)
        {
        txSetColor (cvet);
        txSetFillColor (cvet);
        fscanf (read, "%lg", &deystvie);
        proga[element] = deystvie;
        fprintf (log, "hulc printf to array of programm %lg\n", deystvie);
/*        switch (deystvie)
            {
            case cmdLINE:       proga[element] = cmdLINE;                                                                                   element++;              break;
            case cmdBUCKET:     proga[element] = cmdBUCKET;                                                                                 element++;              break;
            case cmdJUMP:       proga[element] = cmdJUMP;                                                                                   element++;              break;
            case cmdOUT:        proga[element] = cmdOUT;                                                                                    element++;              break;
            case cmdCOLOR:      proga[element] = cmdCOLOR;                                                                                  element++;              break;
            case cmdCIRCLE:     proga[element] = cmdCIRCLE;                                                                                 element++;              break;
            case cmdRECTANGLE:  proga[element] = cmdRECTANGLE;                                                                              element++;              break;
            case cmdTRIANGLE:   proga[element] = cmdTRIANGLE;                                                                               element++;              break;
            case cmdADD:        proga[element] = cmdADD;                                                                                    element++;              break;
            case cmdPUSH:       proga[element] = cmdPUSH; element++; fscanf (read, "%lg", &pushch); proga[element] = pushch;                element++;              break;
            case cmdPUSHR:      proga[element] = cmdPUSHR; element++; fscanf (read, "%lg", &stk.ireg); proga[element] = stk.ireg;           element++;              break;
            case cmdPOPR:       proga[element] = cmdPOPR; element++; fscanf (read, "%lg", &stk.ireg); proga[element] = stk.ireg;            element++;              break;
            case cmdSUB:        proga[element] = cmdSUB;                                                                                    element++;              break;
            case cmdMUL:        proga[element] = cmdMUL;                                                                                    element++;              break;
            case cmdDIV:        proga[element] = cmdDIV;                                                                                    element++;              break;
            case cmdEXIT:       proga[element] = cmdEXIT;                                                                                                           break;
            }*/
        }
        element++;
        proga[element] = cmdEXIT;

    fprintf (log, "\n\n======hulc end read program and he start do this is program======\n\n\n");

    deystvie = 0;
    pushch = 0;
    element = 0;
    stk.ireg = 0;
    pushch = 0;
    stk.ireg = 0;
    for (int i = 0; i <= MAXSYMBOLINCOMMANDFILE; i++)
        {
        txSetColor (cvet);
        txSetFillColor (cvet);
        cmd = proga[element];
        switch (cmd)
            {
            case cmdCOPY: copynum (&stk);                                                element++; break;
            case cmdLINE: line (&stk);                                                   element++; break;
            case cmdPUSH: element++; pushch = proga[element]; stk.push (pushch);         element++; break;
            case cmdBUCKET: clearw (&stk);                                               element++; break;
            case cmdOUT: out (&stk);                                                     element++; break;
            case cmdJUMP: jump (&stk, &element);                                                    break;
            case cmdCOLOR: color (&stk, &cvet);                                          element++; break;
            case cmdCIRCLE: circle (&stk);                                               element++; break;
            case cmdRECTANGLE: rectangle (&stk);                                         element++; break;
            case cmdTRIANGLE: triangle (&stk);                                           element++; break;
            case cmdADD: stk.Vplus ();                                                   element++; break;
            case cmdPUSHR: element++; stk.ireg = proga[element]; stk.pushr (stk.ireg);   element++; break;
            case cmdPOPR: element++; stk.ireg = proga[element]; stk.popr (stk.ireg);     element++; break;
            case cmdSUB: stk.Vminus ();                                                  element++; break;
            case cmdMUL: stk.Vumnozhity ();                                              element++; break;
            case cmdDIV: stk.Vdeleniye ();                                               element++; break;
            case cmdIN: in(&stk);                                                        element++; break;
            case cmdEXIT: fprintf (log, "\n\n ========hulc end do programm, number 0========"); return 0;
            default: txMessageBox ("ERROR Code, program end.", "hulc"); fprintf (log, "ERROR Code, number 2\n"); return 1;
            }
        fprintf (log, "hulc do %d\n", cmd);
        }
    fprintf (log, "\n\n ========hulc end do programm, number 3 (but you haven't gave me cmdEXIT(you luser:) ))========");
    return 3;
    }
Ejemplo n.º 12
0
void DrawFrame()
    {
    txSetColor (TX_WHITE);
    txSetFillColor (TX_TRANSPARENT);
    txRectangle (10, 10, 790, 590);
    }
Ejemplo n.º 13
0
void MoveShar ()
    {
    double x = 100, y = 100;
    double vx = 0, vy = 0;
    double dt = 1;
    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 v = 3;
    double Diametr = 20;
    double Heart = 5;

    while (!GetAsyncKeyState(VK_ESCAPE))
        {
        txSetColor (RGB(random (0, +255), random (0, +255), random (0, +255)));
        txSetFillColor (RGB(random (0, +255), random (0, +255), random (0, +255)));
        txCircle (x, y, Diametr);
        Prepyatstvie (Xpr, Ypr);
        Prepyatstvie (Xpr1, Ypr1);
        Prepyatstvie (Xpr2, Ypr2);
        Prepyatstvie (Xpr3, Ypr3);
        Prepyatstvie (Xpr4, Ypr4);
        Score (dt, 750, 50);
        Score (Heart, 550, 50);

        dt = dt + 0.001;
        x = x + vx * dt;
        y = y + vy * dt;

        if (x < 0)
            {
            vy = -10000;
            vx = -10000;
            txSetFillColor (TX_BLACK);
            txFloodFill (1600, 100);
            txClear ();
            text ("Game Over!", 100, 200);
            }
        if (x > 1500)
            {
            vy = 10000;
            vx = 10000;
            txSetFillColor (TX_BLACK);
            txFloodFill (1600, 100);
            txClear ();
            text ("Game Over!", 100, 200);
            }
        if (y > 800)
            {
            vy = 10000;
            vx = 10000;
            txSetFillColor (TX_BLACK);
            txFloodFill (1600, 100);
            txClear ();
            text ("Game Over!", 100, 200);
            }
        if (y < 0)
            {
            vy = -10000;
            vx = -10000;
            txSetFillColor (TX_BLACK);
            txFloodFill (1600, 100);
            txClear ();
            text ("Game Over!", 100, 200);
            }

        if (GetAsyncKeyState(VK_UP))
            {
            vx = 0;
            vy = -v;
            }
        if (GetAsyncKeyState(VK_LEFT))
            {
            vy = 0;
            vx = -v;
            }
        if (GetAsyncKeyState(VK_DOWN))
            {
            vx = 0;
            vy = v;
            }
        if (GetAsyncKeyState(VK_RIGHT))
            {
            vy = 0;
            vx = v;
            }

        if (-20 < Xpr - x and Xpr - x < 20 and -50 < Ypr - y and Ypr - y < 50)
            {
            Heart = Heart - 1;
            }
        if (-20 < Xpr3 - x and Xpr3 - x < 20 and -50 < Ypr3 - y and Ypr3 - y < 50)
            {
            Heart = Heart - 1;
            }
        if (-20 < Xpr2 - x and Xpr2 - x < 20 and -50 < Ypr2 - y and Ypr2 - y < 50)
            {
            Heart = Heart - 1;
            }
        if (-20 < Xpr1 - x and Xpr1 - x < 20 and -50 < Ypr1 - y and Ypr1 - y < 50)
            {
            Heart = Heart - 1;
            }
        if (-20 < Xpr4 - x and Xpr4 - x < 20 and -50 < Ypr4 - y and Ypr4 - y < 50)
            {
            Heart = Heart - 1;
            }

        if (GetAsyncKeyState (VK_SPACE))
            {
            txSetFillColor (TX_BLACK);
            txFloodFill (1600, 100);
            txClear ();
            }
        if (GetAsyncKeyState ('L'))
            {
            v = 1;
            }

        if (Heart < 0)
            {
            vx = 0;
            vy = 0;
            txSetFillColor (TX_BLACK);
            txFloodFill (1600, 100);
            txClear ();
            text ("Game over!", 100, 200);
            }
        if (dt > 3)
            {
            Heart = Heart + 0.002;
            }

        txSleep (2);
        }
    }
Ejemplo n.º 14
0
void text (const char * text, double x, double y, COLORREF Color, int vis, int shir)
    {
    txSetColor (Color);
    txSelectFont ("Comic Sans MS", vis, shir, 0, false, false, false, 0);
    txTextOut (x, y, text);
    }
Ejemplo n.º 15
0
    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;
        }
    }
Ejemplo n.º 16
0
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);
    }
Ejemplo n.º 17
0
int main()
    {
     _txWindowStyle &= ~ WS_CAPTION;

    txCreateWindow (XWindow, YWindow);

    int sz = 15;

    CBall  Ball [15] = {};

    Mass1 (Ball, sz);
    //double x = 0, y = 0, z = 0;
    //double vx = 0.06, vy = 0.04, vz = 0.02, dt = 1;
    while (!GetAsyncKeyState (VK_ESCAPE))
        {
        txSetFillColor (TX_WHITE);
        txBegin();
        txClear ();

        txSetColor (TX_BLUE, 5);
        Line3D ( 1,  1,  1, -1,  1,  1);
        Line3D (-1,  1, -1,  1,  1, -1);
        Line3D (-1,  1, -1, -1,  1,  1);
        Line3D ( 1,  1,  1,  1,  1, -1);

        txSetColor (TX_BROWN, 5);
        Line3D (-1, -1,  1, -1, -1, -1);
        Line3D ( 1, -1,  1, -1, -1,  1);
        Line3D ( 1, -1, -1,  1, -1,  1);
        Line3D ( 1, -1, -1, -1, -1, -1);

        txSetColor (TX_GREEN, 5);
        Line3D (-1,  1,  1, -1, -1,  1);
        Line3D (-1,  1, -1, -1, -1, -1);
        Line3D ( 1,  1, -1,  1, -1, -1);
        Line3D ( 1,  1,  1,  1, -1,  1);

        printf ("%lf, %lf,\n",ZoomZ, zGlob);

        /*txSetColor (TX_ORANGE, 5);
        Line3D (0, 3, 0,  1, 1, -1);
        Line3D (0, 3, 0, -1, 1,  1);
        Line3D (0, 3, 0, -1, 1, -1);
        Line3D (0, 3, 0,  1, 1,  1);*/
        /*
        for (int K = 0; K < sz; K++)
            {
            Dvig (&Ball [K], 1, 1, 1);
            txSetColor (RGB(random (50, 250), random (50, 250), random (50, 250))
            , 5);
            txSetFillColor (RGB(random (50, 250), random (50, 250), random (50, 250)));
            Circle3D (Ball[K].x, Ball[K].y, Ball[K].z, Ball[K].rad);
            }
        */
        /*Line3D (0, 0, 0, 10, 0, 0);
        Line3D (0, 0, 0, 0, 10, 0);
        Line3D (0, 0, 0, 0, 0, 10);*/

        Skale3D ();
        Translete3D ();
        Rotate ();
        txEnd ();
        }
    return 0;
    }