Source

Fat x Fast / FatxFast / gui / hud / rageframe.py

Full commit
# This file is part of FatxFast.                                                
#                                                                               
#    FatxFast is free software: you can redistribute it and/or modify           
#    it under the terms of the GNU General Public License as published by       
#    the Free Software Foundation, either version 3 of the License, or          
#    (at your option) any later version.                                        
#                                                                               
#    FatxFast is distributed in the hope that it will be useful,                
#    but WITHOUT ANY WARRANTY; without even the implied warranty of             
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
#    GNU General Public License for more details.                               
#                                                                               
#    You should have received a copy of the GNU General Public License          
#    along with FatxFast.  If not, see <http://www.gnu.org/licenses/>.          
                                                                                
# Versioning based on:                                                          
# http://en.wikipedia.org/wiki/Versioning#Designating_development_stage         
__author__ = "dryatu (c) 2013"                                                  
__version__ = "1.2.5" 

from FatxFast.gui.menuwidget import MenuWidget
from FatxFast.gui.boxwidget import BoxWidget
from FatxFast.gui.textwidget import TextWidget
from FatxFast.gui.hud.frame import Frame
from FatxFast.objects.buffs import COFFEE_BUFF_ID
from FatxFast.resource import resource_manager
import pygame

class RageFrame(Frame):
    """Creates a progression bar based on the turbo left on the supplied player.
    Base image for the progression bar has to be supplied."""
    def __init__(self, game, player, **kwargs):
        super(RageFrame, self).__init__(game, **kwargs)
        self.player = player
        self.image = resource_manager.load_image("progressbar.png")
        self._buffcount = 0

    def draw(self, surface):
        dest_rect = self.rect.copy()
        dest_rect.width *= self.player.get_turbo()
        surface.set_clip(dest_rect) 
        surface.blit(self.image, dest=dest_rect)
        surface.set_clip(None)
        if self.bgcolor:
            special_flags = 0
            if self.bgcolor[3] != 255:
                special_flags = pygame.BLEND_SUB
            surface.fill(self.bgcolor, rect=self.rect, 
                special_flags=special_flags)
        self._border.draw(surface, self.rect)