Hi,
A question related to neat OO design of a WinForms game.
I have Game.cs and from this file I make a new instance of Board.cs (for showing the game; i.e. "Form1"). When doing the new instance I also send an array of gamepieces. On the Board, the gamepieces get represented by draggable imageboxes. Basically, the form works like a TV set, just showing what I have in my Game class.
So far so good. Now my question is: If I drag a picturebox (or do something else for that matter), how do I pass this info back to Game.cs? In a simpler game I would just pass variables back and forth using return;, but in this case nothing would happen until I move something and relase it (MouseUp event) or similar; i.e. Board.cs listens for all kinds of input from the user. Using a return statement sounds clumpsy to me.
Similarily, I wonder what the best idea is for actually creating an instance of Games in Program.cs, as yields an error:
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Game());
}
Error 1 The best overloaded method match for 'System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext)' has some invalid arguments
Error 2 Argument 1: cannot convert from 'WindowsFormsApplication1.Game' to 'System.Windows.Forms.ApplicationContext'
I am also a bit confused as I found this reply on a similar question: "Lastly, I've ALWAYS hated it when when a Form extends something other than a Form. This makes it very fragile." In other words, it seems as that person wouldn't use a class (other than the Board.cs form) for the "heart" of the game.
I'd really appreciate an answer as it's hard to search for this on Google.
Thanks!