Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
angle of rotation
#4
This is the code I use to get enemies shoot at the player:
self.gun_rot = (vec(self.game.player.current_ship.rect.center) - self.position).angle_to(vec(1, 0))
It should work for you after modification like:
vec = pygame.math.Vector2

angle = (vec(mouse_pos) - vec(bot_position)).angle_to(vec(1, 0))
angle will be the angle to the bot from the mouse pointer relative the to the x axis.
Reply


Messages In This Thread
angle of rotation - by berckut72 - Apr-15-2020, 10:22 AM
RE: angle of rotation - by TomToad - Apr-15-2020, 06:56 PM
RE: angle of rotation - by berckut72 - Apr-16-2020, 04:56 AM
RE: angle of rotation - by michael1789 - Apr-17-2020, 06:00 PM
RE: angle of rotation - by berckut72 - Apr-27-2020, 04:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Sprite image rotation problem XavierPlatinum 4 2,441 Jul-25-2022, 01:31 PM
Last Post: Ruslan8819
  [PyGame] Rotation Problem in PyGame thunderbird028 1 2,753 Nov-14-2019, 06:49 AM
Last Post: Windspar
  [PyGame] Converting PyGame 2 axis joystick float to 360 angle archieab 1 3,393 Sep-26-2018, 05:40 PM
Last Post: archieab
  What's the angle? microphone_head 0 1,915 Aug-13-2018, 08:38 PM
Last Post: microphone_head

Forum Jump:

User Panel Messages

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