Example #1
0
 def __init__(self, left_top=(0, 0), digit_color=Color.RED):
     super().__init__()
     self.time = 0
     self.prv_time = 0
     self.padding = 4
     self.is_running = False
     self.font_style = self.get_style('digit_text')
     self.seperator_txt = go.RenderText(':', self.font_style)
     self.seconds_txt = go.RenderText(self.display_format(0),
                                      self.font_style)
     self.minutes_txt = go.RenderText(self.display_format(0),
                                      self.font_style)
     self.hours_txt = go.RenderText(self.display_format(0), self.font_style)
     self.box = go.BorderedRect(left_top, (0, 0))
     self.set_size(self.get_clock_size())
     self.set_position(left_top)
Example #2
0
 def __init__(self,
              digits,
              can_grow=False,
              limit=100,
              left_top=(0, 0),
              color=Color.BLACK,
              digit_color=Color.RED):
     self.color = color
     self.digit_color = digit_color
     self.limit = limit
     self.can_grow = can_grow
     self.digits = digits
     self.post_update = False
     self.div = 10 * int('{}{}'.format(
         1, ''.join(['0' for i in range(self.digits - 1)])))
     self.counter = 0
     self.padding = 4
     self.is_visible = True
     self.box = go.Rect(left_top, (0, 0), color=color)
     self.font_info = go.FontInfo(font_size=30, font_color=digit_color)
     self.display_text = go.RenderText(self.get_display_str(),
                                       font_info=self.font_info)
     super().__init__(left_top,
                      default_size=tuple(x + self.padding
                                         for x in self.display_text.size))
Example #3
0
 def creat_suit_emblem(self):
     for suit in SUITS:
         font_info = go.FontInfo(font_size=self.font_size,
                                 font_color=SUIT_TO_COLOR[suit],
                                 font_name=Card.SUIT_FONT)
         self.foundation_suit_texts.append(
             go.RenderText(SUIT_TO_CHAR[suit], font_info=font_info))
Example #4
0
 def __init__(self, *args, **kargs):
     self.foundation_suit_texts = []
     super().__init__(*args, **kargs)
     self.first_card = None
     self.font_size = 30
     font_info = go.FontInfo(font_size=self.font_size,
                             font_name=Card.SUIT_FONT,
                             font_color=Color.BLACK)
     self.card_value_text_top = go.RenderText('',
                                              is_visible=False,
                                              font_info=font_info)
     self.card_value_text_bottom = go.RenderText('',
                                                 is_visible=False,
                                                 font_info=font_info)
     self.creat_suit_emblem()
     self.wire_events()
Example #5
0
 def __init__(self,
              left_top=(0, 0),
              color=Color.BLACK,
              digit_color=Color.RED):
     self.color = color
     self.digit_color = digit_color
     self.is_visible = True
     self.time = 0
     self.prv_time = 0
     self.padding = 4
     self.is_running = False
     self.font_info = go.FontInfo(font_size=20, font_color=digit_color)
     self.seperator_txt = go.RenderText(':', self.font_info)
     self.seconds_txt = go.RenderText(self.display_format(0),
                                      self.font_info)
     self.minutes_txt = go.RenderText(self.display_format(0),
                                      self.font_info)
     self.hours_txt = go.RenderText(self.display_format(0), self.font_info)
     self.box = go.Rect(left_top, (0, 0), color=color)
     super().__init__(left_top, default_size=self.get_clock_size())
Example #6
0
 def __init__(self, lbl_str, on_checked=None, left_top=(0, 0)):
     super().__init__()
     self.is_active = False
     self.is_checked = False
     self.on_checked = on_checked
     self.font_style = self.get_style('default_text')
     self.lbl_text = go.RenderText(lbl_str, self.font_style)
     self.check_box = go.BorderedRect(left_top, (10, 10))
     self.fill_box = go.Rect(left_top, (10, 10))
     self.set_size(tuple(x + 10 for x in self.lbl_text.size))
     self.set_position(left_top)
     self.wire_events()
Example #7
0
 def __init__(self, left_top, size, index, is_visible=True, border=2):
     self.cards = []
     self.index = index
     self.border = border
     self.rect = go.Rect(left_top,
                         size,
                         width=self.border,
                         color=Color.BLACK,
                         is_visible=is_visible)
     self.text = go.RenderText(str(self.index))
     self.set_size(size)
     self.set_position(left_top)
Example #8
0
 def __init__(self, digits, can_grow=False, limit=100, left_top=(0, 0)):
     super().__init__()
     self.limit = limit
     self.can_grow = can_grow
     self.digits = digits
     self.post_update = False
     self.div = 10 * int('{}{}'.format(
         1, ''.join(['0' for i in range(self.digits - 1)])))
     self.counter = 0
     self.padding = 10
     self.box = go.BorderedRect(left_top, (0, 0))
     self.font_style = self.get_style('digit_text')
     self.display_text = go.RenderText(self.get_display_str(),
                                       font_style=self.font_style)
     self.set_size(tuple(x + self.padding for x in self.display_text.size))
     self.set_position(left_top)
Example #9
0
 def __init__(self,
              btn_str,
              on_click=None,
              left_top=(0, 0),
              color=Color.ALICE_BLUE,
              active_color=Color.RED):
     self.color = color
     self.is_active = False
     self.is_enabled = True
     self.is_visible = True
     self.on_click = on_click
     self.active_color = active_color
     self.btn_font = go.FontInfo(font_size=10, font_color=Color.BLACK)
     self.btn_text = go.RenderText(btn_str, self.btn_font)
     self.rect = go.Rect(left_top, (0, 0), color=self.color)
     super().__init__(left_top, default_size=self.btn_text.size)
     self.wire_events()
Example #10
0
 def __init__(self,
              text,
              on_click=None,
              left_top=(0, 0),
              min_size=(0, 0),
              is_visible=True,
              is_enabled=True):
     super().__init__(left_top,
                      is_enabled=is_enabled,
                      is_visible=is_visible)
     self.is_active = False
     self.on_click = on_click
     self.min_w, self.min_h = self.min_size = min_size
     self.font_style = self.get_text_style()
     self.btn_txt = go.RenderText(text, self.font_style)
     self.btn_bck = go.BorderedRect((0, 0), (0, 0))
     self.set_size(self.get_size())
     self.set_position(self.left_top)
     self.wire_events()
Example #11
0
 def __init__(self):
     pygame.init()
     self.w, self.h = self.size = imp.IMP().screen.size
     self.elapsed = 1
     self.is_win = False
     self.previous = None
     self.is_paused = True
     self.SEC_PER_FRAME = 1 / 60
     self.center = tuple(x // 2 for x in self.size)
     self.title = imp.IMP().config.try_get('GAME_NAME', 'Default Name')
     self.card_table = cards.CardTable(
         (0, 0),
         self.size,
         margins=imp.IMP().config.try_get('CARD_TABLE_MARGINS', (0, 0)))
     self.pause_text = go.RenderText('Paused!',
                                     font_info=go.FontInfo(60, Color.BLUE),
                                     is_visible=False)
     self.pause_text.center_on(self.center)
     self.create_side_bars()
     self.wire_events()
     self.set_title()
Example #12
0
 def __init__(self,
              lbl_str,
              left_top=(0, 0),
              on_checked=None,
              is_checked=False,
              color=Color.BLACK,
              checked_color=Color.BLACK):
     self.is_checked = is_checked
     self.color = color
     self.checked_color = checked_color
     self.is_active = False
     self.is_enabled = True
     self.is_visible = True
     self.on_checked = on_checked
     self.font_info = go.FontInfo(font_size=10, font_color=Color.BLACK)
     self.lbl_text = go.RenderText(lbl_str, self.font_info)
     self.check_box = go.Rect(left_top, (10, 10), color=color, width=1)
     self.fill_box = go.Rect(left_top, (10, 10), color=checked_color)
     super().__init__(left_top,
                      default_size=tuple(x + 10
                                         for x in self.lbl_text.size))
     self.wire_events()
Example #13
0
 def __init__(self,
              title,
              left_top,
              size,
              color=Color.LIGHT_GREY,
              header_color=Color.DEEP_SKY_BLUE):
     super().__init__()
     self.title = title
     self.dragging = False
     self.mouse_pos = (0, 0)
     self.controls = []
     self.fixed_positions = []
     self.title_height = 20
     self.window_border = go.Rect(left_top,
                                  tuple(x + 2 for x in size),
                                  width=1)
     self.window = go.Rect(left_top, size)
     self.lbl_text = go.RenderText(self.title,
                                   self.get_style('default_text'))
     self.header = go.Rect(left_top, size)
     self.line = go.HorizontalLine((0, 0), 0)
     self.set_size(size)
     self.set_position(left_top)
     self.wire_events()
Example #14
0
 def __init__(self, *args, **kargs):
     self.remaining_text = go.RenderText('')
     self.card_back = pygame.image.load('{0}/{1}'.format(
         Card.SOURCE_FOLDER, Card.CARD_BACK_IMAGE_FILE)).convert()
     super().__init__(*args, **kargs)
Example #15
0
	def __init__(self, name, text_str='', center=(0,0), velocity=(0, 0), color=color.WHITE, render_order=0):
		object = go.RenderText(self, text_str, go.FontInfo('lucidaconsole', 20, color), velocity)
		go.GameObject.__init__(self, name, center, object.get_bounds(), [object], velocity, render_order)
Example #16
0
	def add_hud_text(self, game_object):
		text_str = self.format_numbers(game_object.id, *game_object.velocity)
		hud_text = go.RenderText(self, text_str, self.font_info, (0, 0))
		self.add_object(hud_text)
		self.map_id_to_object[game_object.id] = hud_text 
		self.total_height += hud_text.get_bounds()[Bound.HEIGHT]