def drawlives(self, lives, fast=0): if lives < 0: lives = 0 dest = self.drawsurface offset = self.drawoffset if not fast: r = pygame.Rect(self.poslives, self.imglives.get_size()) r2 = dest.blit(self.imghud1, r, r).move(offset) else: r2 = None if self.lastlives != lives: self.lastlives = lives size = miniship.get_size() self.imglives = pygame.Surface((size[0] * lives + 1, size[1])) if lives <= 3: #ships for l in range(lives): self.imglives.blit(miniship, (size[0] * l, 0)) else: #ships and num self.imglives.blit(miniship, (4, 0)) pos = size[0] + 10, 0 txt = 'x %d' % lives txt, pos = livesfont.text((150, 200, 150), txt, pos, 'topleft') self.imglives.blit(txt, pos) self.imglives.set_colorkey(0, pygame.RLEACCEL) r1 = dest.blit(self.imglives, self.poslives).move(offset) gfx.dirty2(r1, r2)
def drawlives(self, lives, fast=0): if lives < 0: lives = 0 dest = self.drawsurface offset = self.drawoffset if not fast: r = pygame.Rect(self.poslives, self.imglives.get_size()) r2 = dest.blit(self.imghud1, r, r).move(offset) else: r2 = None if self.lastlives != lives: self.lastlives = lives size = miniship.get_size() self.imglives = pygame.Surface((size[0]*lives+1, size[1])) if lives <= 3: #ships for l in range(lives): self.imglives.blit(miniship, (size[0]*l, 0)) else: #ships and num self.imglives.blit(miniship, (4, 0)) pos = size[0]+10, 0 txt = 'x %d'%lives txt,pos = livesfont.text((150,200,150), txt, pos, 'topleft') self.imglives.blit(txt, pos) self.imglives.set_colorkey(0, pygame.RLEACCEL) r1 = dest.blit(self.imglives, self.poslives).move(offset) gfx.dirty2(r1, r2)
def run(self): self.clocks += 1 self.cleartext() if self.thread and (not self.thread.isAlive() and self.success): self.download_finished() clearme = None if self.lastdownrect: gfx.dirty(self.background(self.lastdownrect)) clearme = self.lastdownrect self.lastdownrect = None r = self.background(self.shipimage[1]) gfx.dirty(r) gfx.updatestars(self.background, gfx) if not self.done: for img, r in self.images: gfx.dirty(gfx.surface.blit(img, r)) downimg, downrect = self.downimg() if downimg: self.lastdownrect = gfx.surface.blit(downimg, downrect) gfx.dirty2(self.lastdownrect, clearme) for text, pos in self.imgs: gfx.surface.blit(text, pos) else: for img, r in self.images: gfx.dirty(self.background(r)) gfx.dirty(clearme) if not self.done: self.drawlist() self.moveship() r = gfx.surface.blit(self.shipimage[0], self.shipimage[1]) gfx.dirty(r) for b in self.boxes: b.erase(self.background) b.tick(1.0) b.draw(gfx) else: #game.handler = self.prevhandler for b in self.boxes: b.erase(self.background) self.clearlist() if self.launchthebrowser: #we do it like this so the window can get #unfullscreened and not minimized on windows self.launchthebrowser -= 1 if not self.launchthebrowser: webbrowser.open(game.site_url, 1, 1)
def draw(self, gfx): frame = int(self.frame-1.0) % self.numframes img = darkimages[frame] r2 = gfx.surface.blit(img, self.rect.move(-self.move[0]*2, -self.move[1]*2)) frame = int(self.frame) % self.numframes img = allimages[glowset][frame] r1 = gfx.surface.blit(img, self.rect) r = r1.union(r2) gfx.dirty2(r, self.lastrect) self.lastrect = r
def draw(self, gfx): if not self.active: return if not self.dead: if type(self.images) == list: frame = int(self.frame) % self.numframes gfx.surface.blit(self.images[frame], self.rect) else: gfx.surface.blit(self.images, self.rect) gfx.dirty2(self.rect, self.lastrect) self.lastrect = Rect(self.rect)
def draw(self, gfx): if not self.dead: img = None if type(self.image) == list: frame = int(self.frame) % len(self.image) img = self.image[frame] else: img = self.image self.drawsurface.blit(img, self.rect) gfx.dirty2(self.rect, self.lastrect) self.lastrect = Rect(self.rect)
def draw(self, gfx): frame = int(self.frame) % 4 if self.shield: gfx.surface.blit(shieldbg[self.shield-1], self.rect) elif self.bullet: gfx.surface.blit(bulletbg[self.bullet-1], self.rect) if self.unmoved: img = upimage else: img = shipimages[self.image + (self.turbo*4)][frame] gfx.surface.blit(img, self.rect) gfx.dirty2(self.rect, self.lastrect) self.lastrect = pygame.Rect(self.rect)
def draw(self, gfx): frame = int(self.frame) % 4 if self.shield: gfx.surface.blit(shieldbg[self.shield - 1], self.rect) elif self.bullet: gfx.surface.blit(bulletbg[self.bullet - 1], self.rect) if self.unmoved: img = upimage else: img = shipimages[self.image + (self.turbo * 4)][frame] gfx.surface.blit(img, self.rect) gfx.dirty2(self.rect, self.lastrect) self.lastrect = Rect(self.rect)
def drawlevel(self, level, fast=0): dest = self.drawsurface offset = self.drawoffset if not fast: r = self.poslevel r2 = dest.blit(self.imghud1, r, r).move(offset) else: r2 = None if self.lastlevel != level: self.lastlevel = level self.imglevel = score.render(level) self.poslevel = self.imglevel.get_rect() self.poslevel.center = 50, 565 r1 = dest.blit(self.imglevel, self.poslevel).move(offset) gfx.dirty2(r1, r2)
def draw(self, gfx): if not self.active: r = self.drawsurface.fill((0, 67, 171), self.rect) gfx.dirty(r) else: if not self.dead: img = None frame = int(self.frame) % 3 if self.shield: img = shieldbg[self.shield - 1] else: img = self.image[frame] self.drawsurface.blit(img, self.rect) gfx.dirty2(self.rect, self.lastrect) self.lastrect = Rect(self.rect)
def draw(self, gfx): if not self.active: r = self.drawsurface.fill((0, 67, 171), self.rect) gfx.dirty(r) else: if not self.dead: img = None frame = int(self.frame) % 3 if self.shield: img = shieldbg[self.shield-1] else: img = self.image[frame] self.drawsurface.blit(img, self.rect) gfx.dirty2(self.rect, self.lastrect) self.lastrect = Rect(self.rect)
def drawitem(self, item, selected): """ Desenha um item do menu. Parametros: item - item do menu a desenhar. selected - item esta selecionado. """ if not selected: gfx.surface.blit(item.img, item.rect) gfx.dirty(item.rect) else: gfx.surface.blit(item.img, item.rect) gfx.dirty(item.rect) gfx.surface.blit(self.select, self.selectrect) self.last_selectrect = Rect(self.selectrect) gfx.dirty2(self.selectrect, self.last_selectrect)
def draw(self): """ Desenha o mapa. """ #Desenha cada tile ativo. for tile in self.tiles: if tile.dead: self.tiles.remove(tile) else: blue_background.fill((0, 67, 171), tile.lastrect) blue_background.blit(tile.image, tile.rect) gfx.surface.blit(blue_background, self.rect) gfx.dirty2(self.rect, self.lastrect) self.lastrect = Rect(self.rect)
def cleanup(self): """ Limpa o mapa. """ blue_background.fill((0, 67, 171)) gfx.surface.blit(blue_background, self.rect) gfx.dirty2(self.rect, self.lastrect) self.lastrect = Rect(self.rect)
def drawlevel(self, level): """ Desenha o nivel atual do jogo. Parametros: level - nivel atual do jogo. """ dest = self.drawsurface offset = self.drawoffset if not fast: r = self.poslevel r2 = dest.blit(self.imghud1, r, r).move(offset) else: r2 = None if self.lastlevel != level: self.lastlevel = level self.imglevel = score.render(level) self.poslevel = self.imglevel.get_rect() self.poslevel.center = 50, 565 r1 = dest.blit(self.imglevel, self.poslevel).move(offset) gfx.dirty2(r1, r2)
def draw(self, gfx): frame = min(int(self.clocks // CLOCK_MULTIPLIER), len(self.images) - 1) img = images[frame] r = gfx.surface.blit(img, self.rect) gfx.dirty2(r, self.lastrect) self.lastrect = r
def draw(self, gfx): img = images[int(self.time)] r = gfx.surface.blit(img, self.rect) gfx.dirty2(r, self.lastrect) self.lastrect = r
def draw(self, gfx): if not self.killed: img = self.images[self.frame] r = gfx.surface.blit(img, self.rect) gfx.dirty2(r, self.lastrect) self.lastrect = r
def draw(self, gfx): frame = min(int(self.clocks/CLOCK_MULTIPLIER), len(self.images)-1) img = images[frame] r = gfx.surface.blit(img, self.rect) gfx.dirty2(r, self.lastrect) self.lastrect = r