私は C# でコンウェイのライフ ゲームを作成していますが、次世代を表示するためのパネルの更新を除いて、すべて正常に動作します。simWindow_Paint
パネルに描画してセルのグリッド線を確立し、 andを使用して「生命」を配置および破壊simWindow_MouseClick
できますが、現在は更新できません。
private void updateGame(){
int living = 0;
int dead = 0;
for(int i = 1; i < gameHeight; i++)
for (int j = 1; j < gameWidth; j++){
//set cell location and size
Rectangle cell = new Rectangle();
cell.Height = cell.Width = 9;
int X = j - 1;
int Y = i - 1;
cell.X = Convert.ToInt32(X * 10 + 1);
cell.Y = Convert.ToInt32(Y * 10 + 1);
using (Graphics g = this.simWindow.CreateGraphics()){
if (gameArray[i, j] == true){
Brush brush = new SolidBrush(Color.Red);
g.FillRectangle(brush, cell);
++living;
} else {
Brush brush = new SolidBrush(Color.White);
g.FillRectangle(brush, cell);
++dead;
}
}
}
}
私がやろうとしていることが C# で可能かどうかはわかりません。すでに Pascal でこれを行っていますが、C# が同じように機能するかどうかはわかりません...