Beispiel #1
0
 def add_number_spark(self,
                      number,
                      start_pos,
                      end_pos,
                      dt=1.0,
                      color=None,
                      dim=2):
     random_offset = euclid.Vector3(self.randomizer.random() * 50 - 25,
                                    self.randomizer.random() * 30, 0)
     start_pos += random_offset
     end_pos += random_offset
     if color == None: color = (1., 1., 1., 1)
     elif isinstance(color, str): color = self.COLORS.get(color)
     else: color = color
     spark = Label(str(number),
                   size=40,
                   color=color,
                   shadow=False,
                   halign="center",
                   valign="center",
                   pos=start_pos)
     spark._pos.set_transition(dt=dt,
                               method="ease_out_circ")  #ease_out_back")
     spark.pos = end_pos
     spark.visible = anim.animate(1., 0., dt=dt)
     spark.scale = anim.animate(1.0, 1.3, dt=dt, method="sine")
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #2
0
 def set_chained_transition(self, positions, dts, methods):
     assert len(positions) > 0
     if isinstance(dts, list) or isinstance(dts, tuple):
         assert len(dts) == len(positions)
     else:
         dts = [dts] * len(positions)
     if isinstance(methods, list) or isinstance(methods, tuple):
         assert len(methods) == len(positions)
     else:
         methods = [methods] * len(positions)
     x_chain = []
     prev_x = self.x
     y_chain = []
     prev_y = self.y
     z_chain = []
     prev_z = self.z
     for pos, dt, method in zip(positions, dts, methods):
         x_chain.append(animate(prev_x, pos.x, dt=dt, method=method))
         y_chain.append(animate(prev_y, pos.y, dt=dt, method=method))
         z_chain.append(animate(prev_z, pos.z, dt=dt, method=method))
         prev_x = pos.x
         prev_y = pos.y
         prev_z = pos.z
     self.x = chain(x_chain)
     self.y = chain(y_chain)
     self.z = chain(z_chain)
Beispiel #3
0
 def set_chained_transition(self, quaternions, dts, methods):
     assert len(quaternions) > 0
     if isinstance(dts, list) or isinstance(dts, tuple):
         assert len(dts) == len(quaternions)
     else:
         dts = [dts] * len(quaternions)
     if isinstance(methods, list) or isinstance(methods, tuple):
         assert len(methods) == len(quaternions)
     else:
         methods = [methods] * len(quaternions)
     w_chain = []
     prev_w = self.w
     x_chain = []
     prev_x = self.x
     y_chain = []
     prev_y = self.y
     z_chain = []
     prev_z = self.z
     for quat, dt, method in zip(quaternions, dts, methods):
         w_chain.append(animate(prev_w, quat.w, dt=dt, method=method))
         x_chain.append(animate(prev_x, quat.x, dt=dt, method=method))
         y_chain.append(animate(prev_y, quat.y, dt=dt, method=method))
         z_chain.append(animate(prev_z, quat.z, dt=dt, method=method))
         prev_w = quat.w
         prev_x = quat.x
         prev_y = quat.y
         prev_z = quat.z
     self.w = chain(w_chain)
     self.x = chain(x_chain)
     self.y = chain(y_chain)
     self.z = chain(z_chain)
Beispiel #4
0
    def __init__(self, pos=zero, is_opponent=False):
        super(StatusView,self).__init__(pos)
        self._toggled = False
        self._spacing = 10
        self._reveal_library = False
        self.color = (0.5, 0.5, 0.5)
        self.is_opponent = is_opponent
        #self._pos.set_transition(dt=0.1, method="linear")
        #symbols = ["life", "library", "hand", "graveyard", "exile"]
        symbols = ["life", "hand", "library", "graveyard", "exile"]
        self.symbols = dict([(symbol, cls(symbol)) for symbol, cls in zip(symbols, [Image, Image, Image, Image, Image])])
        for symbol in self.symbols.values():
            symbol.alpha = 0.8
        self.player_name = Label("", 11, halign="left", fontname = "Arial Bold", valign="center", shadow=False)
        #sizes = [20, 16, 14, 14, 14]
        sizes = [20, 14, 14, 14, 14]
        self.values = dict([(symbol, Label('', size, fontname = "Arial Bold", halign="center", valign="center", shadow=False)) for symbol, size in zip(symbols, sizes)])
        #for val in self.values.values():
        self.avatar = Image(pyglet.image.Texture.create(80,80))
        self.avatar.shaking = 0
        self.avatar.alpha = anim.animate(1., 1., dt=0.25)
        self.alpha = anim.animate(1., 1., dt=0.25)

        self.manapool = ManaPool(is_opponent)
        self.zone_view = ZoneView()
        self._library = LibraryImage(is_opponent)
        self.width, self.height = 145,135
Beispiel #5
0
 def entering_play(self):
     self.is_tapped = False
     self.tapping = anim.animate(0, 0, dt=0.3)
     self.highlighting = anim.animate(0, 0, dt=0.2)
     self.zooming = anim.animate(0, 0, dt=0.2)
     self.pos_transition = "ease_out_circ"  #"ease_out_back"
     self._pos.set_transition(dt=0.4, method=self.pos_transition)
     #self._pos.y = anim.animate(guicard._pos.y, guicard._pos.y, dt=0.4, method="ease_out")
     self._orientation.set_transition(dt=0.3, method="sine")
     self.can_layout = True
     if self.gamecard.types == Creature: self.setup_creature_role()
     # Check for counters
     dispatcher.connect(self.add_counter,
                        signal=CounterAddedEvent(),
                        sender=self.gamecard)
     dispatcher.connect(self.remove_counter,
                        signal=CounterRemovedEvent(),
                        sender=self.gamecard)
     dispatcher.connect(self.type_modified,
                        signal=TypesModifiedEvent(),
                        sender=self.gamecard)
     self.counters = [
         Counter(counter.ctype) for counter in self.gamecard.counters
     ]
     self.layout_counters()
Beispiel #6
0
 def __init__(self,value,pos=euclid.Vector3(0,0,0)):
     super(Image,self).__init__(pos)
     if isinstance(value, str): self.img = ImageCache.get(value)
     else: self.img = value
     self.alpha = anim.animate(1.0,1.0,dt=1,method="sine")
     self.color = (1.0, 1.0, 1.0)
     self._scale = anim.animate(self._final_scale, self._final_scale, dt=0.25, method="sine")
Beispiel #7
0
 def __init__(self, pos=euclid.Vector3(0,0,0)):
     self._pos = AnimatedVector3(pos)
     self.visible = anim.animate(0, 1, dt=1.0)
     self.rotatex = anim.animate(0,0,dt=1.0)
     self.rotatey = anim.animate(0,0,dt=1.0)
     self.rotatez = anim.animate(0,0,dt=1.0)
     self._final_scale = 1.0
     self._scale = anim.animate(self._final_scale, self._final_scale, dt=0.25, method="linear")
Beispiel #8
0
 def add_card(self, card):
     newcard = CardLibrary.CardLibrary.getCard(card)
     newcard._pos.set_transition(dt=0.3, method="sine") #ease_out_back") #self.pos_transition)
     #newcard._orientation.set(euclid.Quaternion())
     #newcard._orientation.set_transition(dt=0.2, method=self.orientation_transition)
     newcard.size = anim.animate(0.1, 0.1, dt=0.3, method="sine")
     newcard.alpha = anim.animate(0, 1, dt=0.1, method="linear")
     self.cards.append(newcard)
Beispiel #9
0
 def animate_life(self, amount):
     symbol = self.symbols["life"]
     curr_scale = symbol._final_scale
     if amount > 0: final_scale = curr_scale*1.5
     else: final_scale = curr_scale*0.5
     symbol._scale = anim.animate(curr_scale, final_scale,dt=0.75, method="oscillate")
     symbol.alpha = anim.animate(symbol.alpha, 0.7,dt=0.75, method="oscillate")
     self.update_life()
Beispiel #10
0
 def __init__(self):
     self.background = ImageCache.get_texture("matte.png")
     self._redzone_width = anim.animate(0,0,dt=0.5, method="linear")
     self._render_redzone = anim.animate(0,0,dt=0.5, method="linear")
     self._highlight_top = anim.animate(0,0,dt=0.8, method="ease_out")
     self._highlight_bottom = anim.animate(0,0,dt=0.8, method="ease_out")
     self.highlight = "bottom"
     self.numtiles = 8
     self.size = 8
Beispiel #11
0
    def button(self, id):
        if id == 51:
            self.get_layout(CanvasLayout)
            self.properties.world_result = []
            self.properties.mass_generalized = []
            self.properties.calculate_mass_and_world()
            langrange = System(self.properties.world_result,self.properties.mass_generalized)

            animate(langrange)
Beispiel #12
0
 def highlight(self):
     if self.highlighting == 0:
         self.highlighting = anim.animate(0, 1, dt=0.75)
         #self.old_size = self.size
         self.size = anim.animate(self.size,
                                  1.5 * self.size,
                                  dt=0.5,
                                  method="oscillate",
                                  extend="repeat")
Beispiel #13
0
 def __init__(self):
     self.background = ImageCache.get_texture("matte.png")
     self._redzone_width = anim.animate(0, 0, dt=0.5, method="linear")
     self._render_redzone = anim.animate(0, 0, dt=0.5, method="linear")
     self._highlight_top = anim.animate(0, 0, dt=0.8, method="ease_out")
     self._highlight_bottom = anim.animate(0, 0, dt=0.8, method="ease_out")
     self.highlight = "bottom"
     self.numtiles = 8
     self.size = 8
Beispiel #14
0
 def add_card_spark(self, card, start_pos, end_pos, size, dt=1.0, grow=False, dim=2):
     spark = Image(card._texture, pos=start_pos)
     spark._pos.set_transition(dt=dt, method="ease_in") #ease_out_back")
     spark.pos = end_pos
     spark.visible = anim.animate(1., 0., dt=dt, method="step")
     if grow: spark.scale = anim.animate(0.1, size, dt=dt, method="sine")
     else: spark.scale = anim.animate(1.5, size, dt=dt, method="sine")
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #15
0
 def __init__(self, value, pos=euclid.Vector3(0, 0, 0)):
     super(Image, self).__init__(pos)
     if isinstance(value, str): self.img = ImageCache.get(value)
     else: self.img = value
     self.alpha = anim.animate(1.0, 1.0, dt=1, method="sine")
     self.color = (1.0, 1.0, 1.0)
     self._scale = anim.animate(self._final_scale,
                                self._final_scale,
                                dt=0.25,
                                method="sine")
Beispiel #16
0
 def highlight(self):
     if self.highlighting == 0:
         self.highlighting = anim.animate(0, 1, dt=0.75)
         self.old_pos = self.pos
         self.pos += euclid.Vector3(0, 3, 0)
         self.highlight_alpha = anim.animate(0.0,
                                             0.8,
                                             dt=1,
                                             method="oscillate",
                                             extend="repeat")
Beispiel #17
0
 def add_card(self, card):
     newcard = CardLibrary.CardLibrary.getHandCard(card)
     self._card_map[card.key] = newcard
     newcard.hidden = self.hidden
     newcard._pos.set_transition(dt=0.8, method="sine") #self.pos_transition)
     newcard._orientation.set_transition(dt=0.2, method=self.orientation_transition)
     newcard.size = anim.animate(newcard.size, newcard.size, dt=0.2, method="sine")
     newcard.alpha = anim.animate(0, 1.0, dt=1.0, method="ease_out_circ")
     self.cards.append(newcard)
     self.layout()
Beispiel #18
0
 def __init__(self, pos=euclid.Vector3(0,0,0)):
     super(StackView,self).__init__(pos)
     self.is_focused = False
     self._is_spaced = True
     self.visible = anim.constant(0)
     #self.header = Label("Stack", halign="left", valign="top")
     #self.header.pos = euclid.Vector3(0,0,0)
     #self.text = Label("", halign="left", valign="center", shadow=False, background=True)
     #self.text.visible = anim.animate(0, 0, dt=0.4, method="linear")
     self.width = anim.animate(0, 0, dt=0.2, method="ease_out")
     self.height = anim.animate(0, 0, dt=0.2, method="ease_out")
Beispiel #19
0
 def __init__(self, pos=euclid.Vector3(0, 0, 0)):
     self._pos = AnimatedVector3(pos)
     self.visible = anim.animate(0, 1, dt=1.0)
     self.rotatex = anim.animate(0, 0, dt=1.0)
     self.rotatey = anim.animate(0, 0, dt=1.0)
     self.rotatez = anim.animate(0, 0, dt=1.0)
     self._final_scale = 1.0
     self._scale = anim.animate(self._final_scale,
                                self._final_scale,
                                dt=0.25,
                                method="linear")
Beispiel #20
0
 def __init__(self, pos=euclid.Vector3(0,0,0)):
     super(ZoneView,self).__init__(pos,reverse_draw=True)
     self._pos.set_transition(dt=0.001)
     self.selected_width = anim.animate(0, 0, dt=0.3, method="sine")
     self.sorted = False
     self.padding = 15
     points = [(0.0, 0.0), (26.0, 244.0), (184.0, 368.0), (400.0, 226.0)]
     self.path = BezierPath(*[euclid.Point2(v[0], v[1]) for v in points])
     self.visible = anim.animate(0,0,dt=0.3)
     self.layout = self.layout_straight
     self.is_library = False
Beispiel #21
0
 def hide(self):
     self.visible = 0.0
     for card in self.cards:
         card.alpha = 0.5
         #card._pos.set_transition(dt=0.25, method="ease_out_circ")
         card.pos = euclid.Vector3(-self.padding,0,0)
         card.size = anim.animate(card.size, 0.1, dt=0.25, method="ease_out_circ")
     for card in self.selected:
         card.alpha = 0.5
         #card._pos.set_transition(dt=0.25, method="ease_out_circ")
         card.pos = euclid.Vector3(-self.padding,0,0)
         card.size = anim.animate(card.size, 0.1, dt=0.25, method="ease_out_circ")
Beispiel #22
0
 def add_star_spark(self, start_pos, end_pos, dt=1.0, color=None, start_size=0.2, end_size=2.0, dim=2):
     spark = Image('targeting', pos=start_pos)
     if color == None: spark.color = (1.0, 1.0, 1.0)
     elif isinstance(color, str):
         spark.color = self.COLORS.get(color)
     else: spark.color = color
     spark.visible = anim.animate(1., 0., dt=dt)
     spark.rotatez = anim.animate(15, -45, dt=dt, method="sine")
     spark.scale = anim.animate(start_size, end_size, dt=dt, method="sine")
     spark.alpha = anim.animate(1.0, 0., dt=dt)
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #23
0
 def add_spark(self, start_pos, end_pos, dt=1.0, color=None, grow=False, dim=2):
     spark = Image("glow", pos=start_pos)
     spark._pos.set_transition(dt=dt, method="ease_out_circ") #ease_out_back")
     spark.pos = end_pos
     if color == None: spark.color=(1.,1.,1.)
     elif isinstance(color, str):
         spark.color = self.COLORS.get(color)
     else: spark.color = color
     spark.visible = anim.animate(1., 0., dt=dt)
     if grow: spark.scale = anim.animate(0.5, 2.0, dt=dt, method="sine")
     else: spark.scale = anim.animate(2.0, 0.2, dt=dt, method="sine")
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #24
0
 def add_ability(self, newcard, startt):
     self.cards.append(newcard)
     self.focus_idx = len(self)-1
     newcard.size = anim.animate(0.2, 0.2, startt=startt, dt=0.5, method="ease_out_circ")
     if startt != 0:
         newcard.visible = anim.animate(0,1,dt=startt, method="step")
         #self.header.dt = startt
     else: pass #self.header.dt = 0.01
     self.layout()
     newcard.alpha = anim.animate(0, 0.5, startt=startt, dt=0.3, method="ease_out_circ")
     newcard._pos.set_transition(dt=0.2, method="ease_out") #self.pos_transition)
     newcard.announced = False
     return newcard
Beispiel #25
0
 def animate_life(self, amount):
     symbol = self.symbols["life"]
     curr_scale = symbol._final_scale
     if amount > 0: final_scale = curr_scale * 1.5
     else: final_scale = curr_scale * 0.5
     symbol._scale = anim.animate(curr_scale,
                                  final_scale,
                                  dt=0.75,
                                  method="oscillate")
     symbol.alpha = anim.animate(symbol.alpha,
                                 0.7,
                                 dt=0.75,
                                 method="oscillate")
     self.update_life()
Beispiel #26
0
 def add_number_spark(self, number, start_pos, end_pos, dt=1.0, color=None, dim=2):
     random_offset = euclid.Vector3(self.randomizer.random()*50-25,self.randomizer.random()*30,0)
     start_pos += random_offset
     end_pos += random_offset
     if color == None: color=(1.,1.,1.,1)
     elif isinstance(color, str): color = self.COLORS.get(color)
     else: color = color
     spark = Label(str(number), size=40, color=color, shadow=False, halign="center", valign="center", pos=start_pos)
     spark._pos.set_transition(dt=dt, method="ease_out_circ") #ease_out_back")
     spark.pos = end_pos
     spark.visible = anim.animate(1., 0., dt=dt)
     spark.scale = anim.animate(1.0, 1.3, dt=dt, method="sine")
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #27
0
    def add_card(self, card, startt):
        guicard = CardLibrary.CardLibrary.getPlayCard(card)
        self._card_map[card.key] = guicard
        guicard.entering_play()
        guicard._pos.set(euclid.Vector3(0, 0, 0))
        cardsize = CARDSIZE
        if card.types == Creature:
            self.creatures.insert(0, guicard)
            guicard._row = self.creatures
        elif card.types == Land:
            if card.supertypes == Basic:
                for key in self.lands.keys():
                    if card.subtypes == key:
                        self.lands[key].append(guicard)
                        guicard._row = self.lands[key]
                        cardsize = CARDSIZE * 0.8
                        break
            else:
                self.lands['Other'].append(guicard)
                guicard._row = self.lands['Other']
        elif card.types == Aura and card.controller == card.attached_to.controller and Match.isPermanent(
                card.attached_to):
            # it should be attached at this point
            self.attached.append(guicard)
            guicard._row = self.attached
            self.card_attached(card, card.attached_to)
        else:
            self.other_perms.insert(0, guicard)
            guicard._row = self.other_perms
        guicard._orientation.set(
            euclid.Quaternion.new_rotate_axis(-math.pi / 2,
                                              euclid.Vector3(1, 0, 0)))
        #if self.is_opponent_view: guicard.orientation *= euclid.Quaternion.new_rotate_axis(math.pi, euclid.Vector3(0,0,1))
        if card.tapped: guicard.tap()
        self.layout()

        if startt != 0:
            guicard.visible = anim.animate(0, 1, dt=startt, method="step")
        guicard.size = anim.animate(0.005, cardsize, dt=0.2, method="sine")
        guicard.alpha = anim.animate(0.5,
                                     1,
                                     startt=startt,
                                     dt=1.0,
                                     method="ease_out_circ")
        guicard._orientation.set_transition(dt=0.2, method="sine")
        guicard._pos.set_transition(dt=0.2,
                                    method="ease_out_circ")  #"ease_out_back")
        #guicard._pos.y = anim.animate(guicard._pos.y, guicard._pos.y, dt=0.4, method="sine") #"ease_out")
        return guicard
Beispiel #28
0
 def __init__(self, fSize, pcCoverImage, angle=-70):
     self.pTexture = Texture(pcCoverImage)
     w, h = self.pTexture.fWidth, self.pTexture.fHeight
     if w > h: self.fWidth, self.fHeight = fSize, fSize*float(h)/w
     else: self.fWidth, self.fHeight = fSize*float(w)/h, fSize
     self.angle = angle
     self.z_base = -4
     self.z_focus = -2
     self.y_base = self.fHeight/2 - 1
     self.fX = anim.ConstantAnimator(0)
     self.fY = anim.ConstantAnimator(0)
     self.fZ = anim.animate(start=self.z_base, end=self.z_base, dt=.5, method="ease_out_back")
     self.fAngle = anim.animate(start=angle, end=angle, dt=.5, method="ease_out_circ")
     self.fAlpha = pValueCoverAlpha
     self.current = False
Beispiel #29
0
 def restore_card(self, card):
     #if self.zooming == 1.0: # This will finish the zooming motion
     if True:
         card.zooming = anim.animate(1, 0, dt=0.3, method="linear")
         #card = self.zooming_card
         card.size = card.old_size
         card.pos = card.old_pos
Beispiel #30
0
 def __init__(self, gamecard, front, back, art, text="", style="regular"):
     super(StackCard,self).__init__(gamecard,front,back)
     self._art = art
     self.highlighting = anim.animate(0, 0, dt=0.2, method="step")
     self.size = anim.animate(self.size, self.size, dt=0.2, method="sine")
     self.alpha = anim.animate(0, 0, dt=1.0, method="ease_out_circ")
     self.style = style
     self.stackwidth, self.stackheight = 368, 414
     if self.style == "regular":
         self._texture = pyglet.image.Texture.create(self.renderwidth, self.renderheight, force_rectangle=True)
         Card._render(self._texture, self._art, self.gamecard)
     else:
         self._texture = pyglet.image.Texture.create(self.stackwidth, self.stackheight, force_rectangle=True)
         self.text = text
         self.render_special()
     if not StackCard.borderedlist: StackCard.borderedlist = self.build_renderlist(self.stackwidth, self.stackheight)
Beispiel #31
0
 def add_card_spark(self,
                    card,
                    start_pos,
                    end_pos,
                    size,
                    dt=1.0,
                    grow=False,
                    dim=2):
     spark = Image(card._texture, pos=start_pos)
     spark._pos.set_transition(dt=dt, method="ease_in")  #ease_out_back")
     spark.pos = end_pos
     spark.visible = anim.animate(1., 0., dt=dt, method="step")
     if grow: spark.scale = anim.animate(0.1, size, dt=dt, method="sine")
     else: spark.scale = anim.animate(1.5, size, dt=dt, method="sine")
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #32
0
 def set_phase(self, state):
     self.current_state = state.lower()
     if state in self.state_map:
         self.current, txt = self.state_map[state]
         self.state_text = self.state_labels[self.current]
         if not self.select:
             self.state_text._pos.x = anim.animate(0, 0, dt=0.5, method="ease_out_circ") #sine")
             self.layout()
Beispiel #33
0
 def entering_play(self):
     self.is_tapped = False
     self.tapping = anim.animate(0, 0, dt=0.3)
     self.highlighting = anim.animate(0, 0, dt=0.2)
     self.zooming = anim.animate(0, 0, dt=0.2)
     self.pos_transition = "ease_out_circ" #"ease_out_back"
     self._pos.set_transition(dt=0.4, method=self.pos_transition)
     #self._pos.y = anim.animate(guicard._pos.y, guicard._pos.y, dt=0.4, method="ease_out")
     self._orientation.set_transition(dt=0.3, method="sine")
     self.can_layout = True
     if self.gamecard.types == Creature: self.setup_creature_role()
     # Check for counters
     dispatcher.connect(self.add_counter, signal=CounterAddedEvent(), sender=self.gamecard)
     dispatcher.connect(self.remove_counter, signal=CounterRemovedEvent(), sender=self.gamecard)
     dispatcher.connect(self.type_modified, signal=TypesModifiedEvent(), sender=self.gamecard)
     self.counters = [Counter(counter.ctype) for counter in self.gamecard.counters]
     self.layout_counters()
Beispiel #34
0
 def remove_card(self, card, clock):
     guicard = self._card_map.pop(card.key)
     guicard.leaving_play()
     for cardlist in [self.creatures,self.other_perms,self.attached]+self.lands.values():
         if guicard in cardlist: break
     guicard.alpha = anim.animate(1, 0.25, dt=1.5, method="ease_in_circ")
     clock.schedule_once(lambda t: cardlist.remove(guicard), 1.4)
     clock.schedule_once(lambda t: self.layout(), 1.5)
Beispiel #35
0
 def set_phase(self, state):
     self.current_state = state.lower()
     if state in self.state_map:
         self.current, txt = self.state_map[state]
         self.state_text = self.state_labels[self.current]
         if not self.select:
             self.state_text._pos.x = anim.animate(
                 0, 0, dt=0.5, method="ease_out_circ")  #sine")
             self.layout()
Beispiel #36
0
 def remove_card(self, card, clock):
     guicard = self._card_map.pop(card.key)
     guicard.leaving_play()
     for cardlist in [self.creatures, self.other_perms, self.attached
                      ] + self.lands.values():
         if guicard in cardlist: break
     guicard.alpha = anim.animate(1, 0.25, dt=1.5, method="ease_in_circ")
     clock.schedule_once(lambda t: cardlist.remove(guicard), 1.4)
     clock.schedule_once(lambda t: self.layout(), 1.5)
Beispiel #37
0
 def set_chained_transition(self, positions, dts, methods):
     assert len(positions) > 0
     if isinstance(dts, list) or isinstance(dts, tuple):
         assert len(dts) == len(positions)
     else: dts = [dts]*len(positions)
     if isinstance(methods, list) or isinstance(methods, tuple):
         assert len(methods) == len(positions)
     else: methods = [methods]*len(positions)
     x_chain = []; prev_x = self.x
     y_chain = []; prev_y = self.y
     z_chain = []; prev_z = self.z
     for pos, dt, method in zip(positions, dts, methods):
         x_chain.append(animate(prev_x, pos.x, dt=dt, method=method))
         y_chain.append(animate(prev_y, pos.y, dt=dt, method=method))
         z_chain.append(animate(prev_z, pos.z, dt=dt, method=method))
         prev_x = pos.x; prev_y = pos.y; prev_z = pos.z
     self.x = chain(x_chain)
     self.y = chain(y_chain)
     self.z = chain(z_chain)
Beispiel #38
0
 def __init__(self, pos=zero):
     super(PhaseStatus, self).__init__(pos)
     self.visible = anim.constant(0)
     states = [('Untap', 'Untap'), ('Upkeep', 'Upkeep'), ('Draw', 'Draw'),
               ('Main1', 'Main 1'), ('BeginCombat', 'Beginning of combat'),
               ('Attack', 'Declare attackers'),
               ('Block', 'Declare blockers'), ('Damage', 'Combat damage'),
               ('EndCombat', 'End of combat'), ('Main2', 'Main 2'),
               ('EndStep', 'End Step'), ('Cleanup', 'Cleanup')]
     self.state_list = [s.lower() for s, t in states]
     self.grouping = [0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0]
     self.state_map = dict([(key, (i, val))
                            for i, (key, val) in enumerate(states)])
     self.states = [Image(key) for key, val in states]
     self.state_labels = [
         Label(val, size=20, valign="center", shadow=False)
         for key, val in states
     ]
     self.state_text = None
     for state in self.states:
         state.visible = anim.constant(1.0)
         state.alpha = anim.animate(1.0,
                                    1.0,
                                    dt=0.5,
                                    method="ease_out_circ")  ##sine")
         state.scale = anim.animate(1.0, 1.0, dt=0.5, method="sine")
         state._pos.set_transition(dt=0.5, method="sine")
     for label in self.state_labels:
         label.scale = 0.8
         label._pos.y = anim.constant(
             -100)  # This is just a hack to hide it
     self.width = state.width
     self.current = 0
     self.select = False
     self.curr_player = None
     self.turn_label = Label("",
                             size=24,
                             halign="center",
                             valign="top",
                             shadow=False)
     self.render_after_transform = self.render_game
     self.set_stops()
Beispiel #39
0
 def new_turn(self, player):
     return
     life = self.symbols["life"]
     if self.player == player:
         life.rotatey = anim.animate(0,
                                     360,
                                     dt=5,
                                     method='linear',
                                     extend='repeat')
     else:
         life.rotatey = anim.constant(0)
Beispiel #40
0
 def add_star_spark(self,
                    start_pos,
                    end_pos,
                    dt=1.0,
                    color=None,
                    start_size=0.2,
                    end_size=2.0,
                    dim=2):
     spark = Image('targeting', pos=start_pos)
     if color == None: spark.color = (1.0, 1.0, 1.0)
     elif isinstance(color, str):
         spark.color = self.COLORS.get(color)
     else:
         spark.color = color
     spark.visible = anim.animate(1., 0., dt=dt)
     spark.rotatez = anim.animate(15, -45, dt=dt, method="sine")
     spark.scale = anim.animate(start_size, end_size, dt=dt, method="sine")
     spark.alpha = anim.animate(1.0, 0., dt=dt)
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #41
0
 def zoom_card(self, card):
     if card.zooming == 0:
         #self.zooming_card = card
         card.zooming = anim.animate(0, 1, dt=0.3, method="linear")
         card.old_pos = card.pos
         card.old_size = card.size
         if self.is_opponent and card.pos.x-card.width/2 < 0: pos_shift = card.width/1.5
         elif card.pos.x+card.width/2 > self.avail_width: pos_shift = self.avail_width - card.width/1.5
         else: pos_shift = card.pos.x
         card._pos.set_transition(dt=0.2, method="sine") #self.pos_transition)
         card.pos = euclid.Vector3(pos_shift, (self.height+card.height/2)*self.dir, 0)
         card.size = 1.0
Beispiel #42
0
 def add_spark(self,
               start_pos,
               end_pos,
               dt=1.0,
               color=None,
               grow=False,
               dim=2):
     spark = Image("glow", pos=start_pos)
     spark._pos.set_transition(dt=dt,
                               method="ease_out_circ")  #ease_out_back")
     spark.pos = end_pos
     if color == None: spark.color = (1., 1., 1.)
     elif isinstance(color, str):
         spark.color = self.COLORS.get(color)
     else:
         spark.color = color
     spark.visible = anim.animate(1., 0., dt=dt)
     if grow: spark.scale = anim.animate(0.5, 2.0, dt=dt, method="sine")
     else: spark.scale = anim.animate(2.0, 0.2, dt=dt, method="sine")
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #43
0
    def __init__(self, pos=zero, is_opponent=False):
        super(StatusView, self).__init__(pos)
        self._toggled = False
        self._spacing = 10
        self._reveal_library = False
        self.color = (0.5, 0.5, 0.5)
        self.is_opponent = is_opponent
        #self._pos.set_transition(dt=0.1, method="linear")
        #symbols = ["life", "library", "hand", "graveyard", "exile"]
        symbols = ["life", "hand", "library", "graveyard", "exile"]
        self.symbols = dict([(symbol, cls(symbol)) for symbol, cls in zip(
            symbols, [Image, Image, Image, Image, Image])])
        for symbol in self.symbols.values():
            symbol.alpha = 0.8
        self.player_name = Label("",
                                 11,
                                 halign="left",
                                 fontname="Arial Bold",
                                 valign="center",
                                 shadow=False)
        #sizes = [20, 16, 14, 14, 14]
        sizes = [20, 14, 14, 14, 14]
        self.values = dict([(symbol,
                             Label('',
                                   size,
                                   fontname="Arial Bold",
                                   halign="center",
                                   valign="center",
                                   shadow=False))
                            for symbol, size in zip(symbols, sizes)])
        #for val in self.values.values():
        self.avatar = Image(pyglet.image.Texture.create(80, 80))
        self.avatar.shaking = 0
        self.avatar.alpha = anim.animate(1., 1., dt=0.25)
        self.alpha = anim.animate(1., 1., dt=0.25)

        self.manapool = ManaPool(is_opponent)
        self.zone_view = ZoneView()
        self._library = LibraryImage(is_opponent)
        self.width, self.height = 145, 135
Beispiel #44
0
    def add_card(self, card, startt):
        guicard = CardLibrary.CardLibrary.getPlayCard(card)
        self._card_map[card.key] = guicard
        guicard.entering_play()
        guicard._pos.set(euclid.Vector3(0,0,0))
        cardsize = CARDSIZE
        if card.types == Creature:
            self.creatures.insert(0, guicard)
            guicard._row = self.creatures
        elif card.types == Land:
            if card.supertypes == Basic:
                for key in self.lands.keys():
                    if card.subtypes == key:
                        self.lands[key].append(guicard)
                        guicard._row = self.lands[key]
                        cardsize = CARDSIZE*0.8
                        break
            else:
                self.lands['Other'].append(guicard)
                guicard._row = self.lands['Other']
        elif card.types == Aura and card.controller == card.attached_to.controller and Match.isPermanent(card.attached_to):
            # it should be attached at this point
            self.attached.append(guicard)
            guicard._row = self.attached
            self.card_attached(card, card.attached_to)
        else:
            self.other_perms.insert(0, guicard)
            guicard._row = self.other_perms
        guicard._orientation.set(euclid.Quaternion.new_rotate_axis(-math.pi/2, euclid.Vector3(1,0,0)))
        #if self.is_opponent_view: guicard.orientation *= euclid.Quaternion.new_rotate_axis(math.pi, euclid.Vector3(0,0,1))
        if card.tapped: guicard.tap()
        self.layout()

        if startt != 0: guicard.visible = anim.animate(0,1,dt=startt, method="step")
        guicard.size = anim.animate(0.005, cardsize, dt=0.2, method="sine")
        guicard.alpha = anim.animate(0.5, 1,startt=startt, dt=1.0, method="ease_out_circ")
        guicard._orientation.set_transition(dt=0.2, method="sine")
        guicard._pos.set_transition(dt=0.2, method="ease_out_circ") #"ease_out_back")
        #guicard._pos.y = anim.animate(guicard._pos.y, guicard._pos.y, dt=0.4, method="sine") #"ease_out")
        return guicard
Beispiel #45
0
 def __init__(self, gamecard, front, back, art, text="", style="regular"):
     super(StackCard, self).__init__(gamecard, front, back)
     self._art = art
     self.highlighting = anim.animate(0, 0, dt=0.2, method="step")
     self.size = anim.animate(self.size, self.size, dt=0.2, method="sine")
     self.alpha = anim.animate(0, 0, dt=1.0, method="ease_out_circ")
     self.style = style
     self.stackwidth, self.stackheight = 368, 414
     if self.style == "regular":
         self._texture = pyglet.image.Texture.create(self.renderwidth,
                                                     self.renderheight,
                                                     force_rectangle=True)
         Card._render(self._texture, self._art, self.gamecard)
     else:
         self._texture = pyglet.image.Texture.create(self.stackwidth,
                                                     self.stackheight,
                                                     force_rectangle=True)
         self.text = text
         self.render_special()
     if not StackCard.borderedlist:
         StackCard.borderedlist = self.build_renderlist(
             self.stackwidth, self.stackheight)
Beispiel #46
0
 def set_chained_transition(self, quaternions, dts, methods):
     assert len(quaternions) > 0
     if isinstance(dts, list) or isinstance(dts, tuple):
         assert len(dts) == len(quaternions)
     else: dts = [dts]*len(quaternions)
     if isinstance(methods, list) or isinstance(methods, tuple):
         assert len(methods) == len(quaternions)
     else: methods = [methods]*len(quaternions)
     w_chain = []; prev_w = self.w
     x_chain = []; prev_x = self.x
     y_chain = []; prev_y = self.y
     z_chain = []; prev_z = self.z
     for quat, dt, method in zip(quaternions, dts, methods):
         w_chain.append(animate(prev_w, quat.w, dt=dt, method=method))
         x_chain.append(animate(prev_x, quat.x, dt=dt, method=method))
         y_chain.append(animate(prev_y, quat.y, dt=dt, method=method))
         z_chain.append(animate(prev_z, quat.z, dt=dt, method=method))
         prev_w = quat.w; prev_x = quat.x; prev_y = quat.y; prev_z = quat.z
     self.w = chain(w_chain)
     self.x = chain(x_chain)
     self.y = chain(y_chain)
     self.z = chain(z_chain)
Beispiel #47
0
 def __init__(self, pos=zero):
     super(PhaseStatus,self).__init__(pos)
     self.visible = anim.constant(0)
     states = [('Untap','Untap'),
         ('Upkeep','Upkeep'),
         ('Draw','Draw'),
         ('Main1','Main 1'),
         ('BeginCombat','Beginning of combat'),
         ('Attack','Declare attackers'),
         ('Block','Declare blockers'),
         ('Damage','Combat damage'),
         ('EndCombat','End of combat'),
         ('Main2','Main 2'),
         ('EndStep','End Step'),
         ('Cleanup','Cleanup')]
     self.state_list = [s.lower() for s, t in states]
     self.grouping = [0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0]
     self.state_map = dict([(key, (i, val)) for i,(key,val) in enumerate(states)])
     self.states = [Image(key) for key, val in states]
     self.state_labels = [Label(val, size=20, valign="center", shadow=False) for key, val in states]
     self.state_text = None
     for state in self.states:
         state.visible = anim.constant(1.0)
         state.alpha = anim.animate(1.0, 1.0, dt=0.5, method="ease_out_circ") ##sine")
         state.scale = anim.animate(1.0, 1.0, dt=0.5, method="sine")
         state._pos.set_transition(dt=0.5, method="sine")
     for label in self.state_labels:
         label.scale = 0.8
         label._pos.y = anim.constant(-100) # This is just a hack to hide it
     self.width = state.width
     self.current = 0
     self.select = False
     self.curr_player = None
     self.turn_label = Label("", size=24, halign="center", valign="top", shadow=False)
     self.render_after_transform = self.render_game
     self.set_stops()
Beispiel #48
0
 def add_sparkle_star(self, start_pos, end_pos, dt=1.0, color=None, dim=2):
     if color == None: color = (1., 0.9, 0)
     elif isinstance(color, str): color = self.COLORS.get(color)
     else: color = color
     spark = Image('targeting', pos=start_pos)
     spark.visible = anim.animate(1., 0., dt=dt)
     spark.rotatez = anim.animate(15, -45, dt=dt, method="sine")
     spark.scale = anim.animate(0.2, 1.5, dt=dt, method="sine")
     spark.color = color
     spark.alpha = anim.animate(1.0, 0., dt=dt)
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
     dt = 0.75*dt
     spark = Image('glow', pos=start_pos)
     spark._pos.set_transition(dt=dt, method="ease_out_circ")
     spark.pos = end_pos
     spark.color = color
     spark.visible = anim.animate(1., 0., dt=dt)
     spark.alpha = anim.animate(1.0, 0., dt=dt)
     spark.scale = anim.animate(0.5, 1.5, dt=dt, method="sine")
     if dim == 2: self.active_sparks.append(spark)
     else: self.active_sparks_3d.append(spark)
Beispiel #49
0
 def set_transition(self, dt, extend="constant", method='linear'):
     self.w = animate(self.w, self.w, dt=dt, extend=extend, method=method)
     self.x = animate(self.x, self.x, dt=dt, extend=extend, method=method)
     self.y = animate(self.y, self.y, dt=dt, extend=extend, method=method)
     self.z = animate(self.z, self.z, dt=dt, extend=extend, method=method)
Beispiel #50
0
 def new_turn(self, player):
     return
     life = self.symbols["life"]
     if self.player == player: life.rotatey = anim.animate(0,360,dt=5,method='linear',extend='repeat')
     else: life.rotatey = anim.constant(0)
Beispiel #51
0
 def animate(self, status):
     symbol = self.symbols[status]
     symbol.scale = anim.animate(symbol.scale, 1.15*symbol.scale, dt=1.0, method=lambda t: anim.oscillate_n(t, 3))
Beispiel #52
0
 def highlight(self):
     if self.highlighting == 0:
         self.highlighting = anim.animate(0,1,dt=0.75)
         self.old_pos = self.pos
         self.pos += euclid.Vector3(0,3,0)
         self.highlight_alpha = anim.animate(0.0, 0.8, dt=1, method="oscillate", extend="repeat")