Java-Gaming.org
Java4K winners:
[
by our judges
|
by the community
]
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members
News
: Read the
Java Gaming Resources
, or peek at
the official Java tutorials
Home
Help
Search
Login
Register
Java-Gaming.org
>
Game Development
>
Newbie & Debugging Questions
>
2 Axises 1 Degree?
Pages: [
1
]
Print
2 Axises 1 Degree?
(Read 500 times)
0 Members and 2 Guests are viewing this topic.
CyanPrime
JGO Ninja
Posts: 683
Medals: 7
2 Axises 1 Degree?
«
on:
2010-04-30 18:42:37
»
I'm using Jinput and I'm trying to learn how to use my controllers joysticks. Now each one seems to give me two axises but I don't know how to turn the axis numbers uinto a degree. Can anyone please help me?
Nate
JGO Neuromancer
Posts: 1062
Medals: 30
mooooo
Re: 2 Axises 1 Degree?
«
Reply #1 on:
2010-04-30 20:12:02
»
I believe Component#getPollData gives you a float between -1 and 1. Joysticks don't know about degrees, just percentage of maximum deflection.
FWIW, here is a class I use for an Xbox 360 controller:
http://code.google.com/p/pg3b/source/browse/trunk/Java/src/com/esotericsoftware/controller/input/JInputXboxController.java
Maybe you can make some use of it or borrow some code. Other classes in that project can access the Xbox controller through the XInput Windows API.
projects
CyanPrime
JGO Ninja
Posts: 683
Medals: 7
Re: 2 Axises 1 Degree?
«
Reply #2 on:
2010-04-30 22:46:01
»
Alright, Thanks ^_^ I think I got it: (Math.toDegrees(Math.atan2(-axisa2, axisa1)) + 180)
Games published by our own members! Go get 'em!
Markus_Persson
JGO Kernel
Posts: 2092
Medals: 10
Mojang Specifications
Re: 2 Axises 1 Degree?
«
Reply #3 on:
2010-05-01 03:43:55
»
Quote from: CyanPrime on
2010-04-30 22:46:01
Math.toDegrees(Math.atan2(-axisa2, axisa1)) + 180
is the same as
Math.toDegrees(Math.atan2(axisa2, -axisa1))
Play
Minecraft
!
JuddMan
Sr. Member
Posts: 285
Your Ad Here
Re: 2 Axises 1 Degree?
«
Reply #4 on:
2010-05-01 06:07:15
»
Also
C
2
= A
2
+ B
2
Gives you how far the stick is tilted in its current direction.
dist = sqrt(axisx * axisx) + (axisy * axisy)
See, high school math is useful in the real world...
Pages: [
1
]
Print
Jump to:
Please select a destination:
-----------------------------
Games Center
-----------------------------
=> Featured Games
=> Showcase
=> Contests
===> LWJGL16k - 2011
===> 4K Game Competition - 2012
===> JGO Comp Petite
===> Finished Contests
=====> 4K Game Competition - 2011
=====> 4K Game Competition - 2010
=====> 4K Game Competition - 2009
=====> 4K Game Competition - 2008
=====> 4K Game Competition - 2007
=====> 4K Game Competition - 2006
=====> 4K Game Competition - 2005
=====> Tiny Game 2010
=====> JGO Comp 2009
=====> 16K LWJGL Competition - 2005
=====> Java Technology Game Development Contest - 2004
-----------------------------
Discussions
-----------------------------
=> General Discussions
===> Suggestions
=> Business and Project Discussions
===> Jobs and Resumes
===> Community & Volunteer Projects
=> Miscellaneous Topics
-----------------------------
Game Development
-----------------------------
=> Newbie & Debugging Questions
=> Articles & tutorials
=> Game Play & Game Design
=> Game Mechanics
===> Artificial Intelligence
=> Networking & Multiplayer
=> Performance Tuning
=> Shared Code
-----------------------------
Java Game APIs & Engines
-----------------------------
=> Engines, Libraries and Tools
===> Java 3D
===> JInput
===> jMonkeyEngine
===> Xith3D Forums
===> Tools Discussion
=> Java 2D
===> JavaFX
=> OpenGL Development
===> JOGL Development
===> LWJGL Development
=> Java Sound & OpenAL
===> JOAL Development
=> Java on Mobile Devices
===> Android
===> J2ME
Loading...