コード例 #1
0
    def setBattleField(self, playerArchive, playerInd, header):
        self._status = PLAYING
        self.batch = pyGra.Batch()
        self.ocean = mdl.gif(oceanBG, [0, 0], glb.wh, self.batch, gOcean)

        # Top Panel
        topPanelXY = [0, reduceTo(glb.wh[1], 90)]
        topPanelWH = [glb.wh[0], glb.wh[1] - topPanelXY[1]]
        mdl.quad(topPanelXY,
                 topPanelWH, [0, 0, 0, 120],
                 self.batch,
                 group=gTopPanel,
                 blend=True)
        self.topPanelXY = topPanelXY

        # Divider
        dividerWH = [15, topPanelXY[1]]
        dividerXY = [int(topPanelWH[0] / 2 - dividerWH[0] / 2), 0]
        mdl.quad(dividerXY,
                 dividerWH, [0, 0, 0, 120],
                 self.batch,
                 group=gTopPanel,
                 blend=True)

        self.setPlayerLayout(0, header[0], topPanelXY, topPanelWH)
        self.setPlayerLayout(1, header[1], topPanelXY, topPanelWH)

        self.extractPlayer1(playerArchive[0])
        self.extractPlayer2(playerArchive[1])

        self.setPlayerTurn(playerInd)
        glb.Aud.gameplay()
コード例 #2
0
    def setPlayerLayout(self, ind, playerName, topPanelXY, topPanelWH):
        baseWH = [600, 600]
        remainingSubWidth = (glb.wh[0] - baseWH[0] * 2) // 4
        if ind: pXY = [remainingSubWidth * 3 + baseWH[0], 10]
        else: pXY = [remainingSubWidth, 10]

        quadXY = [pXY[0], topPanelXY[1]]
        quadWH = [reduceTo(baseWH[0], 50), topPanelWH[1]]
        mdl.label(quadXY,
                  quadWH,
                  playerName,
                  51,
                  batch=self.batch,
                  group=gHeaderText,
                  xyPercInside=[10, 30])
        mdl.quad(quadXY,
                 quadWH, [0, 159, 217, 150],
                 self.batch,
                 group=gHeaderQuad,
                 blend=True)

        lblXY = [quadXY[0] + quadWH[0] + 20, quadXY[1]]
        self.turnLbl[ind] = mdl.label(lblXY,
                                      quadWH,
                                      'Turn !',
                                      51,
                                      batch=self.batch,
                                      group=gHeaderText,
                                      xyPercInside=[10, 30])
        self.lblSize = self.turnLbl[ind].font_size
        self.player[ind] = Player.Player(pXY,
                                         baseWH,
                                         batch=self.batch,
                                         group=gPlayer)
コード例 #3
0
 def setFader(self, ind):
     if self.fadeQuad: self.fadeQuad.delete()
     qXY = self.player[ind].xy
     qWH = self.player[ind].wh
     self.fadeQuad = mdl.quad(qXY,
                              qWH, [0, 0, 0, 150],
                              self.batch,
                              Player.gShip,
                              blend=True)
コード例 #4
0
ファイル: GameModel.py プロジェクト: NeuronEnix/Battleship
 def s_highlightFullQuad(self, quadColor):
     self.fullQuad = glb.delIf(self.fullQuad)
     self.fullQuadColor = quadColor
     if self.fullQuadColor:
         self.fullQuad = mdl.quad(self.xy,
                                  self.wh,
                                  quadColor,
                                  self.batch,
                                  self.group,
                                  blend=True)
     self.batch.invalidate()
コード例 #5
0
    def victoryStuffs(self):
        self._status = VICTORY
        self.turnLbl[self.ind].text = 'Victory !'
        self.player[self.ind].makeShipsVisible()
        self.player[not self.ind].makeShipsVisible()

        pXY = self.player[self.ind].xy
        pWH = self.player[self.ind].wh
        wh = [reduceTo(pWH[0], 50), self.topPanelXY[1] - pXY[1] - pWH[1] - 10]
        xy = [(glb.wh[0] - wh[0]) // 2, pXY[1] + pWH[1] + 5]

        self.mainMenuButton = GameModel.GameModel(xy,
                                                  wh, [1, 1],
                                                  self.batch,
                                                  gPlayer,
                                                  mouseOverAud=True)
        mXY = self.mainMenuButton.xy
        mWH = self.mainMenuButton.wh

        mdl.quad(mXY,
                 mWH, [0, 159, 217, 180],
                 self.batch,
                 gFullQuad,
                 blend=True)
        mdl.quad([0, 0],
                 glb.wh, [0, 0, 0, 150],
                 self.batch,
                 gFullQuad,
                 blend=True)

        wh[1] = reduceTo(wh[1], 85)
        mdl.label(xy,
                  wh,
                  'Main Menu',
                  size=49,
                  batch=self.batch,
                  group=gHeaderText,
                  xyPercInside=[5, 20])
コード例 #6
0
ファイル: GameModel.py プロジェクト: NeuronEnix/Battleship
 def highlightQuadAtXY(self, xy, quadColor, highlight=True):
     if highlight and self.inside(xy):
         ind = self.XYToIndex(xy)
         if self.prevQuadInd != ind:
             self.subQuad = glb.delIf(self.subQuad)
             xy = self.indexToXY(ind)
             self.prevQuadInd = list(ind)
             self.subQuad = mdl.quad(xy,
                                     self.subWH,
                                     quadColor,
                                     self.batch,
                                     self.group,
                                     blend=True)
             self.batch.invalidate()
             if self.mouseOverAud: glb.Aud.mouseOver.play()
     else:
         self.subQuad = glb.delIf(self.subQuad)
         self.prevQuadInd = [-1, -1]
コード例 #7
0
ファイル: SidePanel.py プロジェクト: NeuronEnix/Battleship
 def dispCaretAt( self, lbl ) :
     xy = [ lbl.x + lbl.content_width, lbl.y ]
     self.delCaret(); self.caret = mdl.quad( xy, [10,5], color[ CARET ], self.batch, self.group + gText )
コード例 #8
0
ファイル: SidePanel.py プロジェクト: NeuronEnix/Battleship
 def setHeader( self, text, quadColor ) :
     self.headerXY = xy = [0, reduceTo( self.sidePanelWH[1], 80) ]
     wh = [ self.sidePanelWH[0], reduceTo( self.sidePanelWH[1], 12) ]
     mdl.quad( xy, wh, quadColor, self.batch, self.group + gQuad, blend = True )
     wh[1] = reduceTo( wh[1], 90 ) 
     self.headerLbl = mdl.label( xy, wh, text, size = 54, batch = self.batch, group = self.group + gText , xyPercInside = [4,25] )
コード例 #9
0
ファイル: SidePanel.py プロジェクト: NeuronEnix/Battleship
 def setSidePanel( self, color, fullScreenBlend ) :
     if fullScreenBlend : SidePanelWH = glb.wh
     else : SidePanelWH = self.sidePanelWH
     mdl.quad( [0,0], SidePanelWH, color, self.batch, self.group + gSidePanel , blend = True )