Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def draw(self):
- #when game hasnt started
- if not gamestart:
- if framecount % 30 == 0:
- self.flapping = not self.flapping
- if self.flapping:
- self.y += 0.25
- screen.blit(get_image('/Users/nplotkin/PycharmProjects/FlappyBird/flappybird2.png'), (self.x, self.y))
- else:
- self.y -= 0.25
- screen.blit(get_image('/Users/nplotkin/PycharmProjects/FlappyBird/flappybird1.png'), (self.x, self.y))
- #When game starts
- else:
- #if velocity is not zero, reduce velocity every 10 frames
- if framecount % 10 == 0:
- if self.vel >= 0:
- self.vel -= 0.5
- else:
- self.vel *= 2
- # when velocity gets to zero or below set flapping to false
- if self.vel <= 0:
- self.flapping = False
- # add downwards velocity to y
- self.y -= self.vel
- #If flapping, blit flapping animation
- if self.flapping:
- screen.blit(get_image('/Users/nplotkin/PycharmProjects/FlappyBird/flappybird1.png'), (self.x, self.y))
- #If not flapping, blit nonflapping animation
- else:
- screen.blit(get_image('/Users/nplotkin/PycharmProjects/FlappyBird/flappybird2.png'), (self.x, self.y))
- #jump method
- def flap(self):
- #if not already flapping
- if self.flapping == False:
- #set jumping to true
- self.flapping = True
- #add jump to velocity
- self.vel =+ 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement