Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (797)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (864)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Mouse X and Y are way off.  (Read 1706 times)
0 Members and 1 Guest are viewing this topic.
Offline Jacob Pickens
« Posted 2014-12-14 23:08:09 »

Here is my code:

1  
2  
3  
4  
5  
6  
        public static Rectangle rect = new Rectangle(Mouse.getX(), Display.getHeight() - Mouse.getY() - 1, 1, 1);
   
   public static void update(Input input) {
      rect.setX(Mouse.getX());
      rect.setY(Display.getHeight() - Mouse.getY() - 1);
   }


It then says that the mouses x and y are about 500 pixels away on the X coord from the mouse cursor. Whats the whole reason for this?

Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #1 - Posted 2014-12-15 01:35:07 »

Try setting the Y to
1  
Mouse.getY()/ Display.getHeight()
instead of subtracting.
Offline CopyableCougar4
« Reply #2 - Posted 2014-12-15 01:38:31 »

Do you have your glOrtho setup to be from 0 to 1 or from 0 to the number of pixels?

Either wandering the forum or programming. Most likely the latter Smiley

Github: http://github.com/CopyableCougar4
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #3 - Posted 2014-12-15 01:51:22 »

Try setting the Y to
1  
Mouse.getY()/ Display.getHeight()
instead of subtracting.

fyi, this only works with a orthogonal projection (-1, 1, -1, 1, n, f)

OP, have you tried printing the mouse coordinates to the console? Can you show us exactly how it reacts to your mouse movement? Or what the mouse's coordinates are at the four corners of the screen would do just fine. Also, we need more information, like what libraries you're using, the window's properties (resolution & fullscreen). Stuff like that. Wink

Offline Jacob Pickens
« Reply #4 - Posted 2014-12-15 02:21:19 »

Im using slick and 0, 0 is at the upper left. And the problem is just that the x is about 500 pixels away from the mouse, CONSTANTLY! I don't understand why it is a steady 500 pixels off.

Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #5 - Posted 2014-12-15 02:26:47 »

Im using slick and 0, 0 is at the upper left. And the problem is just that the x is about 500 pixels away from the mouse, CONSTANTLY! I don't understand why it is a steady 500 pixels off.

If it's ignorant to resolution, maybe do
mouse.x = Mouse.getX() + 500;

Offline Cero
« Reply #6 - Posted 2014-12-15 05:53:05 »

sounds like you are getting the absolute screen coordinates of the mouse and not within the relative zero point of the window

Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (3664 views)
2018-11-16 13:46:03

hadezbladez (1307 views)
2018-11-16 13:41:33

hadezbladez (3672 views)
2018-11-16 13:35:35

hadezbladez (704 views)
2018-11-16 13:32:03

EgonOlsen (4014 views)
2018-06-10 19:43:48

EgonOlsen (4541 views)
2018-06-10 19:43:44

EgonOlsen (2698 views)
2018-06-10 19:43:20

DesertCoockie (3557 views)
2018-05-13 18:23:11

nelsongames (3715 views)
2018-04-24 18:15:36

nelsongames (4745 views)
2018-04-24 18:14:32
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!