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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:12:27+00:00 2026-05-29T20:12:27+00:00

Other questions close to this topic don’t seem to help me understand it very

  • 0

Other questions close to this topic don’t seem to help me understand it very much. I’m just starting programming using Visual Studio and Direct2D and I’m having trouble understanding how to make two “eyes,” which are ellipses inside of ellipses, follow my mouse.

Inside of the function void MainWindow::CalculateLayout() I’m using

    const float radius3=radius/4;
    const float radius3_2=radius/5;
    const float x3=x-100;
    const float y3=y-150;
    ellipse3 = D2D1::Ellipse(D2D1::Point2F(x3, y3), radius3, radius3_2);
        //left eye

    const float radius4=radius/4;
    const float radius4_2=radius/5;
    const float x4=x+100;
    const float y4=y-150;
    ellipse4 = D2D1::Ellipse(D2D1::Point2F(x4, y4), radius4, radius4_2);
        //right eye

    const float radius5=radius/8;
    const float radius5_2=radius5/2;
    const float x5=x-100;
    const float y5=y-150;
    ellipse5 = D2D1::Ellipse(D2D1::Point2F(x5, y5), radius5, radius5_2);    
    // left eyeball

    const float radius6=radius/8;
    const float radius6_2=radius6/2;
    const float x6=x+100;
    const float y6=y-150;
    ellipse6 = D2D1::Ellipse(D2D1::Point2F(x6, y6), radius6, radius6_2);    
    // right eyeball

to set up where the eyes and eyeballs are. I think that something along the line of this should be used to control where the mouse is. I am trying to do this from a blank project, not from a form. Is the solution to simply replace const float x5=x-100 with the X value of MouseMove?

  • 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-29T20:12:28+00:00Added an answer on May 29, 2026 at 8:12 pm

    You need to replace the definition of x5, but you need to do it with a formula which will bound it to stay within the eyeball.

    Your formula will look something like this:

    // compute the angle from the eyes to the mouse
    angle = arctan( (mouseY - y) / (mouseX - x) );
    // x-100 and y-150 are assumed to be the origins (center) of the eyeball
    // eyeballRadius should be the radius of the eyeball, or slightly smaller (so the eyes do not extend outside of it)
    x5 = (x-100) + cos(angle) * eyeballRadius;
    y5 = (y-150) + sin(angle) * eyeballRadius;
    

    Hope this helps.

    To get the cross-eyed effect when the cursor is very near, you should have each eyeball compute its own angle, for example the left’s would be leftAngle = arctan( (mouseY - (y-150)) / (mouseX - (x-100)) )

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

Sidebar

Related Questions

I've found several other questions that deal with this topic, but I just can't
There are several other questions about this topic that I have gone through, but
I have read other questions on this topic but none that actually answers my
Ok, I've checked the other questions similar to this one, and none seem to
I have seen other questions on here related to this, but I have their
I've read other questions with similar titles and I think this is a different
I looked at other questions regarding this problem and tried their solutions, but it
I know this is similar to many other questions on S.O. but none of
I have checked several other questions on SO like this , this , this
I'm searched and found other questions on this but none have solved my issues.

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.