Esempio n. 1
0
                            intensity = math.sqrt((rad - dist) / rad) * 2 * max_intensity
                            intensity = min(intensity, max_intensity)

                            # not sending if pixel already at that state
                            if field[field_pos] != intensity:
                                # marking pixel as dirty
                                field[field_pos] = intensity

                                # finally painting
                                matrix.send_pixel((x,y), (intensity, intensity, 0x00))

                if not painted and field[field_pos]:
                    # clear formerly painted and no longer used pixels
                    field[field_pos] = False
                    matrix.send_pixel((x,y), (0x00, 0x00, 0x00))

        # move forward
        self.pos += 1

        # are we finished?
        return pos < width

matrix = LedMatrix()
pacman = Pacman(matrix)

try:
    const_loop(pacman.step, 0.2)
finally:
    matrix.close()

Esempio n. 2
0
 def endless(self, snooze=0.1):
     const_loop(self.step, snooze)
Esempio n. 3
0
                        if old_field[n % width][m % height]:
                            prox += 1

                if old_field[x][y]:
                    prox -= 1
                    if prox < 2:
                        print "lonely ", prox
                        self.die(x, y)
                    elif prox > 3:
                        print "crowded ", prox
                        self.die(x, y)
                    else:
                        self.survive(x, y)
                elif prox == 3:
                    self.create(x, y)

        return True


matrix = LedMatrix()

try:
    matrix.send_clear()

    game = GameOfLife(matrix)
    game.load(sys.argv[1])

    const_loop(game.step, 0.2)
finally:
    matrix.close()
Esempio n. 4
0
                            intensity = min(intensity, max_intensity)

                            # not sending if pixel already at that state
                            if field[field_pos] != intensity:
                                # marking pixel as dirty
                                field[field_pos] = intensity

                                # finally painting
                                matrix.send_pixel((x, y),
                                                  (intensity, intensity, 0x00))

                if not painted and field[field_pos]:
                    # clear formerly painted and no longer used pixels
                    field[field_pos] = False
                    matrix.send_pixel((x, y), (0x00, 0x00, 0x00))

        # move forward
        self.pos += 1

        # are we finished?
        return pos < width


matrix = LedMatrix()
pacman = Pacman(matrix)

try:
    const_loop(pacman.step, 0.2)
finally:
    matrix.close()
Esempio n. 5
0
 def endless(self, snooze=0.1):
     const_loop(self.step, snooze)
Esempio n. 6
0
                        if old_field[n%width][m%height]:
                            prox += 1

                if old_field[x][y]:
                    prox -= 1
                    if prox < 2:
                        print "lonely ", prox
                        self.die(x, y)
                    elif prox > 3:
                        print "crowded ", prox
                        self.die(x, y)
                    else:
                        self.survive(x, y)
                elif prox == 3:
                    self.create(x, y)

        return True

matrix = LedMatrix()

try:
    matrix.send_clear()

    game = GameOfLife(matrix)
    game.load(sys.argv[1])

    const_loop(game.step, 0.2)
finally:
    matrix.close()