Jump to content
  • Advertisement
Sign in to follow this  
Jaqen

Need help improving the efficiency for my cursor in console...

This topic is 3530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This code runs every time there's a mouse event (this is in the console window). My problem is when doing this the cursor is really choppy in it's movement, and it's obvious why it is. It just can't keep up trying to redraw the cursor and the temp tiles every space the cursor moves. The problem is, I don't know how to go about improving this. I might have approached this whole thing the wrong way. Thanks for any help that can be given!
    if(mouse.x != mouse.tempX && mouse.y != mouse.tempY)
    {
        // Redraws the temp tile stored when the cursor went over it before.
        DrawChar(mouse.tempX, mouse.tempY, mouse.tempChar, mouse.tempAttributes);

        // Store the tile properties to redraw it when the cursor moves off it.
        mouse.tempChar = buffer[mouse.x + mouse.y * screenWidth].Char.AsciiChar;
        mouse.tempAttributes = buffer[mouse.x + mouse.y * screenWidth].Attributes;
        mouse.tempX = mouse.x;
        mouse.tempY = mouse.y;

        // Draw the cursor.
        DrawChar(mouse.x, mouse.y, mouse.icon, mouse.fgColor, mouse.bgColor);
    }



[Edited by - Jaqen on November 15, 2008 4:41:55 PM]

Share this post


Link to post
Share on other sites
Advertisement
Honestly, this code performs an insignificant amount of processing. Unless DrawChar is incredibly badly implemented, doing this every time the mouse moves should not produce any sort of "choppiness" (other, of course, than the fact that the pointer can only move from one character position to another).

Share this post


Link to post
Share on other sites
You know what? I'm an idiot. My if statement needs to be OR and not AND... that fixed it. It was only drawing the cursor if I changed coordinates on the y-axis so it looked choppy. Fixed now! Sorry to waste anyone's time.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!