Example #1
0
def main():
    print("Testing basic canvas graphics...")
    with canvas(device) as draw:
        primitives(draw)

    time.sleep(10)

    print("Testing display ON/OFF...")
    for _ in range(10):
        time.sleep(0.5)
        device.hide()

        time.sleep(0.5)
        device.show()

    print("Testing clear display...")
    time.sleep(2)
    device.clear()

    print("Testing screen updates...")
    time.sleep(2)
    for x in range(30):
        with canvas(device) as draw:
            now = datetime.datetime.now()
            draw.text((x, 10), str(now.date()), fill=255)
            draw.text((10, 24), str(now.time()), fill=255)
            time.sleep(1)
Example #2
0
def main():
    print("Testing basic canvas graphics...")
    for _ in range(2):
        with canvas(device) as draw:
            primitives(draw)
    time.sleep(5)

    print("Testing contrast (dim/bright cycles)...")
    for _ in range(5):
        for level in range(255, -1, -10):
            device.contrast(level)
            time.sleep(0.1)
        time.sleep(0.5)

        for level in range(0, 255, 10):
            device.contrast(level)
            time.sleep(0.1)

        time.sleep(1)

    print("Testing display ON/OFF...")
    for _ in range(5):
        time.sleep(0.5)
        device.hide()

        time.sleep(0.5)
        device.show()

    print("Testing clear display...")
    time.sleep(2)
    device.clear()

    print("Testing screen updates...")
    time.sleep(2)
    for x in range(40):
        with canvas(device) as draw:
            now = datetime.datetime.now()
            draw.text((x, 4), str(now.date()), fill="white")
            draw.text((10, 16), str(now.time()), fill="white")
            time.sleep(0.1)
Example #3
0
    plyr = player()
    army = army()
    rows = random.sample(range(12), 12)

    img_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), 'images', 'splash.bmp'))
    splash = Image.open(img_path) \
        .transform((device.width, device.height), Image.AFFINE, (1, 0, 0, 0, 1, 0), Image.BILINEAR) \
        .convert(device.mode)

    # Double buffering in pygame?
    device.display(splash)
    device.display(splash)

    time.sleep(3)
    device.clear()

    while not army.invaded and army.size() > 0:
        with canvas(device) as draw:
            draw.line((0, 61, 95, 61), fill="white")
            draw.line((0, 63, 95, 63), fill="white")

            ai_logic_shoot(army, plyr)
            ai_logic_move(army, plyr, rows)

            army.update(plyr.bullets)

            army.render(draw)
            plyr.render(draw)

            draw.text((8, 0),