Class Person etc

This commit is contained in:
Mikhail Abramov 2018-04-14 20:58:38 +03:00 committed by GitHub
parent 8e29c57764
commit 63fbe41a7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 156 deletions

View file

@ -9,8 +9,7 @@ namespace WindowsFormsApplication1
{ {
public class Circle public class Circle
{ {
public static void CreatePerson(string filename, string name, Person p)
public static void CreatePerson(string filename, string name)
{ {
File.AppendAllText(filename, " Person " + name + ";" + Environment.NewLine); File.AppendAllText(filename, " Person " + name + ";" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine); File.AppendAllText(filename, Environment.NewLine);
@ -23,27 +22,20 @@ namespace WindowsFormsApplication1
File.AppendAllText(filename, Environment.NewLine); File.AppendAllText(filename, Environment.NewLine);
} }
public static void circle(string filename, string name) public static void MovePerson(string filename, string name)
{ {
File.AppendAllText(filename, " angle++;" + Environment.NewLine); File.AppendAllText(filename, " " + name + ".angle++" + Environment.NewLine);
File.AppendAllText(filename, " textureX = 500 + 200 * cos (angle / 10);" + Environment.NewLine); File.AppendAllText(filename, " " + name + ".x = 500 + 200 * cos (" + name + ".angle / 10);" + Environment.NewLine);
File.AppendAllText(filename, " textureY = 300 + 200 * sin (angle / 10);" + Environment.NewLine); File.AppendAllText(filename, " " + name + ".y = 300 + 200 * sin (" + name + ".angle / 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, " txTransparentBlt(txDC(), " + name + ".x, " + name + ".x, 55, 86, " + name + ".texture, 55 * " + name + ".nomer_kadra, 0, RGB(0, 255, 255));" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine); File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " nomer_kadra++;" + Environment.NewLine); File.AppendAllText(filename, " " + name + ".nomer_kadra++;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine); File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " if (nomer_kadra > 2)" + Environment.NewLine); File.AppendAllText(filename, " if (" + name + ".nomer_kadra > 2)" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine); File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " nomer_kadra = 0;" + Environment.NewLine); File.AppendAllText(filename, " " + name + ".nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine); File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, 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, "txDeleteDC(texture);" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "return 0;" + Environment.NewLine);
File.AppendAllText(filename, "}" + Environment.NewLine);
} }
} }
} }

View file

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1 namespace WindowsFormsApplication1
{ {
@ -37,6 +38,22 @@ namespace WindowsFormsApplication1
File.AppendAllText(filename, Environment.NewLine); File.AppendAllText(filename, Environment.NewLine);
} }
public static void OpenMain(string filename, PictureBox PictureBoxBackground)
{
File.AppendAllText(filename, "int main()" + Environment.NewLine);
File.AppendAllText(filename, "{" + Environment.NewLine);
File.AppendAllText(filename, " txCreateWindow(" +
PictureBoxBackground.Image.Width.ToString() + ", " +
PictureBoxBackground.Image.Height.ToString() + ");" + Environment.NewLine);
}
public static void CloseWhile(string filename)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " txSleep(10);" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
}
public static void OpenWhile(string filename) public static void OpenWhile(string filename)
{ {
File.AppendAllText(filename, Environment.NewLine); File.AppendAllText(filename, Environment.NewLine);

View file

@ -130,7 +130,6 @@ namespace WindowsFormsApplication1
this.label1.Size = new System.Drawing.Size(259, 13); this.label1.Size = new System.Drawing.Size(259, 13);
this.label1.TabIndex = 24; this.label1.TabIndex = 24;
this.label1.Text = "number name state view delete"; this.label1.Text = "number name state view delete";
this.label1.Click += new System.EventHandler(this.label1_Click);
// //
// label13 // label13
// //
@ -158,7 +157,6 @@ namespace WindowsFormsApplication1
this.LabelBackground.Size = new System.Drawing.Size(77, 13); this.LabelBackground.Size = new System.Drawing.Size(77, 13);
this.LabelBackground.TabIndex = 11; this.LabelBackground.TabIndex = 11;
this.LabelBackground.Text = "Выбрать фон:"; this.LabelBackground.Text = "Выбрать фон:";
this.LabelBackground.Click += new System.EventHandler(this.LabelBackground_Click);
// //
// dobavitFonButton // dobavitFonButton
// //
@ -342,7 +340,6 @@ namespace WindowsFormsApplication1
this.TextBoxWall2.Name = "TextBoxWall2"; this.TextBoxWall2.Name = "TextBoxWall2";
this.TextBoxWall2.Size = new System.Drawing.Size(100, 20); this.TextBoxWall2.Size = new System.Drawing.Size(100, 20);
this.TextBoxWall2.TabIndex = 3; this.TextBoxWall2.TabIndex = 3;
this.TextBoxWall2.TextChanged += new System.EventHandler(this.TextBoxWall2_TextChanged);
this.TextBoxWall2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBoxWall1_KeyPress); this.TextBoxWall2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBoxWall1_KeyPress);
// //
// TextBoxWall1 // TextBoxWall1
@ -413,7 +410,6 @@ namespace WindowsFormsApplication1
this.Name = "MainForm"; this.Name = "MainForm";
this.RightToLeftLayout = true; this.RightToLeftLayout = true;
this.Text = "Свойства персонажа"; this.Text = "Свойства персонажа";
this.Load += new System.EventHandler(this.MainForm_Load);
this.panel1.ResumeLayout(false); this.panel1.ResumeLayout(false);
this.panel1.PerformLayout(); this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.PictureBoxBackground)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PictureBoxBackground)).EndInit();

View file

@ -11,30 +11,6 @@ namespace WindowsFormsApplication1
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
public struct Person
{
public Label l1;
public Label l2;
public Label l3;
public Button b1;
public Button b2;
public int nomer;
public String coord;
public String coord2;
//Dobavit polya
public String x1;
public String y1;
public String x2;
public String y2;
public String adress;
public String time1;
public String time2;
public String sprite;
public String moveside;
public String charname;
};
Person[] persons = new Person[200]; Person[] persons = new Person[200];
int yPersa = 300; int yPersa = 300;
@ -48,63 +24,23 @@ namespace WindowsFormsApplication1
openFileDialog1.Filter = "Kartinki|*.bmp"; openFileDialog1.Filter = "Kartinki|*.bmp";
saveFileDialog1.Filter = "cpp files|*.cpp"; saveFileDialog1.Filter = "cpp files|*.cpp";
} }
private void buttonAddCharClick(object sender, EventArgs e) private void buttonAddCharClick(object sender, EventArgs e)
{ {
panel3.Visible = true; panel3.Visible = true;
pNomer = -120; pNomer = -120;
} }
private string PersonName(int nomer) private void DeletePics(string filename, int nomer)
{
return "per" + nomer.ToString();
}
private void delete_pics2(string filename, int nomer)
{ {
File.AppendAllText(filename, Environment.NewLine); File.AppendAllText(filename, Environment.NewLine);
for (int n1 = 0; n1 < nomer; n1++) for (int n1 = 0; n1 < nomer; n1++)
{ {
File.AppendAllText(filename, " txDeleteDC(" + PersonName(n1) + ".texture);" + Environment.NewLine); File.AppendAllText(filename, " txDeleteDC(" + Person.PersonName(n1) + ".texture);" + Environment.NewLine);
} }
} }
private void open_main(string filename)
{
File.AppendAllText(filename, "int main()" + Environment.NewLine);
File.AppendAllText(filename, "{" + Environment.NewLine);
File.AppendAllText(filename, " txCreateWindow(" +
PictureBoxBackground.Image.Width.ToString() + ", " +
PictureBoxBackground.Image.Height.ToString() + ");" + 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 close_while(string filename)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " txSleep(10);" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
}
private void delete_pics(string filename)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " txDeleteDC(per.texture);" + Environment.NewLine);
}
private void SaveCharButtonClick(object sender, EventArgs e) private void SaveCharButtonClick(object sender, EventArgs e)
{ {
@ -222,21 +158,6 @@ namespace WindowsFormsApplication1
persons[pNomer].charname = charNameBox.Text; persons[pNomer].charname = charNameBox.Text;
persons[pNomer].l2.Text = charNameBox.Text; persons[pNomer].l2.Text = charNameBox.Text;
} }
private void circle_create_person(string filename, string name, Person p)
{
File.AppendAllText(filename, " Person " + name + ";" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " " + name + ".texture = txLoadImage(\"Pictures\\\\Personaj.bmp\");" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x = 50;" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y = 50;" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".angle = 0;" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
//sohranit v massiv
//proverit, chto est arr[1]
} }
private void old_place(string filename, string name, Person p) private void old_place(string filename, string name, Person p)
@ -263,22 +184,6 @@ namespace WindowsFormsApplication1
File.AppendAllText(filename, Environment.NewLine); File.AppendAllText(filename, Environment.NewLine);
} }
private void circle(string filename, string name)
{
File.AppendAllText(filename, " " + name + ".angle++" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x = 500 + 200 * cos (" + name + ".angle / 10);" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y = 300 + 200 * sin (" + name + ".angle / 10);" + Environment.NewLine);
File.AppendAllText(filename, " txTransparentBlt(txDC(), " + name + ".x, " + name + ".x, 55, 86, " + name + ".texture, 55 * " + name + ".nomer_kadra, 0, RGB(0, 255, 255));" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra++;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " if (" + name + ".nomer_kadra > 2)" + Environment.NewLine);
File.AppendAllText(filename, " {"+ Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " }"+ Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
}
private void OpenAddCharClick(object sender, EventArgs e) private void OpenAddCharClick(object sender, EventArgs e)
{ {
if (openFileDialog1.ShowDialog() == DialogResult.Cancel) if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
@ -317,7 +222,7 @@ namespace WindowsFormsApplication1
} }
Files.CreateStruct(filename); Files.CreateStruct(filename);
open_main(filename); Files.OpenMain(filename, PictureBoxBackground);
for (int nomer = 0; nomer < nomerPersa; nomer++) for (int nomer = 0; nomer < nomerPersa; nomer++)
{ {
@ -325,21 +230,19 @@ namespace WindowsFormsApplication1
if (persons[nomer].moveside == "Прямо") if (persons[nomer].moveside == "Прямо")
{ {
Sinus.CreatePerson(filename, PersonName(nomer), persons[nomer].coord); old_place(filename, Person.PersonName(nomer), persons[nomer]);
old_place(filename, PersonName(nomer));
} }
else if (persons[nomer].moveside == "Волнами") else if (persons[nomer].moveside == "Волнами")
{ {
Sinus.CreatePerson(filename, PersonName(nomer), persons[nomer].coord); Sinus.CreatePerson(filename, Person.PersonName(nomer), persons[nomer].coord);
} }
else if (persons[nomer].moveside == "Кругами") else if (persons[nomer].moveside == "Кругами")
{ {
circle_create_person(filename, PersonName(nomer), persons[nomer]); Circle.CreatePerson(filename, Person.PersonName(nomer), persons[nomer]);
} }
else if (persons[nomer].moveside == "Диагонально") else if (persons[nomer].moveside == "Диагонально")
{ {
Sinus.CreatePerson(filename, PersonName(nomer), persons[nomer].coord); old_place(filename, Person.PersonName(nomer), persons[nomer]);
old_place(filename, PersonName(nomer));
} }
} }
@ -349,24 +252,24 @@ namespace WindowsFormsApplication1
{ {
if (persons[nomer].moveside == "Прямо") if (persons[nomer].moveside == "Прямо")
{ {
go_pryamo(filename, PersonName(nomer)); go_pryamo(filename, Person.PersonName(nomer));
} }
else if (persons[nomer].moveside == "Волнами") else if (persons[nomer].moveside == "Волнами")
{ {
Sinus.MovePerson(filename, PersonName(nomer)); Sinus.MovePerson(filename, Person.PersonName(nomer));
} }
else if (persons[nomer].moveside == "Кругами") else if (persons[nomer].moveside == "Кругами")
{ {
circle(filename, PersonName(nomer)); Circle.MovePerson(filename, Person.PersonName(nomer));
} }
else if (persons[nomer].moveside == "Диагонально") else if (persons[nomer].moveside == "Диагонально")
{ {
go_pryamo(filename, PersonName(nomer)); go_pryamo(filename, Person.PersonName(nomer));
} }
} }
close_while(filename); Files.CloseWhile(filename);
delete_pics2(filename, nomerPersa); DeletePics(filename, nomerPersa);
Files.Ending(filename); Files.Ending(filename);
MessageBox.Show("Successfully"); MessageBox.Show("Successfully");
@ -396,23 +299,10 @@ namespace WindowsFormsApplication1
{ {
openSpace.Image = null; openSpace.Image = null;
} }
MessageBox.Show(persons[nomer].x1);
MessageBox.Show(persons[nomer].y1);
MessageBox.Show(persons[nomer].x2);
MessageBox.Show(persons[nomer].y2);
} }
} }
} }
private void LabelBackground_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label13_Click(object sender, EventArgs e) private void label13_Click(object sender, EventArgs e)
{ {
this.panel1.Controls.Remove(persons[nomerPersa - 1].l1); this.panel1.Controls.Remove(persons[nomerPersa - 1].l1);
@ -433,15 +323,5 @@ namespace WindowsFormsApplication1
e.Handled = true; e.Handled = true;
} }
} }
private void MainForm_Load(object sender, EventArgs e)
{
}
private void TextBoxWall2_TextChanged(object sender, EventArgs e)
{
}
} }
} }

View file

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public struct Person
{
public Label l1;
public Label l2;
public Label l3;
public Button b1;
public Button b2;
public int nomer;
public String coord;
public String coord2;
//Dobavit polya
public String x1;
public String y1;
public String x2;
public String y2;
public String adress;
public String time1;
public String time2;
public String sprite;
public String moveside;
public String charname;
public static string PersonName(int nomer)
{
return "per" + nomer.ToString();
}
}
}

View file

@ -56,6 +56,7 @@
<Compile Include="MainForm.Designer.cs"> <Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Person.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sinus.cs" /> <Compile Include="Sinus.cs" />