Guest User

Untitled

a guest
Jun 15th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1.                 # this is for the bullets
  2.                     if len(bullets) < 2:
  3.                         shootsound.play()
  4.  
  5.                         start_x, start_y = playerman.x+playerman.width//2, playerman.y + playerman.height-54
  6.                         mouse_x, mouse_y = event.pos
  7.  
  8.                         dir_x, dir_y = mouse_x - start_x, mouse_y - start_y
  9.                         distance = math.sqrt(dir_x**2 + dir_y**2)
  10.                         if distance > 0:
  11.                             new_bullet = projectile(start_x, start_y, dir_x/distance, dir_y/distance, (0,0,0))
  12.                             bullets.append(new_bullet)
  13.         # this is displaying the bullets for the player            
  14.             for bullet in bullets[:]:
  15.                 bullet.move()
  16.                 if bullet.x < 0 or bullet.x > 900 or bullet.y < 0 or bullet.y > 900:
  17.                     bullets.pop(bullets.index(bullet))
Add Comment
Please, Sign In to add comment