def initiateMassExplosion(self): for i in range(self.rc[0]): for j in range(self.rc[1]): xy = self.indexToXY([i, j]) mdl.gif(explosionGif, xy, self.subWH, self.batch, self.group + gExp, oneTime=True) glb.Aud.massExplosion.play()
def explodeAt(self, ind): i = max(ind) if self.explodedAt[i]: return False xy = self.indexToXY(ind) mdl.gif(explosionGif, xy, self.subWH, self.batch, self.group + gExp, oneTime=True) mdl.gif(smokeGif, xy, self.subWH, self.batch, self.group + gSmoke) glb.Aud.explosion.play() self.health -= 1 self.explodedAt[i] = True return True
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()
def setPlayer(self, playerName, onConfirm): self.onConfirm = onConfirm self.batch = pyGra.Batch() self.ocean = mdl.gif(oceanBG, [0, 0], glb.wh, self.batch, gOcean) topPanelWHPerc = [30, 100] self.sidePanel = sp.SidePanel( playerName, whPercent=topPanelWHPerc, optionList=[['Place your ships'], ['Drag : To move'], ['Right click : '], [' To Rotate'], [], ['Confirm', self.setupConfirmSeq], ['Cancel', Menu.display]], batch=self.batch, group=gSidePanel) remainingWH = [reduceTo(glb.wh[0], 100 - topPanelWHPerc[0]), glb.wh[1]] wh = [600, 600] x = glb.wh[0] - remainingWH[0] + (remainingWH[0] - wh[0]) // 2 y = (glb.wh[1] - wh[1]) // 2 return Player.Player([x, y], wh, batch=self.batch, group=gPlayer)
def setBG( self, bg ) : if bg : mdl.gif( bg, [0,0], glb.wh, self.batch, self.group + gBG )