Witam. Mam taką klasę :
class Gra
{
public Gra()
{
}
public void rysuj_plansze()
{
Plansza[,] mapa = new Plansza[10, 10];
for (int i = 0; i < mapa.GetLength(0); i++)
{
for (int j = 0; j < mapa.GetLength(1); j++)
{
mapa[i, j] = new Plansza();
//mapa[i, j].Parent = this;
if (i == 0 && j == 0)
{
mapa[i, j].Location = new Point(10, 10);
}
else if (j == 0)
{
mapa[i, j].Location = new Point(mapa[i - 1, j].Location.X + mapa[i, j].Size.Width, 10);
}
else
{
mapa[i, j].Location = new Point(mapa[i, j - 1].Location.X, mapa[i, j - 1].Location.Y + mapa[i, j].Size.Height);
}
}
}
}
}
Chciałbym ją wywołać w formie głównej, ale nie działa niestety.
Po napisaniu :
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Gra gamestate = new Gra();
gamestate.rysuj_plansze();
}
}
nic się nie dzieje. Próbowałem też tak :
this.Controls.Add(gamestate.rysujplansze())
ale pojawiają się błędy :
Error 2 Argument '1': cannot convert from 'void' to 'System.Windows.Forms.Control'
Proszę o pomoc i z góry dzięki.