def levelthree (): flags = FULLSCREEN | DOUBLEBUF pygame.init() #define colors black = (0,0,0) white = (255,255,255) red = (255,0,0) lightBlue = (180,180,225) darkBlue = (141,138,186) darkerBlue = (114,111,161) #defining screen width, height = 1200,600 screen = pygame.display.set_mode((width, height),flags) hideSpeech = True truevar = True clock = pygame.time.Clock() lockers = pygame.image.load("pics/lvl-bgs/full_lockers.png").convert() school_door = pygame.image.load("pics/lvl-bgs/kitchen_door.png") block_rect = pygame.Rect(950, 200, 200, 335) player= Cat() dialogue = pygame.font.Font('fonts/livvic/livvic-medium.ttf', 20) TextSurf_n, TextRect_n = text_objects2("Let's get to class!", dialogue) TextRect_n.center = (375,80) TextSurf_n1, TextRect_n1 = text_objects("Press enter to interact with objects.", dialogue) TextRect_n1.center = (900,560) next = 0 text_box = pygame.image.load("pics/teal_rect.png") text_box.set_alpha(200) text_box = pygame.transform.scale(text_box, (width,150)) player.rect.x = 0 while truevar: mouse = pygame.mouse.get_pos() click = pygame.mouse.get_pressed() screen.blit(lockers, (0,0)) # block = pygame.draw.rect(screen, (0,0,0), block_rect) screen.blit(player.image, player.rect) player.update() key = pygame.key.get_pressed() if key[pygame.K_LEFT]: player.move(-2) player.image = pygame.image.load("KIT_KAT/kitkat_left2.png") if key[pygame.K_RIGHT]: player.move(2) player.image = pygame.image.load("KIT_KAT/kitkat_right2.png") if key[pygame.K_UP]: player.jump() if key[pygame.K_RETURN]: if player.rect.x >900 and player.rect.x <1100: truevar = False maze.main() screen.blit(text_box,(0,0)) if next == 0: screen.blit(TextSurf_n,TextRect_n) screen.blit(TextSurf_n1,TextRect_n1) clock.tick(200) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit(0) elif event.type == KEYDOWN: if event.key == K_ESCAPE: pygame.quit() exit(0) elif event.key == K_KP_ENTER: pygame.quit() exit(0) elif event.type == pygame.MOUSEBUTTONDOWN: click_img = event.pos
import maze import sys if len(sys.argv) > 1: runs = int(sys.argv[1]) else: print('\nUsage: python simulation.py <number_of_runs>\n') sys.exit(1) captured = 0 min = 1000 max = 0 avg = [] for i in range(0, runs): result = maze.main() if result[1] == False: if result[0] < min: min = result[0] elif result[0] > max: max = result[0] avg.append(result[0]) else: captured += 1 print( '\n# of steps with {0} runs\nMinimum: {1}\nMaximum: {2}\nAverage: {3}\nCaptured: {4}' .format(runs, min, max, sum(avg) / runs, captured))
import maze maze.main()
def _test_maze_result(input, expected): _stdout = StringIO() maze.main(_stdin=StringIO(input), _stdout=_stdout) assert_equal(_stdout.getvalue(), expected)
Map.draw_chip(x, y, m[y][x]) def draw_mini_map(self): W = pyxel.width size = self.MINI_MAP_SIZE for j, (arr, vj) in enumerate(zip(self.map.map, self.visited)): for i, (col, v) in enumerate(zip(arr[::-1], vj[::-1])): if not v: continue x = W - (i+1) * size y = j * size pyxel.rect(x, y, size, size, col) pyxel.rectb(x, y, size, size, pyxel.COLOR_DARKGRAY) # event def game_clear(self): H = pyxel.height pyxel.text(5, H - 20, "YOU WIN!!", pyxel.COLOR_YELLOW) pyxel.show() def game_over(self): H = pyxel.height pyxel.text(5, H - 20, "YOU Lose...", pyxel.COLOR_YELLOW) pyxel.show() if __name__ == "__main__": maze.main() App()