Esempio n. 1
0
 def __init__(self):
     MIN_PLANET_RAD = 15
     MAX_PLANET_RAD = int(math.sqrt(Options.Video.height * Options.Video.view_width / 70))
     self.rad = randint(MIN_PLANET_RAD, MAX_PLANET_RAD)
     self.density = randint(20, 50)
     self.force = self.rad ** 2 * self.density
     self.type = randint(0, 3)
     place(self)
Esempio n. 2
0
def gen_bonus(game):
    gen = True
    game.bonus = Bonus()
    while gen:
        gen = False
        place(game.bonus)

        for pl in game.players + game.planets:
            if dist(pl, game.bonus) < pl.rad + game.bonus.rad + 2:
                gen = True
                break
Esempio n. 3
0
def gen_players(game):
    for ind, pl in enumerate(game.players):
        while True:
            place(pl)
            p = game.planets
            if any(dist(pl, game.players[i]) <
                   pl.rad + game.players[i].rad
                   for i in xrange(ind)): continue
            if all(dist(pl, p[i]) >
                   pl.rad + p[i].rad + Const.PLANETS_GAP
                   for i in xrange(len(p))): break