def __init__(self): # NOTE: Most of these hardcoded stuff is for the textures which do not scale with resolution (in-game) self.font_0 = self.tk_font(self.ElementFonts[0], 20) self.font_1 = self.tk_font(self.ElementFonts[0], 24) self.font_2 = self.tk_font(self.ElementFonts[0], 40) self.setup_timer(self.font_0) # Decorations ---- # Weapon self.olWeaponElem = self.tk_draw_rounded_rect( 64 + 8, 64 + 8, 10, (0xcc, 0x0, 0x0), 0x90, ipad=8, anchor_pos=(4, self.tk_resolution[1] - 84)) # Ammo self.olAmmoElem = self.tk_draw_rounded_rect( 128 + 8, 32 + 8, 10, (0xcc, 0x0, 0x0), 0x90, ipad=8, anchor_pos=(4, self.tk_resolution[1] - 136)) self.tk_draw_aaline(self.olAmmoElem[0], (0xff, 0x0, 0x0), (48, 8), (48, 39)) # Separation of icon and ammo count self.AmmoBar = self.tk_surface((80, 28), self.tk_srcalpha) self.AmmoBar.fill((0x80, 0x0, 0x0, 0xaa)) # Health and armor bg self.olHpArmsElem = self.tk_draw_rounded_rect( 144 + 8, 64 + 8, 10, (0xcc, 0x0, 0x0), 0x90, ipad=8, anchor_pos=(88, self.tk_resolution[1] - 84)) # Decoration for the health and armor slot (Endcaps) self.tk_draw_aaline(self.olHpArmsElem[0], (0xff, 0x0, 0x0), (44, 11), (44, 38)) # Health endcaps self.tk_draw_aaline(self.olHpArmsElem[0], (0xff, 0x0, 0x0), (146, 11), (146, 38)) self.tk_draw_aaline(self.olHpArmsElem[0], (0xff, 0x0, 0x0), (44, 43), (44, 70)) # Armor endcaps self.tk_draw_aaline(self.olHpArmsElem[0], (0xff, 0x0, 0x0), (146, 43), (146, 70)) # Health self.healthBar = self.tk_surface((96, 28), self.tk_srcalpha) self.heartBeatCycle = self.tk_cycle(self.__heartBeatGenerator()) # Generate the sin table for the heartbeat effect generator self.heartBeatTable = [ self.tk_sin(self.tk_radians(x)) for x in xrange(0, 360, 10) ] self.healthBarCriticalCycle = self.tk_cycle( self.tk_chain(xrange(0, 128, 4), xrange(128, 0, -4))) self.healthBarCritical = self.tk_surface((96, 28), self.tk_srcalpha) self.healthBarCritical.fill((0x80, 0x0, 0x0, 0xaa)) # Armor self.armorBar = self.tk_surface((96, 28), self.tk_srcalpha) self.armorBar.fill((0x80, 0x0, 0x0, 0xaa)) #self.playerDeath = self.font_2.render("You Are Dead", True, (0xff, 0x0, )) self.playerDeath = self.tk_renderText(self.font_2, "You Are Dead", True, (0xff, 0x0, 0x0), shadow=1) # Weapon slots available base_surf = self.tk_draw_rounded_rect(32, 32, 4, (0xcc, 0x0, 0x0), 0x90) bw, bh = base_surf.get_size() bw /= 2 bh /= 2 self.avai_wpn_slots = {} for key in xrange(1, len(self.tk_slots_available) + 1): # Weapon in the wheel base_copy = base_surf.copy() key_slot = self.tk_renderText(self.font_0, str(key), True, (0xff, 0x0, 0x80), shadow=1) base_copy.blit(key_slot, (bw - key_slot.get_width() / 2, bh - key_slot.get_height() / 2)) self.avai_wpn_slots[key] = base_copy # No weapon in the wheel base_copy = base_surf.copy() key_slot = self.tk_renderText(self.font_0, str(key), True, (0x80, 0x0, 0x0), shadow=1) base_copy.blit(key_slot, (bw - key_slot.get_width() / 2, bh - key_slot.get_height() / 2)) self.avai_wpn_slots[-key] = base_copy # Ui Events EventManager.__init__(self) self.Event_newEvent(1000, self.tick_timer) self.Event_newEvent(2, self.__flashGenerator)
def __init__(self): EventManager.__init__(self)