def test_blit(self): """quadratic image is shown, then cleared.""" screen = Screen(RESOLUTION, BACKGROUND_IMAGE) bitmap = pygame.image.load(TILE).convert() dest = pygame.Rect(60, 60, 32, 32) source = pygame.Rect(0, 0, 32, 32) screen.blit(bitmap, dest, source) next_frame() screen.clear()
def test_blit(self, tile_bitmap): """quadratic image is shown, then cleared.""" screen = Screen() dest = pygame.Rect(60, 60, 32, 32) source = pygame.Rect(0, 0, 32, 32) screen.blit(tile_bitmap, dest, source) next_frame() screen.clear()
self.steps -= 1 if self.steps <= 0: self.finished = True if self.callback: self.callback() def draw(self): self.tile.draw(self.frame, self.current_vector) def wait_for_move(move, screen=None, draw=None, delay=0.01): while not move.finished: if screen: screen.clear() move.move() if draw: draw() move.draw() pygame.display.update() time.sleep(delay) if __name__ == '__main__': screen = Screen(Vector(800, 520), '../lightsouls/data/background.png') frame = Frame(screen, Rect(64, 64, 320, 320)) tile_factory = TileFactory('../lightsouls/data/tiles.conf') pac = tile_factory.get('b.pac_right') move = Move(frame, pac, Vector(50, 50), RIGHT * 2, 200) wait_for_move(move, screen) time.sleep(1)
def zeichnen(self, screen, tiles): '''Auf dem Bildschirm anzeigen''' tile = tiles.get(self.name.lower()) tile.draw(screen, (self.position[0] + 300, self.position[1] + 200)) def simulieren(planeten, screen, tf): screen.clear() sonne = planeten[0] planeten = planeten[1:] for p in planeten: p.bewegen() p.zeichnen(screen, tf) p.anziehungskraft(sonne) sonne.zeichnen(screen, tf) pygame.display.update() time.sleep(VERZOEGERUNG) sc = Screen() tf = TileFactory() planeten = [ Planet("Sonne", 0.0, 0.0, 0.0, 0.0, 300000000.0), Planet("Erde", 0.0, 100.0, 2.17601657851805, 0.0, 1.0), Planet("Venus", 0.0, 60.0, -5.91572020809202436808504899092, 0.0, 1.0) ] while True: simulieren(planeten, sc, tf)
self.map.set_map(self.tile_name * self.value) self.frame.clear() self.map.draw() def increase(self): self.value += 1 self.redraw() def decrease(self): if self.value > 0: self.value -= 1 self.redraw() if __name__ == '__main__': screen = Screen() tile_factory = TileFactory() frame = Frame(screen, Rect(96, 64, 640, 32)) bananas = BarDisplay(frame, tile_factory, 0, 'b', False) frame = Frame(screen, Rect(64, 64, 32, 320)) cherries = BarDisplay(frame, tile_factory, 10, 'c', True) for i in range(15): pygame.display.update() time.sleep(0.1) # screen.clear() bananas.increase() cherries.decrease() pygame.display.update() for i in range(15): pygame.display.update() time.sleep(0.1)
self.frame.clear() self.map.draw() def increase(self): self.value += 1 self.redraw() def decrease(self): if self.value > 0: self.value -= 1 self.redraw() if __name__ == '__main__': screen = Screen(Vector(800,550), '../lightsouls/data/background.png') tile_factory = TileFactory('../lightsouls/data/tiles.conf') frame = Frame(screen, Rect(96, 64, 640, 32)) bananas = BarDisplay(frame, tile_factory, 0, 'b', False) frame = Frame(screen, Rect(64, 64, 32, 320)) cherries = BarDisplay(frame, tile_factory, 10, 'c', True) for i in range(15): pygame.display.update() time.sleep(0.1) #screen.clear() bananas.increase() cherries.decrease() pygame.display.update() for i in range(15): pygame.display.update() time.sleep(0.1)
def test_clear(self): """Screen can be cleared.""" screen = Screen(RESOLUTION, BACKGROUND_IMAGE) screen.clear()
def test_clear(self): """Screen can be cleared.""" screen = Screen() screen.clear()