Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
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 Coordinates  (Read 2144 times)
0 Members and 1 Guest are viewing this topic.
Offline gangrel-br

Junior Devvie




Java and Scala! Thats the game =)


« Posted 2004-05-05 01:23:30 »

Hi all, me again!  Grin

Can I get an absolute coordinate when the mouse moves, directly, or I need to calculate it with the relative coordinates that the Mouse.Ball's x and y axes give me? (At least it looks like that these axes are always returning an relative value, and I haven't found any method to change this behavior).

Thanks  Cheesy

Paulo "JCranky" Siqueira
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #1 - Posted 2004-05-05 06:40:38 »

Hi
 JInput is lower level than the mouse system in AWT/windows, a mouse by itself has no idea of pointer location on a screen as a mouse knows nothing about a screen.
 You *might* be able to do something by getting the location of the mouse with awt then tracking it, but I wouldn't like to say how portable that would be. If yoy really do want just pointer positions, use AWT (for the mouse), if you want to use use it as a controller (mouse look in quake) then jinput would be ideal. In theory you could mix the two for using the mouse in game menus and in the game itself.

HTH

Endolf

Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #2 - Posted 2004-05-05 09:45:52 »

i would suggest that if you want to avoid using AWT/Swing and you're going fullscreen with opengl or something, you might as well make your own mouse system & draw your own pointer, keep it's location in memory, and hide the OS's mouse.

if you're going windowed, use the mouse setup of whatever windowing api you are using, and if you're going fullscreen 2d with java2D, you could use either but i'd recommend swing/awt. that way the users mouse pointer works exactly the same in the game as in their OS.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #3 - Posted 2004-05-05 10:19:40 »

Hi
 for pointing at things in a menu/window system in non fullscreen mode I would agree to use AWT, otherwise use Jinput, and if using the mouse as a controller rather than a pointer I would again suggest JInput, but then I might be a little bias Wink

Endolf

Offline gangrel-br

Junior Devvie




Java and Scala! Thats the game =)


« Reply #4 - Posted 2004-05-05 13:23:13 »

Quote

for pointing at things in a menu/window system in non fullscreen mode I would agree to use AWT


Actualy I need to point things in a menu in fullscreen mode. Maybe I'll have to mix jinput / awt, but I really wanted to use jinput for all input handling...
I'm using the MVC pattern and jinput is working great in the controller layer (at least for keyboard input...)

Paulo "JCranky" Siqueira
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #5 - Posted 2004-05-06 10:29:46 »

Hi
 If you are doing it in fullscreen mode then you can just use JInput, start the mouse at the middle of the screen and then store that position and modify it when you get relative data from the mouse axis, you'll probably need the old mouse speed/ration multiplyer that all the old games used to have to control the mouse speed in the game, you might also need to take into accound the screen res, if I move the mouse 4" across my desk I still expect the same % of the screen moved wether I'm in 800x600 or 1600x1200. You will still have to disable the windows mouse pointer, otherwise you will end up with two of them, AWT is needed to do that.

HTH

Endolf

Offline TheBohemian

Junior Devvie




Java will rule them all!


« Reply #6 - Posted 2004-05-06 16:10:20 »

I wonder what the problem is: Just write your own mouse pointer. Have a look at unreal tournament and co. this approach gives you much more flexibility and you can use it the same way in fullscreen and windowed mode.

and (sorry endolf i think you're reading this a hundred times now Smiley ) in linux you can easily have multiple mouse pointers controlled by different mice.

the only thing you should now worry is how to make the 'real' mouse cursor invisible. but thats an easy one as well: just have a look at java.awt.Toolkit.createCustomCursor() and java.awt.Component.setCursor().


cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xFryIx (58 views)
2014-11-13 12:34:49

digdugdiggy (37 views)
2014-11-12 21:11:50

digdugdiggy (30 views)
2014-11-12 21:10:15

digdugdiggy (26 views)
2014-11-12 21:09:33

kovacsa (48 views)
2014-11-07 19:57:14

TehJavaDev (51 views)
2014-11-03 22:04:50

BurntPizza (51 views)
2014-11-03 18:54:52

moogie (66 views)
2014-11-03 06:22:04

CopyableCougar4 (65 views)
2014-11-01 23:36:41

DarkCart (150 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!