Guest User

For loop

a guest
Jan 6th, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. def create_and_place_units(game, team, start_positions, unit_types):
  2.     for pos, unit_type in zip(start_positions, unit_types):
  3.         unit = UnitFactory.create_unit(unit_type, x=pos[0], y=pos[1], team=team, game=game)
  4.         game.unit_map.place_unit(unit, pos)
  5.         game.unit_handler.add_unit(unit)
  6.  
  7. red_team_positions = [(2, 0), (3, 0), (4, 0), (5, 0), (6, 0)]
  8. blue_team_positions = [(2, 9), (3, 9), (4, 9), (5, 9), (6, 9)]
  9. unit_types = ["Knight", "Archer", "Footman", "Knight", "Crossbowman"]
  10.  
  11. create_and_place_units(game, "red", red_team_positions, unit_types)
  12. create_and_place_units(game, "blue", blue_team_positions, unit_types)
Advertisement
Add Comment
Please, Sign In to add comment