def test_run(self): ccActManager.load("test_tile_scene.act.json") clock = pygame.time.Clock() time_passed = 0 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() ccActManager.step(time_passed) ccGlobals.get_renderer().fill((0, 0, 0)) ccActManager.draw() pygame.display.flip() time_passed = clock.tick(60)
def test_run(self): ccKeyEventHandler.load("test.keys.json") ccActManager.load("test_king_scene.act.json") clock = pygame.time.Clock() time_passed = 0 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() ccKeyEventHandler.update() self.update_scene_velocity() ccActManager.step(time_passed) ccGlobals.get_renderer().fill((0, 0, 0)) ccActManager.draw() pygame.display.flip() time_passed = clock.tick(ccGlobals.frame_rate)
def draw(self): contained_length = 0 start_row_index = abs(int(self.first_tile_pos / self.tile_width)) end_row_index = 2 + int((ccGlobals.size[0] / self.tile_width) + start_row_index) if end_row_index > len(self.map[0]): contained_length = end_row_index - len(self.map[0]) end_row_index = len(self.map[0]) for row in self.map: for index in range(start_row_index, end_row_index): row[index].draw(ccGlobals.get_renderer()) if self.looping is True: if contained_length != 0: for row in self.map: for index in range(0, contained_length): row[index].draw(ccGlobals.get_renderer())
def test_run(self): keylistener = ccKeyEventHandler() keylistener.load("test.keys.json") ccActManager.load("test.act.json") clock = pygame.time.Clock() time_passed = 0 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() for scene in ccActManager.scenes: for obj in scene.object_list: keylistener.update(obj) ccActManager.step(time_passed) ccGlobals.get_renderer().fill((0, 0, 0)) ccActManager.draw() pygame.display.flip() time_passed = clock.tick(30)
def draw(self): for obj in self.object_list: obj.draw(ccGlobals.get_renderer())
def __init__(self): pygame.init() ccGlobals.set_renderer(pygame.display.set_mode(ccGlobals.size)) self.renderer = ccGlobals.get_renderer()