예제 #1
0
        

# initialise shapes
balls = []
for i in range(0, maxballs):
    #r = random.randint(0, 10) + 3
    r = 7
    balls.append(
        Ball(
            random.randint(0,width),
            random.randint(0,height),
            random.randint(0,10) + 5,
            random.randint(0,255) / 128,
            random.randint(0,255) / 128,
            display.create_pen(random.randint(75, 200), random.randint(75, 200), random.randint(75, 200))          
        )
    )
bat = Bat(1)
missile = Missile(width-20,0)
#display.set_led(0,150,0)



while True:
    display.set_pen(40, 40, 40)
    display.clear()
    
    #while ballcount>0:
    print(ballcount)       
    for ball in balls:
예제 #2
0
        self.pen = pen


class Bat:
    def __init__(self, y):
        self.y = y


# initialise shapes
balls = []
for i in range(0, 50):
    balls.append(
        Ball(random.randint(0, width), random.randint(0, height),
             random.randint(0, 10) + 3,
             random.randint(0, 255) / 128,
             random.randint(0, 255) / 128, display.create_pen(0, 0, 155)))
bat = Bat(1)

while True:
    display.set_pen(0, 0, 0)
    display.clear()

    for ball in balls:
        ball.x += ball.dx
        ball.y += ball.dy

        if ball.x <= 0:
            if ball.y > bat.y + 25 or ball.y < bat.y:
                #display.set_led(255,0,0)
                ball.dx = 0
                ball.dy = 0
예제 #3
0
        self.dy = dy
        self.pen = pen


# initialise shapes
balls = []
for i in range(0, 100):
    r = random.randint(0, 10) + 3
    balls.append(
        Ball(
            random.randint(r, r + (width - 2 * r)),
            random.randint(r, r + (height - 2 * r)),
            r,
            (14 - r) / 2,
            (14 - r) / 2,
            display.create_pen(random.randint(0, 255), random.randint(0, 255),
                               random.randint(0, 255)),
        ))

while True:
    display.set_pen(40, 40, 40)
    display.clear()

    for ball in balls:
        ball.x += ball.dx
        ball.y += ball.dy

        xmax = width - ball.r
        xmin = ball.r
        ymax = height - ball.r
        ymin = ball.r
예제 #4
0
# pico-simon by Simon May.
import utime, random
import picodisplay as display

# Set up and initialise Pico Display
buf = bytearray(display.get_width() * display.get_height() * 2)
display.init(buf)
display.set_backlight(0.8)

WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)
RED = display.create_pen(255, 0, 0)
GREEN = display.create_pen(0, 255, 0)
BLUE = display.create_pen(0, 0, 255)
YELLOW = display.create_pen(255, 255, 0)
rwidth = 120
rheight = 67
rect = [{
    "x": 0,
    "y": 0
}, {
    "x": 120,
    "y": 0
}, {
    "x": 0,
    "y": 68
}, {
    "x": 120,
    "y": 68
}]
rpen = [RED, YELLOW, BLUE, GREEN]
예제 #5
0
# Use the above to create a buffer for the screen.  It needs to be 2 bytes for every pixel.
display_buffer = bytearray(width * height * 2)

# Start the display!
display.init(display_buffer)
# Boilerplate end

# setting the backlight intensity
display.set_backlight(1.0)

# set drawing color
display.set_pen(255, 255, 255)

# define pens/colors
makeRed = display.create_pen(255, 0, 0)
makeBlue = display.create_pen(0, 0, 200)
makeGray = display.create_pen(220, 220, 220)

# "clear" (just fills display with color=
display.clear()

# update/push changes to display (to avoid flicker)
display.update()

makemagazin()

display.set_pen(makeRed)
while not (display.is_pressed(display.BUTTON_A)):
    display.pixel(random.randint(5, 234), random.randint(50, 129))
    if display.is_pressed(display.BUTTON_Y):
예제 #6
0
class Missile:
    def __init__(self, x, y):
        self.x = y
        self.y = y
        self.active = False


# initialise shapes
area51 = []
for i in range(0, 25):
    area51.append(
        Ufo(random.randint(0, width), random.randint(0, height),
            random.randint(0, 10) + 3,
            random.randint(0, 255) / 128,
            random.randint(0, 255) / 128,
            display.create_pen(0, random.randint(75, 155), 0)))
bat = Bat(1)
missile = Missile(width - 20, 0)

while True:
    display.set_pen(0, 0, 0)
    display.clear()

    for ufo in area51:
        ufo.x += ufo.dx
        ufo.y += ufo.dy

        if ufo.x < 0 or ufo.x > width:
            ufo.dx *= -1
        if ufo.y < 0 or ufo.y > height:
            ufo.dy *= -1
예제 #7
0
import random
import picodisplay as display

# based on initial code demo for the PiMoroni PicoDisplay for the RaspberyPiPico
width = display.get_width()
height = display.get_height()
display_buffer = bytearray(width * height * 2)  # 2-bytes per pixel (RGB565)
display.init(display_buffer)

display.set_backlight(1.0)

#colours
brightwhite = display.create_pen(255, 255, 255)
white = display.create_pen(155, 155, 155)
red = display.create_pen(155, 0, 0)
green = display.create_pen(0, 155, 0)
brown = display.create_pen(210, 105, 30)
black = display.create_pen(0, 0, 0)


def drawplane(x, y):
    #draw the plane
    display.set_pen(red)
    display.rectangle(x, y, 4, 5)
    display.set_pen(white)
    display.rectangle(x + 2, y + 5, 18, 5)
    display.set_pen(black)
    display.rectangle(x + 18, y + 5, 2, 2)


def drawtree(x, h):
예제 #8
0
tim.init(period=200, mode=Timer.PERIODIC, callback=tick)


def task(s, radius, pen):
    global display
    #    print(pen)
    for i in range(1, s):
        display.set_pen(pen)
        display.rectangle(random.randint(0, width - 1),
                          random.randint(0, height - 1), radius, radius)


#_thread.start_new_thread(task, (0.2, 10))

pen_red = display.create_pen(250, 0, 0)
pen_green = display.create_pen(0, 250, 0)
pen_blue = display.create_pen(0, 0, 250)

tic = time.ticks_ms()
task(s, radius, pen_red)
display.update()
toc = time.ticks_ms()
print("Time: ", (toc - tic) / 1000.0)

time.sleep(2)

tic = time.ticks_ms()
_thread.start_new_thread(task, (s / 2, radius, pen_green))
task(s / 2, radius, pen_green)
display.update()
예제 #9
0
import utime, uarray, random
import picodisplay as display

colorScale = [
    display.create_pen(0x07, 0x07, 0x07),
    display.create_pen(0x1F, 0x07, 0x07),
    display.create_pen(0x2F, 0x0F, 0x07),
    display.create_pen(0x47, 0x0F, 0x07),
    display.create_pen(0x57, 0x17, 0x07),
    display.create_pen(0x67, 0x1F, 0x07),
    display.create_pen(0x77, 0x1F, 0x07),
    display.create_pen(0x8F, 0x27, 0x07),
    display.create_pen(0x9F, 0x2F, 0x07),
    display.create_pen(0xAF, 0x3F, 0x07),
    display.create_pen(0xBF, 0x47, 0x07),
    display.create_pen(0xC7, 0x47, 0x07),
    display.create_pen(0xDF, 0x4F, 0x07),
    display.create_pen(0xDF, 0x57, 0x07),
    display.create_pen(0xDF, 0x57, 0x07),
    display.create_pen(0xD7, 0x5F, 0x07),
    display.create_pen(0xD7, 0x5F, 0x07),
    display.create_pen(0xD7, 0x67, 0x0F),
    display.create_pen(0xCF, 0x6F, 0x0F),
    display.create_pen(0xCF, 0x77, 0x0F),
    display.create_pen(0xCF, 0x7F, 0x0F),
    display.create_pen(0xCF, 0x87, 0x17),
    display.create_pen(0xC7, 0x87, 0x17),
    display.create_pen(0xC7, 0x8F, 0x17),
    display.create_pen(0xC7, 0x97, 0x1F),
    display.create_pen(0xBF, 0x9F, 0x1F),
    display.create_pen(0xBF, 0x9F, 0x1F),