[visionegg] Re: pygame.mouse.get_pos()

  • From: "Maher, Jeffrey" <jeffrey.maher@xxxxxxxxxxxxx>
  • To: <visionegg@xxxxxxxxxxxxx>
  • Date: Wed, 11 Jul 2007 12:55:16 -0500

Correct, my apologies, I did mean bottom left. 
 
What I'm confused about, is that on the screen, as I move my mouse around, the 
y values of the Position readout still starts from (0,0) in the upper left hand 
corner. The bottom left reads a value of (0,600), so basically the mathematical 
way of converting this to what I want would be the -y + 600 (so that that the 
bottom of the display reads a value of zero, and the top reads a value of 600). 
I would like the position readout to display the OpenGL coordinates as opposed 
to the pygame.mouse version.
 
I'm not having a problem with the positioning of text on the screen, in fact I 
would like the position readout to reflect the manner in which text is placed, 
so that I can go back for later reference to the specific location. 
 
Perhaps there's a problem with the conversion to OpenGL coordinates then?
 
Also, I know this is mildly off subject, but you wouldn't happen to know how to 
assign a key on the keyboard to a function such as quitting or alternating 
background color? Any key that I press other than space, esc, home, end, and 
the arrows, closes out the program.  I've managed to get the processes I want 
to happen occur with these keys, but not with any other. I know the coding for 
these functions are good, just not how to assign say the "plus" sign as a 
recognized key.
 
-Jeff

________________________________

From: visionegg-bounce@xxxxxxxxxxxxx on behalf of adam naples
Sent: Wed 7/11/2007 12:26 PM
To: visionegg@xxxxxxxxxxxxx
Subject: [visionegg] Re: pygame.mouse.get_pos()


bottom right? 
I think you might mean bottom left? 
either way, it depends on what you want to do.

 the line  
 y = screen.size[1]-y # convert to OpenGL coords
is taking the vertical position of the mouse on the screen and flipping the 
coordinates, remember opengl coordinates start in the bottom left, not the 
upper left. 

Are you trying to change the way objects are placed on the screen? 

I have a big pile of code for doing things that sounds like they are related to 
this, but I'm not sure what you want to do. 
hope I can help
-a

On Jul 10, 2007, at 12:30 PM, Maher, Jeffrey wrote:


        Hello all,
        As I have been going through the programming, I have run into a major 
stumbling block when it comes to pygame.mouse.get_pos(). 

        According to the description , pygame.mouse.get_pos()  takes the 
coordinate mapping system from the upper left hand corner of the display. Is 
there anyway to make this map out the coordinates from the bottom right hand 
corner, so that standard x-y coordinates can be applied (such as in the 
positioning of text)? 

        For reference here's how the program reads:
         just_current_pos = mouse_position
            (x,y) = pygame.mouse.get_pos()
            y = screen.size[1]-y # convert to OpenGL coords
            mouse_position = (x,y)
            if just_current_pos != mouse_position:
                last_mouse_position = just_current_pos

        My attempts at changing the coordinates mathematically (y= -y +600) 
have failed, either by having the display outside of the viewing screen, or my 
personal favorite, inverting the mouse all-together. I've tried manipulating 
the y= line as well as the mouse_position line, all to no avail.

        Any help or suggestions would be greatly appreciated.

        Thanks,
        Jeff
        ======================================
        The Vision Egg mailing list
        Archives: //www.freelists.org/archives/visionegg
        Website: http://www.visionegg.org/mailinglist.html


The information contained in this message may be privileged and confidential. 
If you are NOT the intended recipient, please notify the sender immediately 
with a copy to hipaa.security@xxxxxxxx <mailto:hipaa.security@xxxxxxxx>  and 
destroy this message.

Please be aware that email communication can be intercepted in transmission or 
misdirected. Your use of email to communicate protected health information to 
us indicates that you acknowledge and accept the possible risks associated with 
such communication. Please consider communicating any sensitive information by 
telephone, fax or mail. If you do not wish to have your information sent by 
email, please contact the sender immediately.




Other related posts: