We initialize the pygame module, create a screen and load resources (images etc.) in order to create the entities involved in the game. All entities are placed in a list, which we call world. At last, the game loop can be started using this list. ''' tank1 = ai.AIBot(100, 500, pygame.image.load("tank1.gif"), pygame.image.load("tank1_top.gif"), KEY_BINDINGS_1) tank2 = Tank(700, 100, pygame.image.load("tank2.gif"), pygame.image.load("tank2_top.gif"), KEY_BINDINGS_2) #input_listener.append(tank1) input_listener.append(tank2) base1 = Base(100, 500, pygame.image.load("base.gif"), tank1) base2 = Base(700, 100, pygame.image.load("base.gif"), tank2) img = pygame.image.load('dirt.jpg') img = pygame.transform.scale(img, (WIDTH, HEIGHT)) world = [] world.append(base1) world.append(base2) world.append(tank1) world.append(tank2) world = [[e.priority, e] for e in world] tank1.set_world(world) tank2.set_world(world) game_loop(tank1, tank2, world)
resources (images etc.) in order to create the entities involved in the game. All entities are placed in a list, which we call world. At last, the game loop can be started using this list. ''' pygame.init() size = WIDTH, HEIGHT screen = pygame.display.set_mode(size) tank1 = ai.AIBot(100, 500, pygame.image.load("tank1.gif"), pygame.image.load("tank1_top.gif"), KEY_BINDINGS_1) tank2 = Tank(700, 100, pygame.image.load("tank2.gif"), pygame.image.load("tank2_top.gif"), KEY_BINDINGS_2) #input_listener.append(tank1) input_listener.append(tank2) base1 = Base(100, 500, pygame.image.load("base.gif"), tank1) base2 = Base(700, 100, pygame.image.load("base.gif"), tank2) background_img = pygame.image.load('dirt.jpg') background_img = pygame.transform.scale(background_img, size) missile_img = pygame.image.load("missile.gif") Missile.missile_img = missile_img world = [base1, base2, tank1, tank2] tank1.set_world(world) tank2.set_world(world) game_loop(tank1, tank2, world)