Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1.     def draw(self):
  2.         #when game hasnt started
  3.         if not gamestart:
  4.             if framecount % 30 == 0:
  5.                 self.flapping = not self.flapping
  6.             if self.flapping:
  7.                 self.y += 0.25
  8.                 screen.blit(get_image('/Users/nplotkin/PycharmProjects/FlappyBird/flappybird2.png'), (self.x, self.y))
  9.             else:
  10.                 self.y -= 0.25
  11.                 screen.blit(get_image('/Users/nplotkin/PycharmProjects/FlappyBird/flappybird1.png'), (self.x, self.y))
  12.  
  13.         #When game starts
  14.         else:
  15.             #if velocity is not zero, reduce velocity every 10 frames
  16.             if framecount % 10 == 0:
  17.                 if self.vel >= 0:
  18.                     self.vel -= 0.5
  19.                 else:
  20.                     self.vel *= 2
  21.  
  22.  
  23.             # when velocity gets to zero or below set flapping to false
  24.             if self.vel <= 0:
  25.                 self.flapping = False
  26.  
  27.             # add downwards velocity to y
  28.             self.y -= self.vel
  29.  
  30.             #If flapping, blit flapping animation
  31.             if self.flapping:
  32.                 screen.blit(get_image('/Users/nplotkin/PycharmProjects/FlappyBird/flappybird1.png'), (self.x, self.y))
  33.             #If not flapping, blit nonflapping animation
  34.             else:
  35.                 screen.blit(get_image('/Users/nplotkin/PycharmProjects/FlappyBird/flappybird2.png'), (self.x, self.y))
  36.  
  37.     #jump method
  38.     def flap(self):
  39.         #if not already flapping
  40.         if self.flapping == False:
  41.             #set jumping to true
  42.             self.flapping = True
  43.             #add jump to velocity
  44.             self.vel =+ 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement