Exemplo n.º 1
0
 def _init(self):
     Animation._init(self)
     dot_length = self._parameters["dot_size"].get_value() * self._oversampling
     dot = np.interp(np.linspace(0, 2, dot_length), [0, 1, 2], [0, 1, 0])
     red, green, blue = self._parameters["color"].get_value()
     point = np.array([dot * red, dot * green, dot * blue], dtype=int)
     self._pixel_data[:, 0:dot_length] = point
Exemplo n.º 2
0
    def __init__(self, caster):
        tenpercent = caster.max_health / 10
        num = 0
        while tenpercent < caster.max_health:
            num += 1
            tenpercent += caster.max_health / 10

        damage = caster.attack * caster.attack_mod + (30 * num)
        self.rect = pygame.Rect((0, 0), (250, 250))
        self.rect.center = caster.rect.center

        if caster.charge == 100:
            for i in caster.enemies:
                if i.rect.colliderect(self.rect):

                    colors = [(226, 34, 76), (226, 88, 34), (226, 184, 34)]
                    a = Animation(colors, 1, (self.rect.left, self.rect.top),
                                  (self.rect.width, self.rect.height),
                                  "special")
                    caster.animations.append(a)
                    enemy = i
                    damage *= calculate_damage_mod(self, enemy, "armour")
                    enemy.health -= damage
                    print(damage)
                    caster.charge = 0
                else:
                    print("No one close enough!")

        else:
            print("Not enough charge!")
Exemplo n.º 3
0
    def prepare_animation(self, hit=False):
        rangestart = 1
        if hit:
            rangestart += 1
            self.animations["ray"].count=1
        else:
            self.animations["ray"] = Animation(self.game_context, self, "ray")
        widths = range(rangestart,6) + range(6,0,-1)
        radiuses = range(1,8)
        frame_duration = self.ray_duration/(len(widths) + len(radiuses))
        for radius in radiuses:
            image = self.costumes['default'].copy()
            image.set_alpha(127)
            pygame.draw.circle(image, (255,255,255), (self.parent.rect.centerx, self.parent.rect.centery), radius)
            self.animations['ray'].append_frame(image, duration_msec=frame_duration, defs=False)
        for ray_width in widths:
            image = self.costumes['default'].copy()
            if ray_width == 1:
                image.set_alpha(0)
            else:
                image.set_alpha(127)
            pygame.draw.line(image, (255,255,255), (self.parent.rect.centerx,self.parent.rect.centery), (self.ray_x, self.ray_y), ray_width)
            if hit:
                pygame.draw.circle(image, (255,255,255), (self.ray_x, self.ray_y), 8)

            self.animations['ray'].append_frame(image, duration_msec=frame_duration, defs=False)
        self.change_active_costume('default')
Exemplo n.º 4
0
 def load_textures(self):
     
     base_path = "imgs/gulags/" + self.path
     path = base_path + "/lvl" + str(self.nivel) + "/*.png"
     
     self.ani_normal = Animation(path)
     self.current_ani = self.ani_normal
 def __init__(self,id,div,speed=8):
     
     self.id = id
     self.div = div
     self.speed = speed
     
     self.base_path = "imgs/characters/" + self.id + "/"
     
     self.ani_general = Animation(self.base_path+"general/*png",speed=self.speed)
     self.ani_happy = Animation(self.base_path+"happy/*png",speed=self.speed)
     self.ani_angry = Animation(self.base_path+"angry/*png",speed=self.speed)
     self.current_ani = self.ani_general
     
     if self.id == "medic":
         self.color = magenta
     elif self.id == "secur":
         self.color = vermelho
     elif self.id == "recur":
         self.color = verde
     elif self.id == "construct":
         self.color = azul
     
     self.btn_chs = Button(self.color,0,0,0,0,self.div,text_size=20)
Exemplo n.º 6
0
    def __init__(self, screen, game_settings, rect, weapon):
        super().__init__()
        self.screen = screen
        self.game_settings = game_settings
        self.xoffset = 15
        self.rotation = 45

        # Sets up state flags
        self.using = False
        self.hit = False
        self.toggled = False
        self.collision = False

        # Rotation and positioning vars
        self.rotbase = 45
        self.rottarget = 60
        self.rotrate = 5

        # Loads weapon img
        self.image_r = pygame.image.load('../resources/items/weapon/' +
                                         weapon + '.png')
        self.image_l = pygame.transform.flip(self.image_r, True, False)
        # Tilts weapon
        self.image_r = pygame.transform.rotate(self.image_r, -self.rotation)
        self.image_l = pygame.transform.rotate(self.image_l, self.rotation)

        # Sets up init position/image
        self.image = self.image_r
        self.rect = self.image.get_rect()
        self.rect.left = rect.right
        self.rect.centery = rect.centery

        self.damage = game_settings.setWeaponDamage(weapon)

        self.animation = Animation(screen, game_settings.hit_path,
                                   game_settings.hit_frames,
                                   game_settings.hit_size)
Exemplo n.º 7
0
 def nada(self):
     self.animations["ray"] = Animation(self.game_context, self, "ray")
     widths = range(2,6) + range(6,0,-1)
     radiuses = range(1,8)
     frame_duration = self.ray_duration/(len(widths) + len(radiuses))
     for radius in radiuses:
         image = self.costumes['default'].copy()
         image.set_alpha(127)
         pygame.draw.circle(image, (255,255,255), (self.ray_sourcex, self.parent.rect.centery), radius)
     for width in widths:
         image = self.costumes['default'].copy()
         image.set_alpha(127)
         pygame.draw.line(image, (255,255,255), (self.parent.rect.centerx,self.parent.rect.centery), (self.ray_x,self.ray_y), width)
         self.animations['ray'].add_frame(image, duration_msec=frame_duration, defs=False)
     self.change_active_costume('default')
Exemplo n.º 8
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.num_tabs = 0
        self.states = []
        self.selected = None
        self._icon = RotatingIcon(
            self,
            self.style().standardIcon(QStyle.SP_BrowserReload))
        self._working_anim = anim = Animation(self, fps=15, duration=1400)
        self.process_completed.connect(anim.stop)
        self.process_started.connect(anim.start)
        anim.tick.connect(self._update_active)
        self._active_box = None

        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum)
        self.setMinimumSize(64, 32)
        self.setMaximumHeight(64)
Exemplo n.º 9
0
    def _turn_on_light(self):
        if (self._frame_count % self._window_on_count == 0):
            OffWindows = []
            for x in range(0, self._columns):
                for y in range(0, self._rows):
                    if not self._windows[x][y]["status"]:
                        OffWindows.append([x, y])
            target = OffWindows.pop(random.randint(0, len(OffWindows) - 1))
            x, y = target[0], target[1]
            self._windows[x][y]["status"] = True
            self._windows[x][y]["window"].fill_color = sf.Color.WHITE
            self._windows[x][y]["create_time"] = datetime.now()
            self._windows[x][y]["energyConsumption"] = 0.01
            animWin = Animation(self._windows[x][y]["window"])
            self._windows[x][y]["animating"] = animWin
            self._windows[x][y]["a_creation_time"] = datetime.now()

        if (self._frame_count % settings.speedIncrement == 0
                and self._acceleration):
            self._window_on_count = self._window_on_count - 1 if self._window_on_count > 1 else 1

        self._frame_count += 1
Exemplo n.º 10
0
 def _init(self):
     Animation._init(self)
     self.__write_sine()
Exemplo n.º 11
0
class Weapon(Sprite):
    def __init__(self, screen, game_settings, rect, weapon):
        super().__init__()
        self.screen = screen
        self.game_settings = game_settings
        self.xoffset = 15
        self.rotation = 45

        # Sets up state flags
        self.using = False
        self.hit = False
        self.toggled = False
        self.collision = False

        # Rotation and positioning vars
        self.rotbase = 45
        self.rottarget = 60
        self.rotrate = 5

        # Loads weapon img
        self.image_r = pygame.image.load('../resources/items/weapon/' +
                                         weapon + '.png')
        self.image_l = pygame.transform.flip(self.image_r, True, False)
        # Tilts weapon
        self.image_r = pygame.transform.rotate(self.image_r, -self.rotation)
        self.image_l = pygame.transform.rotate(self.image_l, self.rotation)

        # Sets up init position/image
        self.image = self.image_r
        self.rect = self.image.get_rect()
        self.rect.left = rect.right
        self.rect.centery = rect.centery

        self.damage = game_settings.setWeaponDamage(weapon)

        self.animation = Animation(screen, game_settings.hit_path,
                                   game_settings.hit_frames,
                                   game_settings.hit_size)

    def face_right(self):
        self.image = self.image_r
        self.animation.right()

    def face_left(self):
        self.image = self.image_l
        self.animation.left()

    def rotating(self, facing_right):

        if self.using and self.toggled:
            if self.rotation != self.rottarget and not self.hit:
                self.rotation += self.rotrate

                self.image = pygame.transform.rotate(self.image, -self.rotrate)
            else:
                self.hit = True

                if self.rotation != self.rotbase:
                    self.rotation -= self.rotrate

                    self.image = pygame.transform.rotate(
                        self.image, self.rotrate)
                else:
                    self.using = False
                    self.hit = False

                    if facing_right:
                        self.image = self.image_r
                    else:
                        self.image = self.image_l

    def update(self, rect, centery, facing_right):
        self.rotating(facing_right)
        self.rect.centery = centery

        if facing_right:
            self.rect.centerx = rect.right - ((rect.centerx - rect.right) / 3)
        else:
            self.rect.centerx = rect.left + ((rect.left - rect.centerx) / 3)

        self.animation.update()

    def blitme(self):
        if self.toggled:
            self.screen.blit(self.image, self.rect)

            if self.using:
                rect_anim = self.rect.copy()
                rect_anim.left = rect_anim.right
                self.animation.blitme(rect_anim)