Разбить синус на несколько функций

This commit is contained in:
Nikita_pidor 2018-03-06 17:44:49 +04:00 committed by GitHub
parent 344484e9ab
commit d8952aaa56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -87,13 +87,38 @@ namespace WindowsFormsApplication1
}
private void file_beginning(string filename)
{
File.WriteAllText(filename, "");
File.AppendAllText(filename, "#include \"TXLib.h\"" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "struct Person" + Environment.NewLine);
File.AppendAllText(filename, "{" + Environment.NewLine);
File.AppendAllText(filename,"double x;" + Environment.NewLine);
File.AppendAllText(filename, "double y;" + Environment.NewLine);
File.AppendAllText(filename, "double angle;" + Environment.NewLine);
File.AppendAllText(filename, " double nomer_kadra;" + Environment.NewLine);
File.AppendAllText(filename, "HDC texture;" + Environment.NewLine);
File.AppendAllText(filename, " int MID_x;" + Environment.NewLine);
File.AppendAllText(filename, " int MID_y;" + Environment.NewLine);
File.AppendAllText(filename, " int rad;" + Environment.NewLine);
File.AppendAllText(filename, " int skorost;" + Environment.NewLine);
File.AppendAllText(filename, " int gr_dvigx;" + Environment.NewLine);
File.AppendAllText(filename, "int gr_dvigy;" + Environment.NewLine);
File.AppendAllText(filename, "int nach_dv;" + Environment.NewLine);
File.AppendAllText(filename, "int ampl_y;" + Environment.NewLine);
File.AppendAllText(filename, " int ampl_x;" + Environment.NewLine);
File.AppendAllText(filename, "double BeginTime;" + Environment.NewLine);
File.AppendAllText(filename, "double EndTime;" + Environment.NewLine);
File.AppendAllText(filename, "double Time;" + Environment.NewLine);
File.AppendAllText(filename, "};" + Environment.NewLine);
File.AppendAllText(filename, "int main()" + Environment.NewLine);
File.AppendAllText(filename, "{" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "txCreateWindow(800, 600);" + Environment.NewLine);
}
private void file_forser(string filename)
@ -120,8 +145,11 @@ namespace WindowsFormsApplication1
//filename.Replace("Вася", "Лох")
file_beginning(filename);
//file_forser(filename);
sinus(filename);
sinus_create_person(filename);
open_while(filename);
sinus3(filename);
sinus4(filename);
//sinus(filename);
file_ending(filename);
File.Copy("TXLib.h", filename.Replace(Path.GetFileName(filename), "TXLib.h"), true);
@ -136,35 +164,52 @@ namespace WindowsFormsApplication1
}
}
private void sinus(string filename)
private void sinus_create_person(string filename)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " HDC texture = txLoadImage(\"Pictures\\Personaj.bmp\");" + Environment.NewLine);
File.AppendAllText(filename, " double textureX = 50;" + Environment.NewLine);
File.AppendAllText(filename, " double textureY = 50;" + Environment.NewLine);
File.AppendAllText(filename, " double nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " while (!GetAsyncKeyState(VK_ESCAPE));" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " txSetColor(TX_RED);" + Environment.NewLine);
File.AppendAllText(filename, " txSetFillColor(TX_RED);" + Environment.NewLine);
File.AppendAllText(filename, " txRectangle(0, 0, txGetExtentX(), txGetExtentY());" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " textureX++;" + Environment.NewLine);
File.AppendAllText(filename, " textureY = 300 + 150 * sin(textureX / 10);" + Environment.NewLine);
File.AppendAllText(filename, " txTransparentBlt(txDC(), textureX, textureY, 55, 86, texture, 55 * nomer_kadra, 0, RGB(0, 255, 255));" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " nomer_kadra++;" + Environment.NewLine);
File.AppendAllText(filename, " if (nomer_kadra > 2)" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, " txSleep(10);" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, "}" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "txDeleteDC(texture);" + Environment.NewLine);
File.AppendAllText(filename, " Person per;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " per.texture = txLoadImage(\"Pictures\\Personaj.bmp\");" + Environment.NewLine);
File.AppendAllText(filename, " per.x = 50;" + Environment.NewLine);
File.AppendAllText(filename, " per.y = 50;"+ Environment.NewLine);
File.AppendAllText(filename, " per.nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " per.nach_dv = 300;" + Environment.NewLine);
File.AppendAllText(filename, " per.ampl_y = 150;" + Environment.NewLine);
File.AppendAllText(filename, " per.ampl_x = 10;" + Environment.NewLine);
}
private void open_while(string filename)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " while (!GetAsyncKeyState(VK_ESCAPE));" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " txSetColor(TX_RED);" + Environment.NewLine);
File.AppendAllText(filename, " txSetFillColor(TX_RED);" + Environment.NewLine);
File.AppendAllText(filename, " txRectangle(0, 0, txGetExtentX(), txGetExtentY());" + Environment.NewLine);
}
private void sinus3(string filename)
{
File.AppendAllText(filename, "txRectangle(0, 0, txGetExtentX(), txGetExtentY());" + Environment.NewLine);
File.AppendAllText(filename, "per.x++;" + Environment.NewLine);
File.AppendAllText(filename, " per.y = per.nach_dv + per.ampl_y * sin(per.x / per.ampl_x);" + Environment.NewLine);
File.AppendAllText(filename, " txTransparentBlt(txDC(), per.x, per.y, 55, 86, per.texture, 55 * per.nomer_kadra, 0, RGB(0, 255, 255));" + Environment.NewLine);
File.AppendAllText(filename, " per.nomer_kadra++;" + Environment.NewLine);
File.AppendAllText(filename, "if (per.nomer_kadra > 2)" + Environment.NewLine);
File.AppendAllText(filename, "{" + Environment.NewLine);
File.AppendAllText(filename, " per.nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, "}" + Environment.NewLine);
}
private void sinus4(string filename)
{
File.AppendAllText(filename, " txSleep(10);" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "txDeleteDC(per.texture);" + Environment.NewLine);
}
private void circle(string filename)
{
File.AppendAllText(filename, Environment.NewLine);