Thread: Clicking-graphics/help-c++

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    21

    Question Clicking-graphics/help-c++

    Hiya, I am relatively new to C++ code, and I am having a hard time advancing from my current position. But there I two things I really want to learn now. that is graphics and clicking. I think clicking is gonna be the simpler of the too, so could someone explain how I could make someone click on something like this:
    [yes][no]
    That's just a simple example of what I want to know.

    Secondly I want to learn to do graphics. I have absolutely no experiance in making graphics, or even what the different types of graphics are. I under stand that there are things like openDL of whatever, but what of all that junk is best? Also could you give me a easy to understand intro to whichever, whatever is best?

    Thanks,
    Chase A.

  2. #2
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    Someone help me!

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    You're asking people to spoon-feed you information. Sorry - do some real research, just like the rest of us...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Google 3D picking.

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    Hey, I'm not asking you to spoon feed me, I been trying to figure this junk out for couple hours. Could you at least tell me a mouse script or, explain the difference between the different types of graphic tutorials they have... and then I'd take the tutorial, and you would have to 'spoon feed' me.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    1. Google 3D picking.
    2. Try it.
    3. Come here when you have a specific problem.

    You sound as if you are trying but we don't see the effort. Many people here are willing to help but you must show that you are willing to try.

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    3d picking? kk I am trying I'm just loosing my mind while i'm doing it because i've only been doing this for a few days but i've been cramming everything in...

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    2D is much simpler. A simple point in rectangle test is all you need for 2D testing. I was assuming you wanted to pick 3D objects from the screen.

    2D is as simple as getting the position of the mouse and then testing all your rectangles to see if the point is in that rectangle. If it is then you add the rectangle to your possible hit list. If more than one rectangle is in the list then you would usually select the one that was on top. How you determine this depends on whether or not you are using z order or some type of layering system to render the objects.

    A 2D point in rectangle test is:

    Code:
    ...
    bool insideRect = false;
    if (point.x >= rect.left && 
        point.y >= rect.top && 
        point.x <= rect.right && 
        point.y <= rect.bottom)
    {
       insideRect = true;
    }
    ...
    Last edited by VirtualAce; 12-10-2010 at 04:35 PM.

  9. #9
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    TYVM, 1 more question. I was working on changing the color of the text(I was SOOOOO happy when I finally figured it out)but how do I set the text back to normal?
    Heres what I was doing:
    Code:
        HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
        WORD wOldColorAttrs;
        CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
    
                          GetConsoleScreenBufferInfo(h, &csbiInfo);
                        wOldColorAttrs = csbiInfo.wAttributes;
    
        GetConsoleScreenBufferInfo(h, &csbiInfo);
        wOldColorAttrs = csbiInfo.wAttributes;
    
        SetConsoleTextAttribute ( h, FOREGROUND_BLUE | FOREGROUND_INTENSITY );

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I do not work in text mode so I have no idea.

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    MSDN is down for me right now, but going through Google cached pages suggests that you can use GetConsoleScreenBufferInfo to get the original attributes, which you can then restore later.

  12. #12
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    Thanks tabstop, but you were wrong. However, I found a game someone made that used these types of scripts and they used this script to restore the default colors:

    SetConsoleTextAttribute ( h, wOldColorAttrs);

    And it seems to work. Thanks everyone for all your help.

    Does anyone know how to change font size??? That one I can't figure out...

  13. #13
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    Hey bubba do I need a header for the mouse thing???

    whats wrong with this script?
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        cout<<"[play]";
        bool insideRect = false;
        if (point.x >= rect.left &&
            point.y >= rect.top &&
            point.x <= rect.right &&
            point.y <= rect.bottom)
    {
       insideRect = true;
            cout<<"wow it worked";
    }
    
    }
    Do I need to plug something in in place of the rect.top? A coordinate?

    THANKS AGAIN FOR ALL YOUR HELP.

  14. #14
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It was a sample. It appears you need to do some research into the language before you tackle such problems.

    Point could be a structure or a class.
    Rectangle could be a structure or a class. You can't just copy code and expect it to work b/c I did not post an entire program.

    In your code point has never been declared or defined and neither has rect. How is the compiler supposed to know what those are?

  15. #15
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by MrHoboMe View Post
    Thanks tabstop, but you were wrong. However, I found a game someone made that used these types of scripts and they used this script to restore the default colors:

    SetConsoleTextAttribute ( h, wOldColorAttrs);

    And it seems to work. Thanks everyone for all your help.

    Does anyone know how to change font size??? That one I can't figure out...
    Out of curiosity, how did they get hold of wOldColorAttrs? (MSDN is back now, but I don't want to wade through if I don't have to, if you've got a neater way of getting the attributes.)

    To change the font size, you would need to set a new font. I would imagine you can guess pretty closely what combination of set+console+font you might want to search on.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Draw rect by clicking button
    By fanta in forum C++ Programming
    Replies: 1
    Last Post: 12-23-2009, 12:58 AM
  2. PC makes clicking noise - now won't start up
    By hk_mp5kpdw in forum Tech Board
    Replies: 9
    Last Post: 09-25-2007, 11:34 PM
  3. Programmically simulate clicking on webbrowser2 object
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 06-25-2007, 01:19 PM
  4. Programmically simulate clicking on webbrowser2 object
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 06-24-2007, 10:34 PM
  5. Automatic clicking
    By gustavosserra in forum C++ Programming
    Replies: 3
    Last Post: 12-07-2004, 08:25 PM

Tags for this Thread