def __init__(self): main = MainBase() main.pos = vec2d(300, 300) main.target = vec2d(main.pos[0] + 10, main.pos[1]) out = Outpost() out.pos = vec2d(200, 200) out.target = vec2d(out.pos[0] + 10, out.pos[1]) self.buildings = [main, out]
def __init__(self): self.w, self.h = 800, 600 PygameHelper.__init__(self, size=(self.w, self.h), fill=((255,255,255))) self.hud = Hud() self.drones = [] for i in range(4): tempagent = Drone() tempagent.pos = vec2d(int(uniform(0, self.w - 20)), int(uniform(0, 400))) target = vec2d(int(uniform(0, self.w - 20)), int(uniform(0, 400))) tempagent.target.append(target) self.drones.append(tempagent) self.selected = self.drones[0] self.builder = self.drones[0] self.project = vec2d(0, 0) self.buildtype = 0 self.buildpos = vec2d(0, 0) self.buildings = [] self.ores = [] count = 0 while count < 15: tempore = Ore() tempore.pos = vec2d(int(uniform(0, 1500)), int(uniform(0, 1500))) if not len(self.ores) == 0: flag = 1 for orecheck in self.ores: dist = orecheck.pos.get_distance(tempore.pos) if dist < 120: flag = 0 if flag: self.ores.append(tempore) count += 1 else: self.ores.append(tempore) count += 1 firstbuild = MainBase() firstbuild.pos = vec2d(300, 300) firstbuild.target = vec2d(firstbuild.pos[0] + 10, firstbuild.pos[1]) self.buildings.append(firstbuild)
def test_init_main_base(self): firstbuild = MainBase() firstbuild.pos = vec2d(300, 300) firstbuild.target = vec2d(firstbuild.pos[0] + 10, firstbuild.pos[1]) self.assertEqual(firstbuild.pos[0], 300) self.assertEqual(firstbuild.pos[1], 300)