コード例 #1
0
    def extract(self):
        self.extractLocations()
        self.extractVenues()
        self.voronoi()
        bar = Bar(self.filesize / 2, "Extracting homes")
        with open(self.file, "r") as entrada:
            for line in entrada:
                line = line.strip()
                self.extractHome(line)
                bar.progress()
        bar.finish()

        bar = Bar(self.filesize / 2, "Extracting INCO, CODU, MAXCON and EDGEP")
        with open(self.file, "r") as entrada:
            for line in entrada:
                line = line.strip()
                bar.progress()
                self.extractMetrics(self.metrics, line)
        edges = self.topoGraph.edgeSet()
        bar.finish()

        if "TOPO" in self.metrics:
            bar = Bar(len(edges), "Extracting TOPO and SOCOR")
            for edge in edges:
                bar.progress()
                src = edge.src
                trg = edge.target
                enc = Encounter(int(src), int(trg))

                if (enc.toString() not in self.totalNeighbors):
                    self.totalNeighbors[enc.toString()] = []

                neighborsSrc = self.topoGraph.get_vertex(src).get_connections()
                degreeSrc = len(neighborsSrc)
                neighborsTrg = self.topoGraph.get_vertex(trg).get_connections()
                degreeDest = len(neighborsTrg)

                exists = 0
                if (self.topoGraph.containsEdge(src, trg)):
                    exists = 1

                to = 0
                for t in neighborsTrg:
                    if t in neighborsSrc:
                        to += 1
                numerator = float(to) + 1
                denominator = ((degreeSrc - exists) +
                               (degreeDest - exists) - to) + 1
                if denominator == 0:
                    denominator = 1
                toPct = numerator / denominator
                self.topo[enc.toString()] = toPct
            bar.finish()

        if "EDGEP" in self.metrics:
            self.normalizeEDGEP()
        if "SOCOR" in self.metrics:
            self.extractSOCOR()

        self.printMetrics(self.metrics)
コード例 #2
0
 def init_bars(self, num_classes, class_names=None):
     del self.bars[:]  #TO CHECK Python 2 vs Python 3
     if class_names is not None:
         for i in range(num_classes):
             self.bars.append(Bar(self.window, i, class_names[i]))
     else:
         for i in range(num_classes):
             self.bars.append(Bar(self.window, i))
コード例 #3
0
ファイル: Board.py プロジェクト: xiaottang2/TicTacToeAI
    def __init__(self, width, height):
        bar_h_1 = Bar()
        bar_h_2 = Bar()
        bar_v_1 = Bar()
        bar_v_2 = Bar()

        self.width = width
        self.height = height
        self.margin = MARGIN
        self.barWidth = BARWIDTH
        self.itemSize = ITEMSIZE
        self.buttonWidth = BUTTONWIDTH
        self.buttonHeight = BUTTONHEIGHT
        self.board_arr = [[CHECKER_EMPTY for i in range(NUM_ROWS)]
                          for j in range(NUM_COLS)]

        rotate = pygame.transform.rotate
        scale = pygame.transform.scale

        bar_h_1.image = rotate(bar_h_1.image, 90)
        bar_h_2.image = rotate(bar_h_2.image, 90)
        bar_h_1.image = scale(bar_h_1.image,
                              ((int(width - 2 * self.margin)), self.barWidth))
        bar_h_2.image = scale(bar_h_2.image,
                              ((int(width - 2 * self.margin)), self.barWidth))
        bar_v_1.image = scale(bar_v_1.image,
                              (self.barWidth, (int(width - 2 * self.margin))))
        bar_v_2.image = scale(bar_v_2.image,
                              (self.barWidth, (int(width - 2 * self.margin))))

        bar_h_1.rect.midtop = (self.margin, self.margin + self.itemSize +
                               0.5 * self.barWidth)
        bar_h_2.rect.midtop = (self.margin, self.margin + 2 * self.itemSize +
                               1.5 * self.barWidth)
        bar_v_1.rect.midtop = (self.margin + self.itemSize +
                               0.5 * self.barWidth, self.margin)
        bar_v_2.rect.midtop = (self.margin + 2 * self.itemSize +
                               1.5 * self.barWidth, self.margin)

        self.bar_h_1 = bar_h_1
        self.bar_h_2 = bar_h_2
        self.bar_v_1 = bar_v_1
        self.bar_v_2 = bar_v_2

        btn_player_first = Button('player')
        btn_ai_first = Button('AI')
        btn_player_first.rect.midtop = (self.width - self.margin -
                                        self.buttonWidth, self.height -
                                        3 * self.margin - self.buttonHeight)
        btn_ai_first.rect.midtop = (2 * self.margin, self.height -
                                    3 * self.margin - self.buttonHeight)

        self.btn_player_first = btn_player_first
        self.btn_ai_first = btn_ai_first

        self.prompt = False
コード例 #4
0
ファイル: TestEmpty2.py プロジェクト: techeye220/w4py
def test(store):
    """Bug report from Stefan Karlsson <*****@*****.**> on Dec 3 2001.

    Obj refs can be incorrectly stored to the database as zeroes for newly created objects.
    """

    from Bar import Bar
    from Foo import Foo
    from BarReq import BarReq

    # Since we're the second empty test, double check that the db is really empty
    assert len(store.fetchObjectsOfClass(Bar)) == 0
    assert len(store.fetchObjectsOfClass(Foo)) == 0

    bar = Bar()
    foo = Foo()
    store.addObject(bar)
    store.addObject(foo)
    bar.setFoo(foo)

    store.saveChanges()

    bars = store.fetchObjectsOfClass(Bar)
    assert len(bars) == 1
    bar2 = bars[0]
    assert bar2 is bar
    assert bar.foo() is not None  # the sign of the bug in question
    assert bar.foo() is foo  # what we should expect

    store.clear()
    bar = store.fetchObjectsOfClass(Bar)[0]
    assert bar.foo() is not None
コード例 #5
0
def test(store):
    """Bug discovered by Chuck Esterbrook on 2002-10-29."""
    from Bar import Bar
    from Qux import Qux

    # import sys; store._sqlEcho = sys.stdout

    # Since we're the second empty test, double check that the db is really empty
    assert len(store.fetchObjectsOfClass(Bar)) == 0
    assert len(store.fetchObjectsOfClass(Qux)) == 0

    qux = Qux()
    store.addObject(qux)
    bar = Bar()
    qux.setBar(bar)
    store.addObject(bar)

    store.saveChanges()
    quxes = store.fetchObjectsOfClass(Qux)
    assert len(quxes) == 1
    qux2 = quxes[0]
    assert qux2 is qux
    assert qux.bar() is not None  # the sign of the bug in question
    assert qux.bar() is bar  # what we should expect

    store.clear()
    qux = store.fetchObjectsOfClass(Qux)[0]
    assert qux.bar() is not None
コード例 #6
0
 def parse_swim(self, filename):
     """ Parse a SWIM trace. """
     self.collect_maxes_swim(filename)
     output_file = self.generate_filename(filename)
     with open(output_file, 'w') as out:
         encounters = {}
         bar = Bar(self.filesize, "Parsing SWIM file")
         with open(filename, 'r') as entrada:
             for i, line in enumerate(entrada):
                 bar.progress()
                 comps = line.strip().split(" ")
                 comps = self.remove_empty(comps)
                 encounter = Encounter(comps[2], comps[3])
                 if str(encounter) in encounters:
                     e = encounters[str(encounter)]
                     self.parsedfilesize += 1
                     out.write("{} {} ".format(comps[2], comps[3]))
                     out.write("{} {} ".format(comps[3], e))
                     out.write("{} ".format(float(comps[0]) - e))
                     out.write("{} {} ".format(comps[4], comps[5]))
                     out.write("{} ".format(comps[6]))
                     out.write("{}\n".format(comps[7]))
                 encounters[str(encounter)] = float(comps[0])
     bar.finish()
     return output_file
コード例 #7
0
ファイル: Minion.py プロジェクト: lechodiman/iic2233-2017-1
    def __init__(self):
        super().__init__()
        # set graphics
        self.setPixmap(QPixmap('./res/imgs/knight.png'))
        self.setTransformOriginPoint(16, 16)

        # initialize health bar
        h = Bar(self)
        h.set_max_val(45)
        h.set_current_val(45)
        self.set_health(h)

        # set specs
        self.set_speed(3)
        self.set_attack(2)
        self.set_range(25)

        # set destination
        self.destination_timer = QTimer()
        self.destination_timer.timeout.connect(self.set_dest_to_closest)
        self.destination_timer.start(1000 / 30)

        # connect timer to move forward
        self.move_timer = QTimer()
        self.move_timer.timeout.connect(self.move_forward)
        self.move_timer.start(1000 / 30)

        # timer to damage
        self.damage_timer = QTimer()
        self.damage_timer.timeout.connect(self.damage_if_colliding)
        self.damage_timer.start(1000)
コード例 #8
0
    def __init__(self, powered_up=False):
        super().__init__()
        # set graphics
        if not powered_up:
            self.setPixmap(
                QPixmap('./res/imgs/wizard.png').scaled(
                    40, 40, Qt.KeepAspectRatio))
            self.setTransformOriginPoint(20, 20)
            h = Bar(self)
            h.set_max_val(60)
            h.set_current_val(60)
            self.set_health(h)
            self.set_attack(4)

        else:
            self.setPixmap(
                QPixmap('./res/imgs/wizard.png').scaled(
                    60, 60, Qt.KeepAspectRatio))
            self.setTransformOriginPoint(30, 30)
            h = Bar(self)
            h.set_max_val(120)
            h.set_current_val(120)
            self.set_health(h)
            self.set_attack(10)

        # set specs
        self.set_speed(2)

        # set attack area
        self.set_range(100)

        # connect a timer to acquire target
        self.damage_timer = QTimer()
        self.damage_timer.timeout.connect(self.acquire_target)
        self.damage_timer.start(1000)

        # timer to move forward, but if has target, then it does not move
        self.move_timer = QTimer()
        self.move_timer.timeout.connect(self.move_forward)
        self.move_timer.start(1000 / 30)

        # set destination
        self.destination_timer = QTimer()
        self.destination_timer.timeout.connect(self.set_dest_to_closest)
        self.destination_timer.start(1000 / 30)
コード例 #9
0
def setup():
    background(0)
    global bar
    numberOfBars = 5
    bar = [0] * numberOfBars
    barWidth = width / numberOfBars
    barHeight = 10
    for n in range(numberOfBars):
        bar[n] = Bar(barWidth, height, barHeight, n)
コード例 #10
0
ファイル: Tower.py プロジェクト: lechodiman/iic2233-2017-1
    def __init__(self):
        super().__init__()
        # initialize attack range (area)
        self.attack_area = QGraphicsPolygonItem()
        self.attack_dest = QPointF(0, 0)
        self.has_target = False

        # set the graphics
        self.setPixmap(
            QPixmap('./res/imgs/lol_tower.png').scaled(80, 80,
                                                       Qt.KeepAspectRatio))

        # initializes health
        h = Bar(self)
        h.set_max_val(250)
        h.set_current_val(250)
        self.set_health(h)
        self.attack = 30

        # create points vector
        points = [
            QPointF(1, 0),
            QPointF(2, 0),
            QPointF(3, 1),
            QPointF(3, 2),
            QPointF(2, 3),
            QPointF(1, 3),
            QPointF(0, 2),
            QPointF(0, 1)
        ]

        # scale points
        SCALE_FACTOR = 100
        points = [p * SCALE_FACTOR for p in points]
        self.range = SCALE_FACTOR

        # create polygon
        self.polygon = QPolygonF(points)

        # create QGraphicsPolygonItem
        self.attack_area = QGraphicsPolygonItem(self.polygon, self)
        self.attack_area.setPen(QPen(Qt.DotLine))

        # move the polygon
        poly_center = QPointF(1.5 * SCALE_FACTOR, 1.5 * SCALE_FACTOR)
        poly_center = self.mapToScene(poly_center)
        tower_center = QPointF(self.x() + 40, self.y() + 40)
        ln = QLineF(poly_center, tower_center)
        self.attack_area.setPos(self.x() + ln.dx(), self.y() + ln.dy())

        # connect a timer to acquire target
        self.damage_timer = QTimer()
        self.damage_timer.timeout.connect(self.acquire_target)
        self.damage_timer.start(1000)

        # allow responding to hover events
        self.setAcceptHoverEvents(True)
コード例 #11
0
ファイル: Database.py プロジェクト: dkinsbur/PyAlgo
 def day_bars_get(self, symbol, start, end=None):
     with self._connect() as conn:
         cur = conn.cursor()
         SQL = self._make_day_bar_select_command(symbol, start, end)
         print SQL
         cur.execute(SQL)
         return tuple(
             Bar(datetime.strptime(dt, '%Y-%m-%d'), h, l, o, c, v)
             for sym, dt, o, h, l, c, v in cur.fetchall())
コード例 #12
0
ファイル: Database.py プロジェクト: dkinsbur/PyAlgo
 def min_bars_get(self, symbol, start, end=None, pre_post_market=True):
     with self._connect() as conn:
         cur = conn.cursor()
         SQL = self._make_min_bar_select_command(symbol, start, end)
         print SQL
         cur.execute(SQL)
         return tuple(
             Bar(datetime.strptime(dt + ' ' +
                                   tm, '%Y-%m-%d %H:%M:%S'), h, l, o, c, v)
             for sym, dt, tm, o, h, l, c, v in cur.fetchall())
コード例 #13
0
 def __init__(self):
     self.health = random.randint(200, 300)
     self.attack = random.randint(10, 20)
     self.inventory = []
     for x in range(0, 10):
         self.bar = Bar()
         self.straw = Straw()
         self.bomb = Bomb()
         self.kiss = Kiss()
         self.inventory = self.inventory + random.sample(
             [self.bomb, self.kiss, self.straw, self.bar], 1)
コード例 #14
0
ファイル: Monster.py プロジェクト: Denise-Yang/rosg
 def __init__(self, x, y, r, grid, pLvl):
     super().__init__(x, y, r, grid, pLvl)
     self.image = []
     self.sequence = 2
     self.index = 0
     self.initImages()
     self.image = self.images[self.index]
     self.distance = 80
     self.hp = 100
     self.hpBar = Bar(self.hp, (255, 0, 0), self.x, self.y - 10, 25, 5)
     self.nodes = self.getNodes()
     self.updateRect()
     self.str = 10
コード例 #15
0
    def __init__(self):
        super().__init__()
        # graphics
        self.set_sprite_image(QPixmap('./res/imgs/ogrillion-move.png'))

        # set specs
        h = Bar(self)
        h.set_max_val(700)
        h.set_current_val(700)
        self.set_health(h)

        self.set_speed(5)
        self.set_attack(5)
        self.set_range(100)
        self.set_cooldown(10000)
コード例 #16
0
    def __init__(self):
        super().__init__()
        # graphics
        self.set_sprite_image(QPixmap('./res/imgs/troll-move.png'))

        # set specs
        h = Bar(self)
        h.set_max_val(666)
        h.set_current_val(666)
        self.set_health(h)

        self.set_speed(3)
        self.set_attack(5)
        self.set_range(40)
        self.set_cooldown(40000)
コード例 #17
0
    def __init__(self, points_to_follow):
        super().__init__()
        # initialize keys dictionary
        self.keys = {
            Qt.Key_W: False,
            Qt.Key_A: False,
            Qt.Key_D: False,
            Qt.Key_S: False
        }
        self.points = points_to_follow
        self.dest = QPointF()
        self.point_index = 0
        self.team = 1

        # set graphics
        self.setPixmap(
            QPixmap('./res/imgs/enemy_3.png').scaled(50, 50,
                                                     Qt.KeepAspectRatio))
        self.setTransformOriginPoint(25, 25)

        self.point_index = 0
        self.dest = self.points[self.point_index]
        self.rotate_to_point(self.dest)

        # connect timer to move forward
        # self.timer = QTimer()
        # self.timer.timeout.connect(self.move_forward)
        # self.timer.start(150)

        # WASD timer
        self.move_timer = QTimer()
        self.move_timer.timeout.connect(self.timer_event)
        self.move_timer.start(1000 / 60)

        # set animations
        self.current_frame = 0
        self.sprite_image = QPixmap('./res/imgs/player-move.png')

        # initialize health bar
        self.health = 100
        self.max_health = 100
        self.health_bar = Bar(self)
        self.health_bar.set_max_val(100)
        self.health_bar.set_current_val(100)

        # create a timer to change the frame
        self.sprite_timer = QTimer()
        self.sprite_timer.timeout.connect(self.nextFrame)
コード例 #18
0
    def extractLocations(self):
        bar = Bar(self.filesize / 2, "Extracting locations")
        with open(self.file, 'r') as entrada:
            for line in entrada:
                split = line.strip().split(" ")
                key = "{} {}".format(split[5], split[6])
                if key not in self.locations:
                    self.locations[key] = self.locationsIndex
                    self.locationsIndex += 1

                key = "{} {}".format(split[7], split[8])
                if key not in self.locations:
                    self.locations[key] = self.locationsIndex
                    self.locationsIndex += 1
                bar.progress()
        bar.finish()
コード例 #19
0
def setupListTest(store, klass):
    # Create a Foo and a Bar, with the Foo pointing to the Bar
    bar = Bar()
    bar.setX(42)
    foo = Foo()
    foo.setBar(bar)
    store.addObject(foo)
    store.addObject(bar)
    store.saveChanges()

    # create an instance of klass and put it into the list in foo
    obj = klass()
    getattr(foo, 'addToListOf%s' % klass.__name__)(obj)
    store.saveChanges()

    return obj, foo, bar
コード例 #20
0
ファイル: TestEmpty.py プロジェクト: techeye220/w4py
def testAddToBars(store):
    # Test 1: Use addToBars()
    f = Foo()
    store.addObject(f)

    b = Bar()
    f.addToBars(b)
    b.dumpAttrs()
    store.saveChanges()

    store.clear()
    f = store.fetchObjectsOfClass(Foo)[0]
    bars = f.bars()
    assert len(bars) == 1, 'bars=%r' % bars
    assert bars[0].foo() == f
    reset(store)
コード例 #21
0
    def extractVenues(self):
        numberVenues = int(self.maxX * self.maxY / (self.r * self.r))
        numberVenues = min(835, numberVenues)

        _set = list(self.locations.keys())
        randomIndex = 0
        venuesIndex = 0
        bar = Bar(numberVenues, "Extracting venues")
        for i in range(0, numberVenues):
            randomIndex = random.randint(0, len(_set) - 1)
            while _set[randomIndex] not in self.locations:
                randomIndex = random.randint(0, len(_set) - 1)
            self.venues[venuesIndex] = _set[randomIndex]
            venuesIndex += 1
            bar.progress()
        bar.finish()
コード例 #22
0
    def __init__(self):
        super().__init__()
        # graphics
        self.set_sprite_image(QPixmap('./res/imgs/player-move.png'))

        # set specs
        h = Bar(self)
        h.set_max_val(500)
        h.set_current_val(500)
        self.set_health(h)

        self.set_speed(5)
        self.set_attack(5)
        self.set_range(100)
        self.set_cooldown(30000)

        self.items_freezed = []
コード例 #23
0
ファイル: Monster.py プロジェクト: Denise-Yang/rosg
 def __init__(self, x, y, r, grid, pLvl):
     self.x, self.y, self.r = x, y, r
     super(Monster, self).__init__()
     self.images = []
     self.index = 0
     self.initImages()
     self.image = self.images[self.index]
     self.sequence = 4
     self.grid = grid
     self.distance = 100
     self.path = []
     self.hp = 10 * int(math.sqrt(pLvl))
     self.hpBar = Bar(self.hp, (255, 0, 0), self.x, self.y - 10, 25, 5)
     self.nodes = self.getNodes()
     self.updateRect()
     self.maxStr = 2 * int(math.sqrt(pLvl))
     self.str = random.randint(0, self.maxStr)
     self.speed = 20
コード例 #24
0
ファイル: Classifier.py プロジェクト: augdomingues/MOCHA
    def best_fit_distribution(self, data, filename, bins=200):
        """ Computes and returns the distribution that best fits the data. """
        y, x = np.histogram(data, bins=bins, density=True)
        x = (x + np.roll(x, -1))[:-1] / 2.0

        DISTRIBUTIONS = [
            st.dweibull, st.expon, st.gamma, st.logistic, st.lognorm, st.norm,
            st.pareto
        ]

        best_distribution = st.norm
        best_params = (0.0, 1.0)
        best_sse = np.inf

        if os.sep in filename:
            metric = filename.split(os.sep)[1]
        else:
            metric = filename

        progressbar = Bar(len(DISTRIBUTIONS), "Fitting {}".format(metric))
        for distribution in DISTRIBUTIONS:
            warnings.filterwarnings('ignore')
            params = distribution.fit(data)
            arg = params[:-2]
            loc = params[-2]
            scale = params[-1]
            pdf = distribution.pdf(x, loc=loc, scale=scale, *arg)
            sse = np.sum(np.power(y - pdf, 2.0))
            sse = -2 * math.log(sse) + 2 * (len(params) + 1)
            if sse < best_sse:
                best_distribution = distribution
                best_params = params
                best_sse = sse

            print(" SSE of {} is {}(Current best: {})".format(
                distribution.name, round(sse, 2), round(best_sse, 2)),
                  end="")
            progressbar.progress()

        print(" Fit to {} with params [{}]".format(best_distribution.name,
                                                   best_params),
              end="")
        progressbar.finish()
        return (best_distribution.name, best_params)
コード例 #25
0
def play_game(utility, DISPLAYSURF):
    fps_clock = pygame.time.Clock()

    pygame.mixer.music.load("./music/game_theme.mp3")
    pygame.mixer.music.play(-1, 2.0)

    player = Bar()
    ball = Ball()

    player.draw(DISPLAYSURF)
    ball.draw(DISPLAYSURF)
    blocks = draw_blocks(utility, DISPLAYSURF)

    while True:  # main game loop
        keys = pygame.key.get_pressed()

        #move bar when right or left arrow is held down or pushed down
        if (keys[pygame.K_RIGHT]):
            player.move(DISPLAYSURF, 3)
        elif (keys[pygame.K_LEFT]):
            player.move(DISPLAYSURF, -3)
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == MOUSEBUTTONUP:
                print(event.pos)

        ball.move(DISPLAYSURF, player)
        draw_blocks2(utility, DISPLAYSURF, blocks)
        # determine if ball hits a block
        block_collision = utility.getBallNBlockCollision(ball, blocks)

        if block_collision:
            # deduct from that blocks health
            blocks = block_collision.deductHealth(blocks, ball, player,
                                                  DISPLAYSURF)

        if ball.outOfScreen():
            player.reduceLives()
            ball.resetPosition()

        pygame.display.update()
        fps_clock.tick(utility.getFPS())
コード例 #26
0
    def __init__(self, x, y):
        
        pygame.sprite.Sprite.__init__(self)
        self.size  = 20
        super(Player, self).__init__()
        
        #initialize animation
        self.images = []
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerF1.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerF2.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerF3.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerF4.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerB1.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerB2.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerB3.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerB4.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerL1.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerL2.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerL3.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerL4.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerR1.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerR2.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerR3.png'), (20,20)))
        self.images.append(pygame.transform.scale(pygame.image.load('playeranimation/playerR4.png'), (20,20)))
        self.index, self.dir = 0, 0
        self.image = self.images[self.index]
        self.seq = 4
        self.str = 10
        self.hp = 40
        self.x =  x
        self.y = y
        self.lvlNum = 1

        #initialize stats
        self.hpBar = Bar(self.hp,(255,0,0), 10, 630, 200, 20, "HP")
        self.lvlBar = Lvl(20, (0,255,0), 10, 675, 200, 10, self.lvlNum)
        self.myfont = pygame.font.SysFont(None, 20)
        self.lvlFont  = pygame.font.SysFont('Comic Sans MS', 15)
        self.hpFont = pygame.font.SysFont('Comic Sans MS', 25)
        self.lvlTxt = self.lvlFont.render ("lvl:"+ str(self.lvlNum), False,(255,255,255))
        self.hpTxt = self.hpFont.render ("HP", False,(255,255,255))
        self.speed = 20
        self.updateRect()
コード例 #27
0
    def __init__(self):
        super().__init__()

        # set the graphics
        self.setPixmap(
            QPixmap('./res/imgs/lol_inhibitor_2.png').scaled(
                50, 50, Qt.KeepAspectRatio))

        # initializes health
        h = Bar(self)
        h.set_max_val(600)
        h.set_current_val(600)
        self.set_health(h)

        # initializes signal (when it dies)
        self.s = InhibitorSignal()

        # allow responding to hover events
        self.setAcceptHoverEvents(True)
コード例 #28
0
def setupListTest(store, klass):
    """
	Setup 3 objects: one of the specified klass, pointing to a Foo, pointing to a Bar.
	Returns tuple (object of specified klass, foo, bar).
	"""
    # Create a Foo and a Bar, with the Foo pointing to the Bar
    bar = Bar()
    bar.setX(42)
    foo = Foo()
    foo.setBar(bar)
    store.addObject(foo)
    store.addObject(bar)
    store.saveChanges()

    # create an instance of klass and put it into the list in foo
    object = klass()
    getattr(foo, 'addToListOf%s' % klass.__name__)(object)
    store.saveChanges()

    return object, foo, bar
コード例 #29
0
def createPiece(board):
    """Randomly generates a new piece."""
    # You can comment out parts of this to remove any not-yet-implemented 
    # pieces during testing.
    pieceChoice = randrange(7)
    if pieceChoice == 0:
        return Bar(board)
    elif pieceChoice == 1:
        return Ell(board)
    elif pieceChoice == 2:
        return Jay(board)
    elif pieceChoice == 3:
        return Tee(board)
    elif pieceChoice == 4:
        return RightZig(board)
    elif pieceChoice == 5:
        return LeftZag(board)
    
    # Default to MrChunky
    return MrChunky(board)
コード例 #30
0
    def __init__(self, ):
        super().__init__()
        # set the graphics
        self.setPixmap(
            QPixmap('./res/imgs/lol_nexus_1.png').scaled(
                80, 80, Qt.KeepAspectRatio))

        # initializes health
        h = Bar(self)
        h.set_max_val(1200)
        h.set_current_val(1200)
        self.set_health(h)

        # set signal
        self.s = NexusSignal()

        # set not damageable
        self.set_damageable(False)

        # allow responding to hover events
        self.setAcceptHoverEvents(True)