Beispiel #1
0
 def layout(self):
     life_img, life = self.symbols["life"], self.values["life"]
     life_img.alpha = anim.constant(0.3)
     life_img._final_scale = 0.25
     life_img._scale = anim.constant(life_img._final_scale)
     #life_img.visible = anim.constant(0)
     avatar = self.avatar
     spacing = self._spacing
     if self.is_opponent:
         x, y = spacing, life.height / 2.
     
         self.player_name.pos = euclid.Vector3(x, y, 0)
         self.manapool.pos = euclid.Vector3(self.width, 0, 0)
         x = self.width - life.width/2 - spacing
         life.pos = life_img.pos = euclid.Vector3(x, y, 0)
         
         for i, status in enumerate(["graveyard", "library", "hand"]):
             symbol, value = self.symbols[status], self.values[status]
             #symbol.scale = 0.3
             #symbol.pos = value.pos = euclid.Vector3(x, life.height+spacing+symbol.height/2+0.7*i*(symbol.height), 0)
             symbol.pos = value.pos = euclid.Vector3(x, life.height+spacing/2+symbol.height/2+i*(symbol.height), 0)
             
         library, lib = self._library, self.symbols["library"]
         library.scale = 0.5
         library.pos = euclid.Vector3(self.width, life.height+spacing/2+1.5*lib.height, 0)
         #status = "library"
         #library, value = self.symbols["library"], self.values["library"]
         #library.scale = 0.3
         #library.pos = value.pos = euclid.Vector3(spacing + library.width/2, life.height+library.height/2+spacing,0)
         avatar.pos = euclid.Vector3(spacing + avatar.width/2, life.height+avatar.height/2+spacing,0)
     else:
         x, y = spacing, self.height - life.height / 2.
     
         self.player_name.pos = euclid.Vector3(x, y, 0)
         self.manapool.pos = euclid.Vector3(self.width, self.height, 0)
         x = self.width - life.width/2 - spacing
         life.pos = life_img.pos = euclid.Vector3(x, y, 0)
         
         for i, status in enumerate(["graveyard", "library", "hand"][::-1]):
             symbol, value = self.symbols[status], self.values[status]
             #symbol.scale = 0.3
             #symbol.pos = value.pos = euclid.Vector3(x, self.height-life.height-symbol.height/2-0.7*i*(symbol.height), 0)
             symbol.pos = value.pos = euclid.Vector3(x, self.height-life.height-symbol.height/2-i*(symbol.height)-spacing/2, 0)
             
         library, lib = self._library, self.symbols["library"]
         library.scale = 0.5
         library.pos = euclid.Vector3(self.width, 1.5*lib.height, 0)
         #status = "library"
         #library, value = self.symbols["library"], self.values["library"]
         #library.scale = 0.3
         #library.pos = value.pos = euclid.Vector3(spacing + library.width/2, self.height-life.height-library.height/2-spacing,0)
         avatar.pos = euclid.Vector3(spacing + avatar.width/2, self.height-life.height-avatar.height/2-spacing,0)
Beispiel #2
0
 def __init__(self,
              value,
              size=20,
              color=(1, 1, 1, 1),
              shadow=True,
              halign="left",
              valign="bottom",
              background=False,
              pos=euclid.Vector3(0, 0, 0),
              border=False,
              width=None,
              fontname=None):
     super(Label, self).__init__(pos)
     self._fixed_width = width
     self._value = None
     self._color = color
     self.shadow = shadow
     self.halign = halign
     self.valign = valign
     self.background = background
     self.fontname = fontname if fontname else global_fontname
     self.size = size
     self.font = font.load(self.fontname, self.size, dpi=96)
     self.visible = anim.constant(1)
     self.render_border = border
     self.border = 5
     self.set_text(value)
Beispiel #3
0
 def __init__(self, pos=zero):
     super(ManaView,self).__init__(pos)
     self._pos.set_transition(dt=1.0, method="ease_out_circ")
     self.colors = ["white", "blue", "black", "red", "green", "colorless"]
     self.colormap = dict(zip(self.colors, "WUBRG"))
     self.nummana = len(self.colors)
     self.symbols = [ManaImage(color) for color in self.colors]
     self.pool = [Label("", size=20) for i in range(self.nummana)]
     self.values = dict([(c,v) for c, v in zip(self.colors, self.pool)])
     self.spend = [Label("0", size=30) for i in range(self.nummana)]
     self.spend_values = dict([(c,v) for c, v in zip(self.colors, self.spend)])
     for p, s in zip(self.pool, self.spend):
         p.visible = anim.constant(1)
         s.visible = anim.constant(1)
     self.cost = Label("0", size=40, halign="center", background=True)
     self.select_mana = self.select_x = False
     self.layout()
Beispiel #4
0
 def __init__(self, pos=zero):
     super(ManaView, self).__init__(pos)
     self._pos.set_transition(dt=1.0, method="ease_out_circ")
     self.colors = ["white", "blue", "black", "red", "green", "colorless"]
     self.colormap = dict(zip(self.colors, "WUBRG"))
     self.nummana = len(self.colors)
     self.symbols = [ManaImage(color) for color in self.colors]
     self.pool = [Label("", size=20) for i in range(self.nummana)]
     self.values = dict([(c, v) for c, v in zip(self.colors, self.pool)])
     self.spend = [Label("0", size=30) for i in range(self.nummana)]
     self.spend_values = dict([(c, v)
                               for c, v in zip(self.colors, self.spend)])
     for p, s in zip(self.pool, self.spend):
         p.visible = anim.constant(1)
         s.visible = anim.constant(1)
     self.cost = Label("0", size=40, halign="center", background=True)
     self.select_mana = self.select_x = False
     self.layout()
Beispiel #5
0
 def __init__(self, gamecard, front, back):
     self.gamecard = gamecard
     self.front = front
     self.back = back
     self.hidden = False
     self.width, self.height = self.front.width, self.front.height
     self.size = anim.constant(1.0) 
     self._pos = AnimatedVector3(0,0,0)
     self.pos_transition = "ease_out_circ"
     self._orientation = AnimatedQuaternion()
     self.visible = anim.constant(1.0)
     self.alpha = anim.constant(1.0)
     if not Card.cardlist: Card.cardlist = self.build_displaylist(self.width, self.height)
     #self.renderwidth, self.renderheight = 736, 1050
     #self.renderwidth, self.renderheight = 368, 525
     #self.renderwidth, self.renderheight = 397, 553
     if not Card.fbo: Card.build_fbo()
     if not Card.renderlist: Card.renderlist = self.build_renderlist(self.renderwidth, self.renderheight)
Beispiel #6
0
 def __init__(self, text='', pos=zero):
     super(Button, self).__init__(pos)
     self._padding = 12
     self.toggled = False
     self.visible = anim.constant(1)
     self.label = pyglet.text.Label('', font_size=12, color=(0,0,0,255),
     #self.label = pyglet.text.Label(text, font_size=12, color=(255,255,255,255),
                                 anchor_x = "center", anchor_y = "center",
                                 x = 0, y = 0)
     self.set_text(text)
Beispiel #7
0
 def __init__(self, ctype, color=None):
     self.ctype = ctype
     if not color:
         color = [0, 0, 0]
         temp = hash(ctype) % 2**24
         color[0] = temp/2**16
         temp = temp % 2**16
         color[1] = temp/2**8
         color[2] = temp % 2**8
         self.color = (color[0] / 255.0, color[1] / 255.0, color[2] / 255.0)
     else: self.color = color
     self.size = anim.constant(1)
     self._pos = AnimatedVector3(0,0,0)
     self._orientation = AnimatedQuaternion()
     self.orientation = euclid.Quaternion.new_rotate_axis(pi, euclid.Vector3(0,0,1))
     self.visible = anim.constant(1.0)
     self.alpha = 0.9 #0.7 #anim.constant(1.0)
     cls = self.__class__
     if not cls.piece_list: self.build_piece_list(cls)
Beispiel #8
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 #9
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 #10
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 #11
0
 def __init__(self, gamecard, front, back):
     self.gamecard = gamecard
     self.front = front
     self.back = back
     self.hidden = False
     self.width, self.height = self.front.width, self.front.height
     self.size = anim.constant(1.0)
     self._pos = AnimatedVector3(0, 0, 0)
     self.pos_transition = "ease_out_circ"
     self._orientation = AnimatedQuaternion()
     self.visible = anim.constant(1.0)
     self.alpha = anim.constant(1.0)
     if not Card.cardlist:
         Card.cardlist = self.build_displaylist(self.width, self.height)
     #self.renderwidth, self.renderheight = 736, 1050
     #self.renderwidth, self.renderheight = 368, 525
     #self.renderwidth, self.renderheight = 397, 553
     if not Card.fbo: Card.build_fbo()
     if not Card.renderlist:
         Card.renderlist = self.build_renderlist(self.renderwidth,
                                                 self.renderheight)
Beispiel #12
0
 def __init__(self, ctype, color=None):
     self.ctype = ctype
     if not color:
         color = [0, 0, 0]
         temp = hash(ctype) % 2**24
         color[0] = temp / 2**16
         temp = temp % 2**16
         color[1] = temp / 2**8
         color[2] = temp % 2**8
         self.color = (color[0] / 255.0, color[1] / 255.0, color[2] / 255.0)
     else:
         self.color = color
     self.size = anim.constant(1)
     self._pos = AnimatedVector3(0, 0, 0)
     self._orientation = AnimatedQuaternion()
     self.orientation = euclid.Quaternion.new_rotate_axis(
         pi, euclid.Vector3(0, 0, 1))
     self.visible = anim.constant(1.0)
     self.alpha = 0.9  #0.7 #anim.constant(1.0)
     cls = self.__class__
     if not cls.piece_list: self.build_piece_list(cls)
Beispiel #13
0
 def __init__(self, pos=zero):
     super(SelectionList,self).__init__(pos)
     #self.options = []
     #self.alpha = anim.animate(0, 0.9, dt=1.0, method="sine")
     self.border = 20
     self.visible = anim.constant(0)
     #self.focus_idx = 0
     self.large_size = 17
     self.max_width = 700
     #self.small_scale = 0.35
     #self.intermediate_scale = 0.55
     #self.layout = self.layout_normal
     self.prompt = Label("", size=self.large_size, halign="center", shadow=False)
Beispiel #14
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 #15
0
 def __init__(self, text='', pos=zero):
     super(Button, self).__init__(pos)
     self._padding = 12
     self.toggled = False
     self.visible = anim.constant(1)
     self.label = pyglet.text.Label(
         '',
         font_size=12,
         color=(0, 0, 0, 255),
         #self.label = pyglet.text.Label(text, font_size=12, color=(255,255,255,255),
         anchor_x="center",
         anchor_y="center",
         x=0,
         y=0)
     self.set_text(text)
Beispiel #16
0
 def __init__(self, pos=zero):
     super(SelectionList, self).__init__(pos)
     #self.options = []
     #self.alpha = anim.animate(0, 0.9, dt=1.0, method="sine")
     self.border = 20
     self.visible = anim.constant(0)
     #self.focus_idx = 0
     self.large_size = 17
     self.max_width = 700
     #self.small_scale = 0.35
     #self.intermediate_scale = 0.55
     #self.layout = self.layout_normal
     self.prompt = Label("",
                         size=self.large_size,
                         halign="center",
                         shadow=False)
Beispiel #17
0
 def __init__(self, value, size=20, color=(1,1,1,1), shadow=True, halign="left", valign="bottom", background=False, pos=euclid.Vector3(0,0,0), border=False, width=None, fontname=None):
     super(Label,self).__init__(pos)
     self._fixed_width = width
     self._value = None
     self._color = color
     self.shadow = shadow
     self.halign = halign
     self.valign = valign
     self.background = background
     self.fontname = fontname if fontname else global_fontname
     self.size = size
     self.font = font.load(self.fontname, self.size, dpi=96)
     self.visible = anim.constant(1)
     self.render_border = border
     self.border = 5
     self.set_text(value)
Beispiel #18
0
 def set(self, Q):
     self.w = constant(Q.w)
     self.x = constant(Q.x)
     self.y = constant(Q.y)
     self.z = constant(Q.z)
Beispiel #19
0
 def set(self, V):
     self.x = constant(V.x)
     self.y = constant(V.y)
     self.z = constant(V.z)
Beispiel #20
0
 def set(self, Q):
     self.w = constant(Q.w)
     self.x = constant(Q.x)
     self.y = constant(Q.y)
     self.z = constant(Q.z)
Beispiel #21
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 #22
0
 def clear(self):
     self.symbols['life'].rotatey = anim.constant(0)
     status = self.values
     counters = ["life", "hand", "library", "graveyard", "exile"]
     for c in counters: status[c].set_text(0)
Beispiel #23
0
 def clear(self):
     self.symbols['life'].rotatey = anim.constant(0)
     status = self.values
     counters = ["life", "hand", "library", "graveyard", "exile"]
     for c in counters:
         status[c].set_text(0)
Beispiel #24
0
    def layout(self):
        life_img, life = self.symbols["life"], self.values["life"]
        life_img.alpha = anim.constant(0.3)
        life_img._final_scale = 0.25
        life_img._scale = anim.constant(life_img._final_scale)
        #life_img.visible = anim.constant(0)
        avatar = self.avatar
        spacing = self._spacing
        if self.is_opponent:
            x, y = spacing, life.height / 2.

            self.player_name.pos = euclid.Vector3(x, y, 0)
            self.manapool.pos = euclid.Vector3(self.width, 0, 0)
            x = self.width - life.width / 2 - spacing
            life.pos = life_img.pos = euclid.Vector3(x, y, 0)

            for i, status in enumerate(["graveyard", "library", "hand"]):
                symbol, value = self.symbols[status], self.values[status]
                #symbol.scale = 0.3
                #symbol.pos = value.pos = euclid.Vector3(x, life.height+spacing+symbol.height/2+0.7*i*(symbol.height), 0)
                symbol.pos = value.pos = euclid.Vector3(
                    x, life.height + spacing / 2 + symbol.height / 2 + i *
                    (symbol.height), 0)

            library, lib = self._library, self.symbols["library"]
            library.scale = 0.5
            library.pos = euclid.Vector3(
                self.width, life.height + spacing / 2 + 1.5 * lib.height, 0)
            #status = "library"
            #library, value = self.symbols["library"], self.values["library"]
            #library.scale = 0.3
            #library.pos = value.pos = euclid.Vector3(spacing + library.width/2, life.height+library.height/2+spacing,0)
            avatar.pos = euclid.Vector3(
                spacing + avatar.width / 2,
                life.height + avatar.height / 2 + spacing, 0)
        else:
            x, y = spacing, self.height - life.height / 2.

            self.player_name.pos = euclid.Vector3(x, y, 0)
            self.manapool.pos = euclid.Vector3(self.width, self.height, 0)
            x = self.width - life.width / 2 - spacing
            life.pos = life_img.pos = euclid.Vector3(x, y, 0)

            for i, status in enumerate(["graveyard", "library", "hand"][::-1]):
                symbol, value = self.symbols[status], self.values[status]
                #symbol.scale = 0.3
                #symbol.pos = value.pos = euclid.Vector3(x, self.height-life.height-symbol.height/2-0.7*i*(symbol.height), 0)
                symbol.pos = value.pos = euclid.Vector3(
                    x, self.height - life.height - symbol.height / 2 - i *
                    (symbol.height) - spacing / 2, 0)

            library, lib = self._library, self.symbols["library"]
            library.scale = 0.5
            library.pos = euclid.Vector3(self.width, 1.5 * lib.height, 0)
            #status = "library"
            #library, value = self.symbols["library"], self.values["library"]
            #library.scale = 0.3
            #library.pos = value.pos = euclid.Vector3(spacing + library.width/2, self.height-life.height-library.height/2-spacing,0)
            avatar.pos = euclid.Vector3(
                spacing + avatar.width / 2,
                self.height - life.height - avatar.height / 2 - spacing, 0)
Beispiel #25
0
 def set(self, V):
     self.x = constant(V.x)
     self.y = constant(V.y)
     self.z = constant(V.z)