From 633be6c6c07677b208afd9ed612f1ca785ad9621 Mon Sep 17 00:00:00 2001 From: David Raison Date: Sun, 31 Aug 2014 10:20:12 +0200 Subject: [PATCH] Added missing fileg --- avocado.py | 8 ++++++-- itext.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 itext.py diff --git a/avocado.py b/avocado.py index 61b1931..99600f7 100644 --- a/avocado.py +++ b/avocado.py @@ -80,10 +80,14 @@ class Avocado: 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): if not self.has_been_pinned: - if self.rect.right > self.screen_width or self.rect.left < 0: - self.vx = -self.vy + self.checkBoundaries() if self.hasLanded(): self.destroy() diff --git a/itext.py b/itext.py new file mode 100644 index 0000000..eeb9b06 --- /dev/null +++ b/itext.py @@ -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