示例#1
0
    if len(full_output)>0:
        msg = { 'update' : full_output }
        for h in handlers:
            h.do_send(msg)
    
            
    
        

for i in range(0, num_walls):
    x = random.randint(400, 3200)
    y = random.randint(400, 1800)
    w = random.randint(100, 200)
    h = random.randint(100, 200)
    logic.wall_list.append(pygame.Rect(x, y, w, h))
    
logic.wall_list.append(pygame.Rect(0, 0, map_dimensions[0], 25))
logic.wall_list.append(pygame.Rect(0, 0, 25, map_dimensions[1]))
logic.wall_list.append(pygame.Rect(0, map_dimensions[1]-25, map_dimensions[0], 25))
logic.wall_list.append(pygame.Rect(map_dimensions[0]-25, 0, 25, map_dimensions[1]))

port = 8888
server = Listener(port, MyHandler)
clock = pygame.time.Clock()
while 1:
    clock.tick(TICKS)
    logic.doLogic()
    poll_events()
#     event_log.bullet_deaths = []
#     event_log.ship_deaths = []
    poll(timeout=0.0125) # in seconds
示例#2
0
    x = random.randint(player_ship.location[0], 3200 - player_ship.location[0])
    y = random.randint(player_ship.location[1], 1800 - player_ship.location[1])
    w = random.randint(100, 200)
    h = random.randint(100, 200)
    logic.wall_list.append(pygame.Rect(x, y, w, h))

logic.wall_list.append(pygame.Rect(0, 0, map_dimensions[0], 25))
logic.wall_list.append(pygame.Rect(0, 0, 25, map_dimensions[1]))
logic.wall_list.append(
    pygame.Rect(0, map_dimensions[1] - 25, map_dimensions[0], 25))
logic.wall_list.append(
    pygame.Rect(map_dimensions[0] - 25, 0, 25, map_dimensions[1]))

view.wall_list = logic.wall_list
view.bullet_list = logic.bullet_list
view.ship_list = logic.ship_list

clock = pygame.time.Clock()

while 1:
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == QUIT:
            exit()
    logic.doLogic()
    read_input(controller.move_ship, controller.turn_left,
               controller.turn_right, controller.shoot, controller.shield_on)
    for bot in botControllers:
        bot()
    view.set_camera_loc(player_ship.location)
    view.draw_everything()