Advertisement
Hppavilion1

Go In Direction (not working)

Dec 24th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. def update_player_pos(self):
  2.         p = self.entities[self.pi]
  3.         direc = (p.r % 360)
  4.         if Qt.Key_W in self.pressed:
  5.             print('W')
  6.             print('sin(%s) -> %s' % (direc, sin(direc)*7))
  7.             print('-cos(%s) -> %s' % (direc, -cos(direc)*7))
  8.             p.x += sin(direc)*7
  9.             p.y -= cos(direc)*7
  10.         elif Qt.Key_S in self.pressed:
  11.             print('S')
  12.             p.x += round(sin(rad(direc)))*7
  13.             p.y += round(cos(rad(direc)))*7
  14.  
  15.         if Qt.Key_A in self.pressed:
  16.             print('A')
  17.             p.r -= 5
  18.             p.r %= 360
  19.             # p.r = abs(p.r)
  20.         elif Qt.Key_D in self.pressed:
  21.             print('D')
  22.             p.r += 5
  23.             p.r %= 360
  24.             # p.r = abs(p.r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement