Exemplo n.º 1
0
    def __init__(self, message, str=None):
        cfg = Config('chats', message)

        if (str is None):
            self.str = cfg.get('message')
        else:
            self.str = str

        self.str = self.str.replace('\\\n', '').replace('\n', '\n\n')

        self.duration = cfg.get('duration')

        self.font = FontManager.getFont(cfg.get('font'))
        self.font.setPointSize(cfg.get('font_size'))
        self.font_color = QColor.fromRgb(*cfg.get('font_color'))

        self.image = QImage(cfg.get('image_path'))

        p = cfg.get('image_pos')
        self.image_rect = QRect(0., 0., self.image.width(),
                                self.image.height())
        self.image_rect.moveCenter(QPoint(p[0], p[1]))

        self.text_rect = QRect(*cfg.get('text_rect'))

        self.has_cursor = True
        self.blink_elapsed = 0.
        self.blink_time = cfg.get('blink_time')

        self.elapsed = 0.
        self.message_sz = len(self.str)
Exemplo n.º 2
0
    def __init__(self, message, str=None):
        cfg = Config('messages', message)

        if (str is None):
            self.str = cfg.get('message')
        else:
            self.str = str

        self.duration = cfg.get('duration')
        self.fade_duration = cfg.get('fade_duration')

        self.color = QColor.fromRgb(*cfg.get('color'))
        self.alpha_final = self.color.alpha()
        self.color.setAlpha(0)

        self.font = FontManager.getFont(cfg.get('font'))
        self.font.setPointSize(cfg.get('font_size'))

        self.font_color = QColor.fromRgb(*cfg.get('font_color'))
        self.font_alpha_final = self.font_color.alpha()
        self.font_color.setAlpha(0)

        self.elapsed = 0.0
        self.state = 0
        self.tick_funcs = [
            self.tick_fade_in, self.tick_message, self.tick_fade_out
        ]
Exemplo n.º 3
0
    def __init__(self, message, str = None):
        cfg = Config('messages', message)

        if (str is None):
            self.str = cfg.get('message')
        else:
            self.str = str
        
        self.duration = cfg.get('duration')
        self.fade_duration = cfg.get('fade_duration')
        
        self.color = QColor.fromRgb(*cfg.get('color'))
        self.alpha_final = self.color.alpha()
        self.color.setAlpha(0)
        
        self.font = FontManager.getFont(cfg.get('font'))
        self.font.setPointSize(cfg.get('font_size'))
        
        self.font_color = QColor.fromRgb(*cfg.get('font_color'))
        self.font_alpha_final = self.font_color.alpha()
        self.font_color.setAlpha(0)
        
        self.elapsed = 0.0        
        self.state = 0
        self.tick_funcs = [self.tick_fade_in, self.tick_message, self.tick_fade_out]
Exemplo n.º 4
0
    def __init__(self, message, str = None):       
        cfg = Config('chats', message)

        if (str is None):
            self.str = cfg.get('message')
        else:
            self.str = str
        
        self.str = self.str.replace('\\\n', '').replace('\n','\n\n')
        
        self.duration = cfg.get('duration')
        
        self.font = FontManager.getFont(cfg.get('font'))
        self.font.setPointSize(cfg.get('font_size'))
        self.font_color = QColor.fromRgb(*cfg.get('font_color'))
        
        self.image = QImage(cfg.get('image_path'))
        
        p = cfg.get('image_pos')
        self.image_rect = QRect(0.,0.,self.image.width(),self.image.height())
        self.image_rect.moveCenter(QPoint(p[0],p[1]))
        
        self.text_rect = QRect(*cfg.get('text_rect'))
        
        self.has_cursor = True
        self.blink_elapsed = 0.
        self.blink_time = cfg.get('blink_time')

        self.elapsed = 0.
        self.message_sz = len(self.str)
Exemplo n.º 5
0
def start_pyasteroids():
    random.seed()

    import sys
    from OpenGL.GLUT import glutInit
    glutInit(sys.argv)

    app = QApplication(argv)

    # Game state
    Player()

    # Load the config files in memory
    ConfigManager()

    # Add the custom fonts to the Qt database
    FontManager()

    # Creates the window (GLWidget is created there)
    win = AsteroidsMainWindow()

    # Pop-up the window
    win.show()

    # Faster processing
    try:
        import psyco
    except:
        print 'You currently do not have the Psyco module in your PYTHONPATH.'
        print 'It is highly advisable to install it for a much better gaming performance.'
        print 'Official site: http://psyco.sourceforge.net/'

    # Gives control to Qt
    app.exec_()
Exemplo n.º 6
0
 def __init__(self, level_number, level):
     self.level_number = level_number
     
     self.info = {}
     self.fields = set()
     
     self.level = level
     self.player_state = Player.get_instance()
             
     cfg = Config('interface', 'Settings')
     font_name = cfg.get('field_font')
     font_size = cfg.get('field_font_sz')
     self.field_font = FontManager.getFont(font_name)
     self.field_font.setPointSize(font_size)
     self.field_color = QColor.fromRgb(*cfg.get('field_color'))
     
     for f_name in ConfigManager.getOptions('interface', 'Fields'):
         s = ConfigManager.getVal('interface', 'Fields', f_name)
         s = map(str.strip, s.split('||'))
         
         img = QImage('resources/images/'+s[0])
         img_pos = QPoint(*eval(s[1]))
         info_rect = QRect(*eval(s[2]))
         scale = float(s[3])
         
         if (len(s) >= 5):
             font = QFont(self.field_font)
             font.setPointSize(int(s[4]))
         else:
             font = self.field_font
         
         img_w, img_h = img.width(), img.height()
         img_rect = QRect(
             img_pos.x(), img_pos.y(),
             int(img_w*scale), int(img_h*scale)
         )
         
         self.info[f_name] = ''
         
         self.fields.add(Field(f_name, img, img_rect, info_rect, font))
     
     self.radar = Radar.from_config('E-Radar', self)
     self.missile = GuidedMissile.from_config('GuidedMissile', self)