From 2559bbbd2cfb009b53d0d030dcb3a20272fa354f Mon Sep 17 00:00:00 2001 From: Zifrkoks <31888982+Zifrkoks@users.noreply.github.com> Date: Fri, 2 Mar 2018 16:04:13 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D1=83=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=B5=D1=80=D1=81=D0=BE=D0=BD=D0=B0=D0=B6=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Examples/Circle.cpp | 56 +++++++++++++----- .../Examples/Sinus.cpp | 51 ++++++++++++---- .../Examples/Sprite.cpp | 48 +++++++++++---- .../Examples/timer.cpp | 59 ++++++++++++++----- 4 files changed, 160 insertions(+), 54 deletions(-) diff --git a/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Circle.cpp b/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Circle.cpp index 1c3b102..c3120a1 100644 --- a/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Circle.cpp +++ b/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Circle.cpp @@ -1,15 +1,45 @@ #include "TXLib.h" +struct Person +{ + double x; + double y; + double angle; + double nomer_kadra; + HDC texture; + int MID_x; + int MID_y; + int rad; + int skorost; + int gr_dvigx; + int gr_dvigy; + int nach_dv; + int ampl_y; + int ampl_x; + double BeginTime; + double EndTime; + double Time; +}; + +Person per; + int main() { + + txCreateWindow(800, 600); - HDC texture = txLoadImage("Pictures\\Personaj.bmp"); + per.x = 50; + per.y = 50; + per.angle = 0; + per.nomer_kadra = 0; + per.texture = txLoadImage("Pictures\\Personaj.bmp"); + per.MID_x = 500; + per.MID_y = 300; + per.rad = 200; + per.skorost = 10; + - double textureX = 50; - double textureY = 50; - double angle = 0; - double nomer_kadra = 0; while (!GetAsyncKeyState(VK_ESCAPE)) { @@ -17,23 +47,17 @@ int main() txSetFillColor(TX_RED); txRectangle(0, 0, txGetExtentX(), txGetExtentY()); - angle++; - textureX = 500 + 200 * cos (angle / 10); - textureY = 300 + 200 * sin (angle / 10); + per.angle++; + per.x = per.MID_x + per.rad * cos (per.angle / per.skorost); + per.y = per.MID_y + per.rad * sin (per.angle / per.skorost); - txTransparentBlt(txDC(), textureX, textureY, 55, 86, texture, 55 * nomer_kadra, 0, RGB(0, 255, 255)); + txTransparentBlt(txDC(), per.x, per.y, 55, 86, per.texture, 0, 0, RGB(0, 255, 255)); - nomer_kadra++; - - if (nomer_kadra > 2) - { - nomer_kadra = 0; - } txSleep(10); } - txDeleteDC(texture); + txDeleteDC(per.texture); return 0; } diff --git a/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Sinus.cpp b/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Sinus.cpp index fd6a26b..b088b53 100644 --- a/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Sinus.cpp +++ b/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Sinus.cpp @@ -1,37 +1,64 @@ #include "TXLib.h" +struct Person +{ + double x; + double y; + double angle; + double nomer_kadra; + HDC texture; + int MID_x; + int MID_y; + int rad; + int skorost; + int gr_dvigx; + int gr_dvigy; + int nach_dv; + int ampl_y; + int ampl_x; + double BeginTime; + double EndTime; + double Time; +}; + +Person per; + + int main() { txCreateWindow(800, 600); - HDC texture = txLoadImage("Pictures\\Personaj.bmp"); + per.texture = txLoadImage("Pictures\\Personaj.bmp"); - double textureX = 50; - double textureY = 50; - double nomer_kadra = 0; + per.x = 50; + per.y = 50; + per.nomer_kadra = 0; + per.nach_dv = 300; + per.ampl_y = 150; + per.ampl_x = 10; while (!GetAsyncKeyState(VK_ESCAPE)) { txSetColor(TX_RED); txSetFillColor(TX_RED); txRectangle(0, 0, txGetExtentX(), txGetExtentY()); - - textureX++; - textureY = 300 + 150 * sin(textureX / 10); - txTransparentBlt(txDC(), textureX, textureY, 55, 86, texture, 55 * nomer_kadra, 0, RGB(0, 255, 255)); + per.x++; + per.y = per.nach_dv + per.ampl_y * sin(per.x / per.ampl_x); - nomer_kadra++; + txTransparentBlt(txDC(), per.x, per.y, 55, 86, per.texture, 55 * per.nomer_kadra, 0, RGB(0, 255, 255)); - if (nomer_kadra > 2) + per.nomer_kadra++; + + if (per.nomer_kadra > 2) { - nomer_kadra = 0; + per.nomer_kadra = 0; } txSleep(10); } - txDeleteDC(texture); + txDeleteDC(per.texture); return 0; } diff --git a/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Sprite.cpp b/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Sprite.cpp index e4f24ca..7ec83d2 100644 --- a/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Sprite.cpp +++ b/WindowsFormsApplication1/WindowsFormsApplication1/Examples/Sprite.cpp @@ -1,34 +1,60 @@ #include "TXLib.h" +struct Person +{ + double x; + double y; + double angle; + double nomer_kadra; + HDC texture; + int MID_x; + int MID_y; + int rad; + int skorost; + int gr_dvigx; + int gr_dvigy; + int nach_dv; + int ampl_y; + int ampl_x; + double BeginTime; + double EndTime; + double Time; +}; + +Person per; + + + int main() { txCreateWindow(800, 600); - HDC texture = txLoadImage("Pictures\\Personaj.bmp"); + per.texture = txLoadImage("Pictures\\Personaj.bmp"); - int textureX = 10; - int textureY = 10; - int nomer_kadra = 0; + per.x = 10; + per.y = 10; + per.nomer_kadra = 0; + per.gr_dvigx = 1000; - while (textureX < 1000) + while (per.x < per.gr_dvigx) { txSetColor(TX_RED); txSetFillColor(TX_RED); txRectangle(0, 0, txGetExtentX(), txGetExtentY()); - txTransparentBlt(txDC(), textureX, textureY, 55, 86, texture, 55 * nomer_kadra, 0, RGB(0, 255, 255)); - textureX++; - nomer_kadra++; + txTransparentBlt(txDC(), per.x, per.y, 55, 86, per.texture, 55 * per.nomer_kadra, 0, RGB(0, 255, 255)); + per.x++; + per.nomer_kadra++; - if (nomer_kadra > 2) + if (per.nomer_kadra > 2) { - nomer_kadra = 0; + per.nomer_kadra = 0; } txSleep(10); } - txDeleteDC(texture); + txDeleteDC(per.texture); return 0; } diff --git a/WindowsFormsApplication1/WindowsFormsApplication1/Examples/timer.cpp b/WindowsFormsApplication1/WindowsFormsApplication1/Examples/timer.cpp index 45772b9..b98a3c2 100644 --- a/WindowsFormsApplication1/WindowsFormsApplication1/Examples/timer.cpp +++ b/WindowsFormsApplication1/WindowsFormsApplication1/Examples/timer.cpp @@ -1,18 +1,47 @@ #include "TXLib.h" +struct Person +{ + double x; + double y; + double angle; + double nomer_kadra; + HDC texture; + int MID_x; + int MID_y; + int rad; + int skorost; + int gr_dvigx; + int gr_dvigy; + int nach_dv; + int ampl_y; + int ampl_x; + double BeginTime; + double EndTime; + double Time; +}; + +Person per; + + + int main() { txCreateWindow(800, 600); - HDC texture = txLoadImage("Personaj.bmp"); + per.texture = txLoadImage("Pictures\\Personaj.bmp"); - double textureX = 50; - double textureY = 50; - double angle = 0; - double BeginTime = 3; - double EndTime = 10; - double Time = 0; + per.x = 50; + per.y = 50; + per.angle = 0; + per.BeginTime = 3; + per.EndTime = 10; + per.Time = 0; + per.MID_x = 500; + per.MID_y = 300; + per.rad = 200; + per.skorost = 10; while (!GetAsyncKeyState(VK_ESCAPE)) { @@ -21,25 +50,25 @@ int main() txSetFillColor(TX_RED); txRectangle(0, 0, txGetExtentX(), txGetExtentY()); - if ((Time >= BeginTime) && (Time <= EndTime)) + if ((per.Time >= per.BeginTime) && (per.Time <= per.EndTime)) { - angle++; - textureX = 500 + 200 * cos (angle / 10); - textureY = 300 + 200 * sin (angle / 10); + per.angle++; + per.x = per.MID_x + per.rad * cos (per.angle / per.skorost); + per.y = per.MID_y + per.rad * sin (per.angle / per.skorost); - txTransparentBlt(txDC(), textureX, textureY, 55, 86, texture, 0, 0, RGB(0, 255, 255)); + txTransparentBlt(txDC(), per.x, per.y, 55, 86, per.texture, 0, 0, RGB(0, 255, 255)); } txSleep(100); - Time = Time + 0.1; + per.Time = per.Time + 0.1; char str[100]; - sprintf(str, "%f", Time); + sprintf(str, "%f", per.Time); txTextOut(100, 100, str); txEnd(); } - txDeleteDC(texture); + txDeleteDC(per.texture); return 0; }