-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Schrodinger71/dev_fix
Add GameLife
- Loading branch information
Showing
63 changed files
with
1,205 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,13 @@ jobs: | |
- name: Build app for release | ||
run: msbuild app_WindowsForm\WindowsFormsAppCalculateLab7\WindowsFormsAppCalculateLab7.sln -t:rebuild -verbosity:diag -property:Configuration=Release | ||
|
||
|
||
build-windowsFormAppGameLife4: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup MSBuild | ||
uses: microsoft/[email protected] | ||
- name: Build solution | ||
run: msbuild app_WindowsForm\WindowsFormsGame_Life\WindowsFormsGame_Life.sln /p:Configuration=Release | ||
- name: Build app for release | ||
run: msbuild app_WindowsForm\WindowsFormsGame_Life\WindowsFormsGame_Life.sln -t:rebuild -verbosity:diag -property:Configuration=Release |
1 change: 1 addition & 0 deletions
1
app_WindowsForm/WindowsFormsGame_Life/.vs/WindowsFormsGame_Life.csproj.dtbcache.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"RootPath":"C:\\Lesson\\app_WindowsForm\\WindowsFormsGame_Life","ProjectFileName":"WindowsFormsGame_Life.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Form1.cs"},{"SourceFile":"Form1.Designer.cs"},{"SourceFile":"Program.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Deployment.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Windows.Forms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Lesson\\app_WindowsForm\\WindowsFormsGame_Life\\bin\\Debug\\WindowsFormsGame_Life.exe","OutputItemRelativePath":"WindowsFormsGame_Life.exe"},{"OutputItemFullPath":"C:\\Lesson\\app_WindowsForm\\WindowsFormsGame_Life\\bin\\Debug\\WindowsFormsGame_Life.pdb","OutputItemRelativePath":"WindowsFormsGame_Life.pdb"}],"CopyToOutputEntries":[]} |
Binary file added
BIN
+39.2 KB
...ife/.vs/WindowsFormsGame_Life/FileContentIndex/1736cc91-72b1-4876-a79d-54ea86845fc5.vsidx
Binary file not shown.
Binary file added
BIN
+14 KB
...ife/.vs/WindowsFormsGame_Life/FileContentIndex/777fa211-44d5-4f93-893f-a288adf9af12.vsidx
Binary file not shown.
Binary file added
BIN
+7.55 KB
...ife/.vs/WindowsFormsGame_Life/FileContentIndex/cba0294b-786d-419f-831f-293a928519ed.vsidx
Binary file not shown.
Binary file added
BIN
+65.5 KB
app_WindowsForm/WindowsFormsGame_Life/.vs/WindowsFormsGame_Life/v17/.suo
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> | ||
</startup> | ||
</configuration> |
231 changes: 231 additions & 0 deletions
231
app_WindowsForm/WindowsFormsGame_Life/Form1.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace WindowsFormsGame_Life | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
|
||
private Graphics graphics; | ||
private int resolution; | ||
private GameLifeEngine gameEngine; | ||
|
||
|
||
|
||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void StartGame() | ||
{ | ||
if (timer1.Enabled) | ||
return; | ||
|
||
//Text = $"Game Life Generation {currentGeneration}"; | ||
|
||
numResolution.Enabled = false; | ||
numDensity.Enabled = false; | ||
resolution = (int)numResolution.Value; | ||
|
||
|
||
gameEngine = new GameLifeEngine | ||
( | ||
rows: pictureBox1.Height / resolution, | ||
cols: pictureBox1.Width / resolution, | ||
density: (int)numDensity.Value | ||
//density: (int)(numDensity.Minimum) * (int)numDensity.Maximum - (int)numDensity.Value | ||
); | ||
|
||
|
||
|
||
|
||
textBoxGeneration.Text = $"{gameEngine.currentGeneration}"; | ||
|
||
//gameEngine.currentGeneration = 500; //пример инкапсуляции | ||
|
||
|
||
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height); | ||
graphics = Graphics.FromImage(pictureBox1.Image); | ||
timer1.Start(); | ||
|
||
//graphics.FillRectangle(Brushes.LightGreen, 0, 0, resolution, resolution); //рисует клетку | ||
|
||
|
||
} | ||
|
||
private void DrawNextGeneration() | ||
{ | ||
graphics.Clear(Color.Black); | ||
|
||
var field = gameEngine.GetCurrentGeneration(); | ||
|
||
for ( int x = 0; x < field.GetLength(0); x++ ) | ||
{ | ||
for ( int y = 0; y < field.GetLength(1); y++ ) | ||
{ | ||
if (field[x,y]) | ||
graphics.FillRectangle(Brushes.Crimson, x * resolution, y * resolution, resolution - 1, resolution - 1); | ||
|
||
} | ||
} | ||
|
||
pictureBox1.Refresh(); | ||
textBoxGeneration.Text = $"{gameEngine.currentGeneration}"; | ||
gameEngine.NextGeneration(); | ||
} | ||
|
||
|
||
|
||
private void timer1_Tick(object sender, EventArgs e) | ||
{ | ||
DrawNextGeneration(); | ||
} | ||
|
||
private void bStart_Click(object sender, EventArgs e) | ||
{ | ||
StartGame(); | ||
} | ||
|
||
private void StopGame() | ||
{ | ||
if (!timer1.Enabled) | ||
return; | ||
|
||
timer1.Stop(); | ||
numResolution.Enabled = true; | ||
numDensity.Enabled = true; | ||
} | ||
private void bStop_Click(object sender, EventArgs e) | ||
{ | ||
StopGame(); | ||
} | ||
|
||
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) | ||
{ | ||
if (!timer1.Enabled) | ||
return; | ||
|
||
if (e.Button == MouseButtons.Left) | ||
{ | ||
var x = e.Location.X / resolution; | ||
var y = e.Location.Y / resolution; | ||
gameEngine.AddCell(x, y); | ||
|
||
} | ||
|
||
if (e.Button == MouseButtons.Right) | ||
{ | ||
var x = e.Location.X / resolution; | ||
var y = e.Location.Y / resolution; | ||
gameEngine.RemoveCell(x, y); | ||
|
||
} | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.