Merge branch 'master' of github.com:lvl2/avocados

master
Raphaël Vinot 2014-08-31 10:20:20 +02:00
commit 61ffeb267a
2 changed files with 34 additions and 2 deletions

View File

@ -80,10 +80,14 @@ class Avocado:
return self.has_been_pinned return self.has_been_pinned
def checkBoundaries(self):
if self.rect.right > self.screen_width or self.rect.left < 0:
self.vx = -self.vx
def move(self): def move(self):
if not self.has_been_pinned: if not self.has_been_pinned:
if self.rect.right > self.screen_width or self.rect.left < 0: self.checkBoundaries()
self.vx = -self.vy
if self.hasLanded(): if self.hasLanded():
self.destroy() self.destroy()

28
itext.py Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import pygame
from support.colors import *
class Text:
def __init__(self, container, text, pos, duration):
""" Foo """
self.clock = container['clock']
self.duration = duration
self.totalTime = 0
self.text = container['font'].render(text, 0 , WHITE)
self.screen = container['screen']
self.pos = pos
def blitme(self):
""" sd """
self.screen.blit(self.text, self.pos)
def hasExpired(self):
self.totalTime += self.clock.get_time()
if self.totalTime > self.duration:
del(self)
return True
return False