示例#1
0
    def render(self, s):
        s.blit(Menu.img_background, (0, 0))

        for row in self.rows:
            if row.collidepoint(core.Inputhandler.x_mouse, core.Inputhandler.y_mouse):
                color = core.Var.THEME_LIGHT
            else:
                color = core.Var.THEME_HOVER
            core.p.draw.rect(s, color, row)
            core.p.draw.line(s, core.Var.BLACK, (self.left, row.top),
                             (self.left + self.table_row_width, row.top), core.dppr(1.3))
        core.p.draw.line(s, core.Var.BLACK, (self.left, self.rows[-1].bottom),
                         (self.left + self.table_row_width, self.rows[-1].bottom), core.dppr(1.3))

        column = self.left
        core.p.draw.line(s, core.Var.BLACK, (column, self.top),
                         (column, self.top + self.number_rows * self.table_row_height), core.dppr(1.3))
        for i in range(self.number_columns):
            column = self.left + core.dppr(self.columnlens[i])
            core.p.draw.line(s, core.Var.BLACK, (column, self.top),
                             (column, self.top + self.number_rows * self.table_row_height), core.dppr(1.3))
        for i in range(len(self.data)):
            s.blit(self.data[i][0], self.data[i][1])

        for i in self.widgets:
            i.render(s)
示例#2
0
 def on_start(self):
     self.widgets = set()
     self.rows.clear()
     self.data.clear()
     self.left = core.dppr((800 - self.columnlens[-1]) / 2)
     self.top = core.dpp(40)
     self.table_row_width = core.dpp(self.columnlens[-1] + 1)
     self.table_row_height = round(core.Var.SCREEN_HEIGHT - 2 * self.top - core.widgets.Button.height)
     self.table_row_height /= self.number_rows
     self.table_row_height = round(self.table_row_height)
     menu_x, menu_y = core.Var.SCREEN_WIDTH / 2, core.Var.SCREEN_HEIGHT
     self.widgets.add(
             core.widgets.Button(core.Var.str_back[core.Var.language_id], menu_x - core.widgets.Button.width / 2,
                                 menu_y - core.widgets.Button.height - core.dpp(22), self.back))
     for i in range(self.number_rows):
         self.rows.append(core.p.Rect((self.left, self.top + i * self.table_row_height),
                                      (self.table_row_width, self.table_row_height)))
     data = [core.Var.str_scoreboard[core.Var.language_id]]
     for i in core.Var.scoreboard_data:
         data.append(i)
     item = []
     for i in data:
         for j in range(len(i)):
             item.clear()
             item.append(core.Var.font_tiny.render(i[j], True, core.Var.BLACK))
             item.append(item[0].get_rect())
             item[1].left = self.left + core.dppr(5 + self.columnlens[j])
             item[1].centery = self.rows[data.index(i)].centery
             self.data.append(item.copy())
示例#3
0
 def get_damage(self, dmg):
     self.health -= dmg
     core.Var.channel_misc2.play(core.Var.sound_hero_hit[core.randint(0, 2)])
     rng = core.dppr(10.3)
     x = self.x + core.randint(-rng, rng)
     y = self.y + core.randint(-rng, rng)
     core.Gameobj.particle_effect(core.Gameobj.img_blood, 5, True, core.dppr(35), x, y)
     if self.health < 0:
         self.health = 0
示例#4
0
 def get_damaged(self, dmg):
     if core.Var.channel_monster1.get_sound() is None:
         core.Var.channel_monster1.play(core.Var.sound_hero_hit[randint(0, 2)])
     elif core.Var.channel_monster2.get_sound() is None:
         core.Var.channel_monster2.play(core.Var.sound_hero_hit[randint(0, 2)])
     self.health -= dmg
     rng = core.dppr(10.3)
     x = self.x + randint(-rng, rng)
     y = self.y + randint(-rng, rng)
     core.Gameobj.particle_effect(core.Gameobj.img_blood, 3, True, core.dppr(35), x, y)
示例#5
0
 def render(self, s):
     s.blit(self.img_text, self.frame_text)
     core.p.draw.rect(s, self.__color_main, self.frame)
     s.blit(self.__img_value, self.__frame_value)
     if self.__blink:
         core.p.draw.line(s, core.Var.BLACK, self.__frame_value.topright, self.__frame_value.bottomright,
                          core.dppr(2))
示例#6
0
 def __init__(self, x, y, width, command, text=""):
     Widget.__init__(self, x, y, width - core.dpp(40), core.dpp(Widget.def_height), command, text)
     self.frame_text.left -= core.dpp(40)
     self.__circle_radius = core.dppr(8)
     self.__line_width = core.dppr(5)
     self.__anotherpoint = (0, 0)
     self.value = 0
     self.__color_hover = core.Var.THEME_DEFAULT
     self.__change_value = False
     self.__img_value = core.Var.font_tiny.render(": {:3d}".format(self.value), True, core.Var.BLACK)
     self.__frame_value = self.__img_value.get_rect()
     self.__frame_value_back = core.p.Rect((0, 0), (width - self.width - core.dpp(13), self.height - core.dpp(4)))
     self.__frame_value_back.midleft = self.frame.midright
     self.__frame_value_back.left += core.dpp(13)
     self.__frame1 = core.p.Rect((self.x-self.__circle_radius*2, self.y), (self.width+self.__circle_radius*4,
                                                                           self.height))
示例#7
0
 def __init__(self, x, y, width, height, text, fontsize=14):
     Widget.__init__(self, x, y, width, height, None, text)
     self.__textsurface = core.p.Surface((width, height), flags=core.p.SRCALPHA)
     font = core.p.font.SysFont("Verdana", core.dppr(fontsize))
     line_spacing = font.size("A")[1]+core.dpp(4)
     data = text.split("\\n")
     line = ""
     y = self.y
     for paragraph in data:
         wordlist = paragraph.split()
         for nr in range(len(wordlist)):
             if font.size(wordlist[nr]+line)[0] < self.width - font.size(wordlist[nr])[0]*3 and nr+1 < len(wordlist):
                 line += " "+wordlist[nr]
             else:
                 line += " "+wordlist[nr]
                 self.__textsurface.blit(font.render(line, True, core.Var.BLACK), (self.x, y))
                 y += line_spacing
                 line = ""
         y += line_spacing
示例#8
0
 def __init__(self, x, y, width, text, fontsize):
     Widget.__init__(self, x, y, width, core.dpp(fontsize), None, text)
     font = core.p.font.SysFont("Verdana", core.dppr(fontsize))
     self.img_text = font.render(text, True, core.Var.BLACK)
     self.frame_text.center = x, y
示例#9
0
    def destroy(self):
        if core.Var.channel_monster1.get_sound() is None:
            core.Var.channel_monster1.play(core.Var.sound_zombie_die[randint(0, 4)])
        else:
            core.Var.channel_monster2.play(core.Var.sound_zombie_die[randint(0, 4)])
        core.Var.monsters_killed += 1
        core.Gameobj.particle_effect(Devil.img_gore_particles, 5 - self.health // 15, False, core.dppr(25), self.x,
                                     self.y)
        core.Var.score += self.maxhealth
        rng = randint(0, 2)
        if rng == 1:
            idgun = randint(2, 5)

            def action():
                if not core.Gameobj.hero.guns[idgun]:
                    core.Gameobj.hero.guns[idgun] = True
                clipsize = core.Gameobj.guns[idgun].clip_size
                core.Gameobj.hero.ammo[core.Gameobj.guns[idgun].bullet_type] += randint(clipsize, clipsize * 3)
                core.Var.channel_misc2.play(core.Var.sound_pick)

            core.Gameobj.items.append(core.Item(self.x, self.y, core.Item.img_weaponground[idgun], action))
        core.Gameobj.monsters.remove(self)