Python Forum
[PyGame] Converting PyGame 2 axis joystick float to 360 angle
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Converting PyGame 2 axis joystick float to 360 angle
#1
I would like to convert my joystick's two axis float (horizontal and vertical) to a 360 angle that can be used to set a players direction in my game. From my research, I've found the best route to take is using Atan2.

Variables:
self.rot = 0
horaxis = joy1.get_axis(0)
veraxis = joy1.get_axis(1)
Demonstration Diagram: you are correct, it is drawn in MS Paint
[Image: 6Ugnk.png]

Absolutely any suggestions/snippets for the code would be amazing!
Reply
#2
Aha! About 2 hours after posting this, I found a solution online.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tips on Converting BASIC to Pygame robin73 4 2,392 Oct-06-2022, 08:14 AM
Last Post: Windspar
  Rasp Pi Analog Joystick mmagner2022 1 2,320 Feb-07-2022, 10:19 PM
Last Post: Larz60+
  angle of rotation berckut72 4 2,957 Apr-27-2020, 04:55 PM
Last Post: berckut72
  [PyGame] Using joystick module from PyGame archieab 6 16,112 Sep-25-2018, 06:13 PM
Last Post: archieab
  [PyGame] Joystick Input microphone_head 2 9,333 Sep-16-2018, 06:02 AM
Last Post: microphone_head
  What's the angle? microphone_head 0 1,862 Aug-13-2018, 08:38 PM
Last Post: microphone_head
  [PyGame] Limiting a Joystick value -1 to +1, to a value between 0 an 127 with 64 being center? japreja 2 4,413 Dec-10-2017, 06:20 AM
Last Post: japreja

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020