def __init__(self, transition): self.transition = transition self.boundary = transition.boundary self.screenImage = screen.copy() self.nextImage = view.createRectangle(DIMENSIONS) self.playState = None self.ticks = 0
def initialiseMapImage(self): self.mapImage = view.createRectangle((self.cols * TILE_SIZE, self.rows * TILE_SIZE), view.BLACK) for tiles in self.mapTiles: for tile in tiles: tileImage = tile.createTileImage() if tileImage: self.mapImage.blit(tileImage, (tile.x * TILE_SIZE, tile.y * TILE_SIZE)) self.mapRect = self.mapImage.get_rect()
def __init__(self, playState): self.screenImage = screen.copy() self.nextImage = view.createRectangle(DIMENSIONS) self.playState = playState self.viewRect = player.viewRect.copy() self.viewRect.top = 0 self.ticks = 0 musicPlayer.longFadeoutCurrentTrack()
def initialiseMapImage(self): self.mapImage = view.createRectangle((self.cols * view.TILE_SIZE, self.rows * view.TILE_SIZE), view.BLACK) for x in range(self.cols): for y in range(self.rows): mapTile = self.mapTiles[x][y] if mapTile: tileImage = mapTile.createTileImage() if tileImage: self.mapImage.blit(tileImage, (x * view.TILE_SIZE, y * view.TILE_SIZE)) self.mapRect = self.mapImage.get_rect()
def createTileImage(self): if len(self.tiles) == 0: return None elif len(self.tiles) > 1: # if we're layering more than one image we don't want to draw on any of # the original images because that will affect every copy tileImage = view.createRectangle((TILE_SIZE, TILE_SIZE), view.BLACK) for image in self.tiles: tileImage.blit(image, (0, 0)) return tileImage return self.tiles[0]
def __init__(self): self.screenImage = screen.copy() self.topLine1 = gameFont.getTextImage("BRAVE ADVENTURER") self.topLine2 = gameFont.getTextImage("YOU ARE DEAD") self.topLine3 = gameFont.getTextImage("CONTINUE... 10") self.lowLine1 = gameFont.getTextImage("PRESS SPACE") self.lowLine2 = gameFont.getTextImage("TO PLAY AGAIN") self.blackRect = view.createRectangle(self.topLine3.get_size(), view.BLACK) self.continueOffered = True if registryHandler.snapshot.checkpoint else False self.countdown = None self.countdownTopleft = None self.ticks = 0
from events import MapTransitionEvent, EndGameEvent from fixedsprites import FixedCoin, CoinCount, KeyCount, Lives ORIGIN = (0, 0) X_MULT = VIEW_WIDTH // 64 Y_MULT = VIEW_HEIGHT // 64 DIMENSIONS = (VIEW_WIDTH, VIEW_HEIGHT) # number of frames required to bring the player into view from an off-screen position BOUNDARY_TICKS = {UP: 24, DOWN: 24, LEFT: 14, RIGHT: 14} DOORWAY_TICKS = {UP: 16, DOWN: 16, LEFT: 16, RIGHT: 16} pygame.display.set_caption("Ulmo's Adventure") screen = pygame.display.set_mode(DIMENSIONS) blackRect = view.createRectangle(DIMENSIONS) gameFont = font.GameFont() # globals eventBus = None registry = None soundHandler = None fixedSprites = None player = None def startGame(): global eventBus eventBus = EventBus() # create registry
RIGHT: 14 // VELOCITY } DOORWAY_TICKS = { UP: 16 // VELOCITY, DOWN: 16 // VELOCITY, LEFT: 16 // VELOCITY, RIGHT: 16 // VELOCITY } PLAYER_OFF_SCREEN_START = (-2, 27) PLAYER_ON_SCREEN_START = (7, 27) pygame.display.set_caption("Ulmo's Adventure") screen = pygame.display.set_mode(DIMENSIONS) blackRect = view.createRectangle(DIMENSIONS) gameFont = font.GameFont() titleFont = font.TitleFont() # globals eventBus = None soundHandler = None registryHandler = None musicPlayer = None fixedSprites = None player = None def setup(): global eventBus