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 8203079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:25:15+00:00 2026-06-07T07:25:15+00:00

First time I ever ask a question here so correct me if I´m doing

  • 0

First time I ever ask a question here so correct me if I´m doing it wrong.

Picture of my chess set:

Every time I move a piece it lags for about 1 second. Every piece and tile has an Image and there is exactly 96 Images. Every time I move a piece it clears everything with black and then update the graphics.

In the early stages of the chess I didn’t have any Images and used different colors instead and only a few pieces there was no noticeable lag and the piece moved in an instant.

        public void updateGraphics(PaintEventArgs e, Graphics g, Bitmap frame)
    {
        g = Graphics.FromImage(frame);
        g.Clear(Color.Black);


        colorMap(g);

        g.Dispose();
        e.Graphics.DrawImageUnscaled(frame, 0, 0);
    }

The function colorMap(g) looks like this:

        private void colorMap(Graphics g)
    {
        for (int y = 0; y < SomeInts.amount; y++)
        {
            for (int x = 0; x < SomeInts.amount; x++)
            {
                //Tiles
                Bundle.tile[x, y].colorBody(g, x, y);

                //Pieces
                player1.colorAll(g);
                player2.colorAll(g);
            }
        }
    }

The colorAll function executes every pieces colorBody(g) function which look like this:

        public void colorBody(Graphics g)
    {
        //base.colorBody() does the following: body = new Rectangle(x * SomeInts.size + SomeInts.size / 4, y * SomeInts.size + SomeInts.size / 4, size, size);
        base.colorBody();

        if (team == 1)
        {
            //If its a white queen
            image = Image.FromFile("textures/piece/white/queen.png");
        }
        if (team == 2)
        {
            //If its a black queen
            image = Image.FromFile("textures/piece/black/queen.png");
        }
        g.DrawImage(image, body);
    }

and finaly the function that moves the piece:

        public void movePiece(MouseEventArgs e)
    {
        for (int y = 0; y < SomeInts.amount; y++)
        {
            for (int x = 0; x < SomeInts.amount; x++)
            {
                if (Bundle.tile[x, y].body.Contains(e.Location))
                {
                    //Ignore this
                    for (int i = 0; i < queens.Count; i++)
                    {
                        Queen temp = queens.ElementAt<Queen>(i);
                        temp.move(x, y);
                    }
                    //Relevant
                    player1.move(x, y);
                    player2.move(x, y);
                }
            }
        }
    }

Thank you for reading all this! I could make a link to the whole program if my coding examples is not enough.

  • 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-06-07T07:25:16+00:00Added an answer on June 7, 2026 at 7:25 am

    You’re calling Image.FromFile in every refresh, for every image – effectively reloading every image file every time from disk.

    Have you considered loading the images once, and storing the resulting Images somewhere useful? (say, an array, Image[2,6] would be adequate)

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

Sidebar

Related Questions

Here's my two scenarios. 1 - User opens app for the first time ever
this is my first time ever posting a question and I am kind of
So I'm trying to set up GitHub for the first time ever and I
This is the first time ever I'm using AJAX, and I want to do
I'm trying to improve FxCop compliance in my code (for the first time ever),
Today is the first time I ever expose to LINQ so to say I
first time post here. I was hoping someone could help me make custom SPARQL
first time posting here so be gentle :) On my web pages I have
I am attempting at embedding multi-threading for the first time ever and running into
http://localhost:3000/genre I'm using Instant Rails, I'm introducing scaffolding for the first time ever. So

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.