Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
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 1882 times)
0 Members and 1 Guest are viewing this topic.
Offline gangrel-br

Junior Member




Java and Scala! Thats the game =)


« Posted 2004-05-05 03: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
« League of Dukes »

JGO Coder


Medals: 4
Projects: 1


Current project release date: sometime in 3003


« Reply #1 - Posted 2004-05-05 08: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 Member


Medals: 1


Your Ad Here


« Reply #2 - Posted 2004-05-05 11: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!
Play the free demo of Revenge of the Titans!
Offline endolf
« League of Dukes »

JGO Coder


Medals: 4
Projects: 1


Current project release date: sometime in 3003


« Reply #3 - Posted 2004-05-05 12: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 Member




Java and Scala! Thats the game =)


« Reply #4 - Posted 2004-05-05 15: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
« League of Dukes »

JGO Coder


Medals: 4
Projects: 1


Current project release date: sometime in 3003


« Reply #5 - Posted 2004-05-06 12: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 Member




Java will rule them all!


« Reply #6 - Posted 2004-05-06 18: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.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (34 views)
2013-05-17 21:29:12

alaslipknot (42 views)
2013-05-16 21:24:48

gouessej (72 views)
2013-05-16 00:53:38

gouessej (71 views)
2013-05-16 00:17:58

theagentd (79 views)
2013-05-15 15:01:13

theagentd (74 views)
2013-05-15 15:00:54

StreetDoggy (116 views)
2013-05-14 15:56:26

kutucuk (140 views)
2013-05-12 17:10:36

kutucuk (140 views)
2013-05-12 15:36:09

UnluckyDevil (149 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.111 seconds with 22 queries.