MASS = 1.0 MAX_SPEED = 100 # pixels / second MAX_FORCE = 200 # pixels / second^2 MAX_TURN_RATE = 100 # degrees / second INIT_VEL = Vector2(100,0) world = GameWorld(WIDTH,HEIGHT) # main Vehicle leader = Vehicle(world=world, \ center=(WIDTH*0.5,HEIGHT*0.5), \ mass=MASS, \ max_speed=MAX_SPEED, \ max_force=MAX_FORCE, \ max_turn_rate=MAX_TURN_RATE, \ vel= 0.5 * INIT_VEL, color='purple') follower = Vehicle(world=world, \ center=(WIDTH*0.5,HEIGHT*0.15), \ mass=MASS, \ max_speed=MAX_SPEED, \ max_force=MAX_FORCE, \ max_turn_rate=MAX_TURN_RATE, \ vel= INIT_VEL) def start(): follower.offset_pursuit_on();
HEIGHT = 600 MASS = 1.0 MAX_SPEED = 50 # pixels / second MAX_FORCE = 500 # pixels / second^2 MAX_TURN_RATE = 50 # degrees / second INIT_VEL = (20, 5) BEHAVIOR = Behavior.WANDER world = GameWorld(WIDTH, HEIGHT) # main Vehicle vehicle = Vehicle(world=world, \ center=(WIDTH*0.05,HEIGHT*0.5), \ mass=1.0, \ max_speed=MAX_SPEED, \ max_force=MAX_FORCE, \ max_turn_rate=MAX_TURN_RATE, \ vel=INIT_VEL) #evade in this case vehicle.toggle_behavior(BEHAVIOR) def start(): create_agents() world.create_obstacles() def update(dt): world.update(dt)
HEIGHT = 600 MASS = 1.0 MAX_SPEED = 100 # pixels / second MAX_FORCE = 200 # pixels / second^2 MAX_TURN_RATE = 100 # degrees / second INIT_VEL = (100, 0) BEHAVIOR = Behavior.NONE world = GameWorld(WIDTH, HEIGHT) # main Vehicle hunter = Vehicle(world=world, \ center=(WIDTH*0.5,HEIGHT*0.5), \ mass=MASS, \ max_speed=(MAX_SPEED * 0.5), \ max_force=MAX_FORCE, \ max_turn_rate=MAX_TURN_RATE, \ vel= (INIT_VEL[0]*0.05,0)) hider1 = Vehicle(world=world, \ center=(WIDTH*0.25,HEIGHT*0.25), \ mass=MASS, \ max_speed=MAX_SPEED, \ max_force=MAX_FORCE, \ max_turn_rate=MAX_TURN_RATE, \ boid = 'purple', vel=INIT_VEL) hider2 = Vehicle(world=world, \
MASS = 1.0 MAX_SPEED = 100 # pixels / second MAX_FORCE = 200 # pixels / second^2 MAX_TURN_RATE = 100 # degrees / second INIT_VEL = (100,0) world = GameWorld(WIDTH,HEIGHT) # main Vehicle vehicle = Vehicle(world=world, \ center=(WIDTH*0.5,HEIGHT*0.5), \ mass=MASS, \ max_speed=MAX_SPEED, \ max_force=MAX_FORCE, \ max_turn_rate=MAX_TURN_RATE, \ vel= INIT_VEL) def start(): world.add_agent(vehicle) vehicle.path = Path.create_random_path(10,(20,20),(760,500)) vehicle.path_follow_on(); world.display_flags_off() world.view_keys = True world.show_steering_force = True world.show_path = True
HEIGHT = 600 MASS = 1.0 MAX_SPEED = 100 # pixels / second MAX_FORCE = 1000 # pixels / second^2 MAX_TURN_RATE = 100 # degrees / second INIT_VEL = Vector2(100, 0) FLOCK_SIZE = 10 world = GameWorld(WIDTH, HEIGHT) # main Vehicle leader = Vehicle(world=world, \ center=(WIDTH*0.5,HEIGHT*0.5), \ mass=MASS, \ max_speed=MAX_SPEED, \ max_force=MAX_FORCE, \ max_turn_rate=MAX_TURN_RATE, \ vel= 0.5 * INIT_VEL, color='red') flock = [] for i in range(FLOCK_SIZE): vel = Vector2(1, ) vel.rotate_ip(random.randint(0, 359)) vel *= random.randint(20, 30) v = Vehicle(world=world, \ center=(WIDTH*0.5 + random.randint(-30,30), HEIGHT*0.6), \ mass=MASS, \ max_speed=MAX_SPEED, \ max_force=MAX_FORCE, \