Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084764
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:28:53+00:00 2026-05-20T18:28:53+00:00

Basically, i made a chessboard. i have 2 classes. the partial class, that triggers

  • 0

Basically, i made a chessboard.
i have 2 classes. the partial class, that triggers the events, and the logic class where the chess game code is executed (i.e. MVC model).

basically, what i am working on now is to make a reply of the game. The game ,of course, has to restart (redraw) itself.

To start , i am going to explain to you how the pictures are loaded.

Here is the algorithm when the chess is loaded.

    PictureBox[,] chessPics = new PictureBox[9, 9];// this is an array of pictureBox. each square is a picture box

    private void Chess_Load(object sender, EventArgs e)
    {        
        chessPics = Pattern();// pattern is a function that returns an array of 
        PrintPieces(codeFile.FirstTimeLoad());// this FirstTimeLoad method, goes to the chess code file an brings a new array of all the chess pieces (each chess piece is an object).        
    }


        public PictureBox[ , ] Pattern()
    {
        chessPics[1, 1] = a1;// each letter and number is an event that triggers the picture.
        chessPics[1, 2] = b1;
        chessPics[1, 3] = c1;
        chessPics[1, 4] = d1;
        chessPics[1, 5] = e1;
        chessPics[1, 6] = f1;
        chessPics[1, 7] = g1;
        chessPics[1, 8] = h1;
        chessPics[2, 1] = a2;
        chessPics[2, 2] = b2;
        chessPics[2, 3] = c2;
        chessPics[2, 4] = d2;
        chessPics[2, 5] = e2;
        chessPics[2, 6] = f2;
        chessPics[2, 7] = g2;
        chessPics[2, 8] = h2;
        chessPics[3, 1] = a3;
        chessPics[3, 2] = b3;
        chessPics[3, 3] = c3;
        chessPics[3, 4] = d3;
        chessPics[3, 5] = e3;
        chessPics[3, 6] = f3;
        chessPics[3, 7] = g3;
        chessPics[3, 8] = h3;
        chessPics[4, 1] = a4;
        chessPics[4, 2] = b4;
        chessPics[4, 3] = c4;
        chessPics[4, 4] = d4;
        chessPics[4, 5] = e4;
        chessPics[4, 6] = f4;
        chessPics[4, 7] = g4;
        chessPics[4, 8] = h44;
        chessPics[5, 1] = a5;
        chessPics[5, 2] = b5;
        chessPics[5, 3] = c5;
        chessPics[5, 4] = d5;
        chessPics[5, 5] = e5;
        chessPics[5, 6] = f5;
        chessPics[5, 7] = g5;
        chessPics[5, 8] = h5;
        chessPics[6, 1] = a6;
        chessPics[6, 2] = b6;
        chessPics[6, 3] = c6;
        chessPics[6, 4] = d6;
        chessPics[6, 5] = e6;
        chessPics[6, 6] = f6;
        chessPics[6, 7] = g6;
        chessPics[6, 8] = h6;
        chessPics[7, 1] = a7;
        chessPics[7, 2] = b7;
        chessPics[7, 3] = c7;
        chessPics[7, 4] = d7;
        chessPics[7, 5] = e7;
        chessPics[7, 6] = f7;
        chessPics[7, 7] = g7;
        chessPics[7, 8] = h7;
        chessPics[8, 1] = a8;
        chessPics[8, 2] = b8;
        chessPics[8, 3] = c8;
        chessPics[8, 4] = d8;
        chessPics[8, 5] = e8;
        chessPics[8, 6] = f8;
        chessPics[8, 7] = g8;
        chessPics[8, 8] = h8;

        return chessPics;

    }

The method that prints each picture on a picture box:

        public  void PrintPieces(Pieces [,] pieces)
    {      
        for (int i = 1; i < 9; i++)
        {             
            for (int j = 1; j < 9; j++)
            {
                if (pieces[i, j] is Object)
                {
                   chessPics[i, j].Load(pieces[i, j].print());    // in the pieces object there are objects with a print method which specifies from which location to load the pictures             
                }
                else
                {
                    chessPics[i, j].Image = null;
                }
            }             
        }
    }

what i fail to do , is in the middle or end of the game to reset everything to the begining.
i tried to create new objects and new methods that will replicate the algorithm that i did when in the load function form, but nothing worked.

is there any solution?


here is my Class2:

   public class Class2
 {
    public static bool MATE;
    Pieces[,] pieces;
    Pieces[,] piece;

i created a new object

        Class2 codeFileReplay = new Class2();

and even assigned a method to reset and retreat a new array:

     public void resetBoard()
    {
        piece = null;
        pieces = null;
    }

i activated that method , and did the whole process again, of sending a new array of the new object to the method that prints the board

        public static Pieces[,] ChessBoardDisplay()
    {
        Pieces[,] piece2 = new Pieces[9, 9];

        piece2[8, 1] = new Rook("WR");
        piece2[8, 2] = new Knight("WKN");
        piece2[8, 3] = new Bishop("WB");
        piece2[8, 5] = new Queen("WQ");
        piece2[8, 4] = new King("WK");
        piece2[8, 6] = new Bishop("WB");
        piece2[8, 7] = new Knight("WKN");
        piece2[8, 8] = new Rook("WR");


        piece2[7, 1] = new Pawn("WP");
        piece2[7, 2] = new Pawn("WP");
        piece2[7, 3] = new Pawn("WP");
        piece2[7, 4] = new Pawn("WP");
        piece2[7, 5] = new Pawn("WP");
        piece2[7, 6] = new Pawn("WP");
        piece2[7, 7] = new Pawn("WP");
        piece2[7, 8] = new Pawn("WP");

        piece2[1, 1] = new Rook("BR");
        piece2[1, 2] = new Knight("BKN");
        piece2[1, 3] = new Bishop("BB");
        piece2[1, 5] = new Queen("BQ");
        piece2[1, 4] = new King("BK");
        piece2[1, 6] = new Bishop("BB");
        piece2[1, 7] = new Knight("BKN");
        piece2[1, 8] = new Rook("BR");

        piece2[2, 1] = new Pawn("BP");
        piece2[2, 2] = new Pawn("BP");
        piece2[2, 3] = new Pawn("BP");
        piece2[2, 4] = new Pawn("BP");
        piece2[2, 5] = new Pawn("BP");
        piece2[2, 6] = new Pawn("BP");
        piece2[2, 7] = new Pawn("BP");
        piece2[2, 8] = new Pawn("BP");

        return piece2;
    }  

     public Pieces[,] FirstTimeLoad()
    {
        pieces = ChessBoardDisplay();
        piece = ChessBoardDisplay();
        return pieces;
    }

i activated teh FirstTimeLoad in the partial class:

PrintPiecesReplay(codeFileReplay.FirstTimeLoad());
        PictureBox[,] chessPictures = new PictureBox[9, 9];
    public void PrintPiecesReplay(Pieces[,] pieces)
    {
        for (int i = 1; i < 9; i++)
        {
            for (int j = 1; j < 9; j++)
            {
                if (pieces[i, j] is Object)
                {
                    chessPictures[i, j].Load(pieces[i, j].print());
                }
                else
                {
                    chessPictures[i, j].Image = null;
                }
            }
        }
    }

Basically, i did the whole process from the beginning with a new object of the class code (Class2). wont redraw the board

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:28:54+00:00Added an answer on May 20, 2026 at 6:28 pm

    According to PrintPieces, it’s the pieces array you need to worry about resetting, not the chessPics array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the confusing title. Basically I made a BinaryReader class that reads in
I have made CAlayer that contains an image. What i basically want to do
I have just made my first proper little desktop GUI application that basically wraps
hi i'm using a script made by http://snook.ca/archives/javascript/simplest-jquery-slideshow so basically the code i have
So, I have this nice little view that I've made, which basically shows two
I have a PHP file i made that basically give me passwords to all
So I have basically started documenting a class library I made, this is the
I am new to ZF.i have made a function that basically make a Form
I'm developing a game that basically has its entire terrain made out of AABB
I'm making a 3D game with OpenGL that basically has a world made entirely

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.