コード例 #1
0
ファイル: main.py プロジェクト: Junkpilepunk/memory_game


#initialize variables
game_started = 0
level=1

# mainloop

sense.clear()

while True:
    while game_started == False:            #show a message before the game starts

        #press button to start
        sense.load_image("press_start.png", redraw=True)
        for event in sense.stick.get_events():
            if event.action == "released":
                game_started = True


    sense.show_message("lvl " + str(level))

    trythis = to_do(level)
    win = players_turn(trythis)

    if win == True:
        sense.load_image("correct.png", redraw=True)
        sleep(1)
        level = level + 1
コード例 #2
0
# reading and writing to the sensehat with python

from sense_emu import SenseHat
from time import sleep

mySenHa = SenseHat()

mySenHa.show_message("Hello", text_colour=[100, 200, 150])

mySenHa.load_image("raspberry.jpg")
sleep(5)

myHumidity = mySenHa.get_humidity()
humidString = str(myHumidity)
mySenHa.show_message(humidString)
コード例 #3
0
ファイル: Ui.py プロジェクト: AberDerBart/senseHatClock
    """draws [image] on the sense hat"""
    sense.set_pixels(imageAlpha(image, alpha))


def drawPixel(x, y, pixel):
    """sets the pixel color of pixel at ([x],[y]) on the sense hat to [pixel]"""
    global alpha
    sense.set_pixel(x, y, pixelAlpha(pixel, alpha))


def drawLoading():
    """draws a loading icon on the sense hat"""
    drawImage(drawLoading.loading)


drawLoading.loading = sense.load_image("img/loading.png")


def registerApp(appString, app):
    """registers [app] in [appDict], it can then be loaded with [setApp]"""
    appDict[appString] = app


def getApp(appString):
    """returns the app registered with [appString]"""
    return appDict[appString]


def setApp(appString):
    """loads app with the corresponding string [appString]"""
    global appDict