Hello!
i am new in C# and i am trying to make a simple chess game
but i need to clearify some things i guess...

i understand how to add components to the Form1 with code - in my example i manage to add 8X8 squares class that inherit from picturebox and when the form is initialize its draw the squares with the pieces inside them

i made some classes that can help me in my goal - position, move, pieces etc.
and i guess it will be best to manage the game from the Program.cs (right?)

i understand i need to create instances of the classes inside program and i know how to do it.
but... i dont know how to connect the things happen in the game to the board (the 8X8 squares) that is inside the Form1...
like if i have a instance of the position class inside the program (contain 8X8 char for the pieces & which side turn etc.) and i have a methode inside the Board class that take position and place the pieces.
i know i dont need to create instance of the Board inside the program because i already has one inside Form1.
so how i can change the Board from program?

i am sorry if the question is not clear... hope u will try to understand my problem
thanks!

Recommended Answers

All 3 Replies

and i guess it will be best to manage the game from the Program.cs (right?)

Wrong, handle all your events in your form object.

thank uddanbe - u r awsome, u answer almost all of my questions so far - really appriciate this

so, i just put all the code in form1.cs
thanks again

Well, thanks. :) But because I said that you have to put some code in your forms file, does not mean you have to put ALL your code in there. Just leave Program.cs as it is and Form1 is a good way to start to put the rest of your code for the moment.
But you could have a Pawn class for instance, that could inherit from a Chesspiece class, just think about it! All the code for it would be in a Pawn.cs and Chesspiece.cs file of course :-/
Any more questions will be gladly answered by me or others here.

Succes and happy computing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.