Merge pull request #8 from IngenerkaTeamCenter/Zifrkoks-patch-1

создал структуру для персонажа
This commit is contained in:
Mikhail Abramov 2018-03-03 10:30:01 +04:00 committed by GitHub
commit 6db0392cf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 160 additions and 54 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}