本文整理汇总了Python中Camera.getPos方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.getPos方法的具体用法?Python Camera.getPos怎么用?Python Camera.getPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.getPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WhatABlockGame
# 需要导入模块: import Camera [as 别名]
# 或者: from Camera import getPos [as 别名]
class WhatABlockGame(object):
WINDOW_SIZE = Vector2(1366, 768)
Clock = 0
isGameOver = False
folderDir = ''
assetDir = ''
bgImage = ''
cam = ''
mapCollection = ''
player = ''
inputManager = ''
myRFIDReader = ''
player_revealver = ''
bgSound = ''
def __init__(self, WINDOW_SIZE):
self.WINDOW_SIZE = Vector2(1366, 768)
self.isGameOver = False
self.playWithRFID = True
self.folderDir = os.path.split(os.getcwd())[0]
self.assetDir = self.folderDir + '/Assets/'
self.inputManager = InputManager()
if self.playWithRFID:
self.myRFIDReader = RFIDReader()
self.inputManager.setRFIDInput(self.myRFIDReader)
pygame.init()
self.clock = pygame.time.Clock()
self.display = pygame.display.set_mode((self.WINDOW_SIZE.getX(), self.WINDOW_SIZE.getY()), pygame.FULLSCREEN)
pygame.display.set_caption('What A Block')
self.loadAssets()
self.cam = Camera(offSet = Vector2(self.WINDOW_SIZE.getX()/2 , self.WINDOW_SIZE.getY()/2 - self.player.getHeight()/2), camSize = self.WINDOW_SIZE)
self.player_revealver = Revealer(IsoToScreen(self.player.getIsoPos(), self.mapCollection.getBlockSize().getX(), self.mapCollection.getBlockSize().getY()), 60)
pygame.mixer.music.play(-1)
def loadAssets(self):
pygame.mixer.music.load(self.assetDir + 'bgSound.mp3')
self.mapCollection = MapCollection(currentMap = 0, assetDir = self.assetDir, WINDOW_SIZE = self.WINDOW_SIZE)
self.player = Player(self.mapCollection.getCurrentMapObject().getPlayerStartPos(), assetDir = self.assetDir, blockWidth = self.mapCollection.getBlockSize().getX(), blockHeight = self.mapCollection.getBlockSize().getY(), moveSpeed = 0.1)
self.mainFontSize = 50
self.secondFontSize = 30
self.thirdFontSize = 18
self.mainFont = pygame.font.Font(self.assetDir + "Universe.ttf", self.mainFontSize)
self.secondFont = pygame.font.Font(self.assetDir + "Universe.ttf", self.secondFontSize)
self.thirdFont = pygame.font.Font(self.assetDir + "Universe.ttf", self.thirdFontSize)
self.numberOfDeath = 0
def render(self):
#sent player into map for order of rendering purpose
self.mapCollection.renderCurrentMap(self.display, camPos = self.cam.getPos(), player = self.player)
self.renderGUI()
pygame.display.flip()
def renderGUI(self):
levelText = str(self.mapCollection.getCurrentMapIndex()) #Level
renderlevelText = self.thirdFont.render( levelText, 1, (255,255,255))
self.display.blit(renderlevelText, (self.WINDOW_SIZE.getX()/2 - len(levelText) * self.thirdFontSize/2 + 5, self.WINDOW_SIZE.getY()*8.3/20))
deathCountText = str(self.numberOfDeath) #Death
renderDeathCountText = self.mainFont.render( deathCountText, 1, (0,0,0))
self.display.blit(renderDeathCountText, (self.WINDOW_SIZE.getX()/2 - len(deathCountText) * self.mainFontSize/2 + 10, self.WINDOW_SIZE.getY()/9))
bombCountText = str(self.player.getBomb()) #Bomb
renderBombCountText = self.secondFont.render( bombCountText, 1, (127,100,0))
self.display.blit(renderBombCountText, (self.WINDOW_SIZE.getX()*9/20 - len(deathCountText) * self.secondFontSize/2 + 10, self.WINDOW_SIZE.getY()*17/20))
bulletCountText = str(self.player.getBullet()) #Bullet
renderBulletCountText = self.secondFont.render( bulletCountText, 1, (127,100,0))
self.display.blit(renderBulletCountText, (self.WINDOW_SIZE.getX()*11/20 - len(deathCountText) * self.secondFontSize/2 + 10, self.WINDOW_SIZE.getY()*17/20))
def update(self):
self.inputs()
self.player.update(isoBlocks = self.mapCollection.getCurrentMapObject().getBlocks())
self.player_revealver.setPos(self.player.getScreenPos())
self.player_revealver.reveal(isoBlocks = self.mapCollection.getCurrentMapObject().getBlocks())
self.checkPlayerFall()
self.checkPlayerFallOut()
#.........这里部分代码省略.........