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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:02:21+00:00 2026-05-27T04:02:21+00:00

i am developing a space invader game which has a mouse_move event. it works

  • 0

i am developing a space invader game which has a mouse_move event. it works but when i move the mouse, everything slows down. the invaders and other things stop moving until you stop moving the mouse

Can someone please explain why and what can be done to resolve this.

thanx

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
    Cursor.Dispose();
    objsp.gsPos = new Point(MousePosition.X / 2 - 10, MousePosition.Y / 2 - 15);

    UpdatePosition(objsp.gsPos.X, objsp.gsPos.Y, objsp.gsImage);
}

private void UpdatePosition(int dx, int dy, Image img)
{
    Point newPos = new Point(objsp.gsPos.X + dx, objsp.gsPos.Y + dy);

    //dont go out of window boundary
    newPos.X = Math.Max(0, Math.Min(ClientSize.Width - img.Width, newPos.X));
    newPos.Y = Math.Max(0, Math.Min(ClientSize.Height - img.Height, newPos.Y));

    if (newPos != objsp.gsPos)
    {
        objsp.gsPos = newPos;
        Invalidate();
    }
}
  • 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-27T04:02:22+00:00Added an answer on May 27, 2026 at 4:02 am

    You are probably doing way too much work in your mouse_move handler. Since you don’t provide the code that’s the best advice I can offer.

    You have to be careful what you do in a handler like that. Mouse move will get fired many, many times when dragging the mouse around. You should do as little as possible in that event.

    If you post your code we can help further, but until then we don’t have enough info to give you a solid fix

    EDIT:

    Now that you’ve posted the code I see you are calling Invalidate() in every mouse move event. You are constantly repainting the entire form. That’s a lot of work to be performing that often. You need to be a bit more intelligent about what you redraw.

    Try invalidating only the region that needs to be redrawn as a first step. That should help things markedly. Invalidate() will accept a Rectangle as an argument, use that.

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

Sidebar

Related Questions

i am developing a space invader game, and i am new to this game
I am developing a space shooter game with customizable ships. You can increase the
I am developing a cocos2d based app with a space background in which I
I am developing a small appplication which is single windowed... I have formated everything
I'm developing a ASP.NET MVC application. There is little space for me to put
When developing whether its Web or Desktop at which point should a developer switch
I'm developing some sort of air mouse application for iPhone platform. This applications connects
I am developing contactus webpage which have a input field called Email. It is
I don't understand why the ABI is important context of developing user-space applications. Is
I am developing an android application In which i have a ListView with images.I

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.