Example #1
0
def room_3():
	###Room 3 - exits north, east
	room=3
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(1,1,0,0)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
Example #2
0
def move_view(button_direction, pressed):
    global view, article_length, start, max_onscreen, f, eof
    if pressed:
        if button_direction == "down":
            start_position = view[0] + 1
            action = "next"
        elif button_direction == "up":
            start_position = view[0] - 1
            action = "next"
        elif button_direction == "right":
            start_position = view[1]
            action = "next"
        elif button_direction == "left":
            start_position = view[0]
            action = "prev"
        else:
            raise ValueError("this direction doesn't exist")
        if start_position <= 0:
            start_position = 0
            action = "next"
        elif start_position >= article_length:
            start_position = article_length
            action = "prev"
        if start_position + max_onscreen >= article_length:
            if f:
                ugfx.fill_circle(291, 5, 10, ugfx.BLACK)
                ugfx.flush()
                if not eof:
                    if not read_data():
                        eof = True
                        print('EOF')
            else:
                print('File not yet read!')
        print("scroll: " + str(start_position) + " " + str(article_length))
        view = create_view(start_position, action)
Example #3
0
def drawui():
    ugfx.init()
    buttons.init()
    ugfx.clear(ugfx.html_color(0x87F717))

    ugfx.set_default_font(ugfx.FONT_MEDIUM)

    ugfx.fill_circle(50,50, 20, ugfx.WHITE)
    ugfx.fill_circle(50, 100, 20, ugfx.WHITE)

    ugfx.text(45, 45, "A", ugfx.RED)
    ugfx.text(45, 95, "B", ugfx.RED)

    ugfx.text(95, 45, "Flash the lights", ugfx.WHITE)
    ugfx.text(95, 95, "Disco Inferno", ugfx.WHITE)

    ugfx.fill_polygon(270,50, [ [0,0], [40,0], [40, 175], [0, 175] ], ugfx.RED)#  , [230, 100], [230, 60]
    ugfx.fill_polygon(270,50, [ [0,0], [-20,10], [-20, 50], [0, 40] ], ugfx.RED)#  , [230, 100], [230, 60]

    ugfx.area(283, 61, 14, 10, ugfx.WHITE)
    ugfx.area(283, 79, 14, 10, ugfx.WHITE)
    ugfx.area(283, 97, 14, 10, ugfx.WHITE)
    ugfx.area(283, 115, 14, 10, ugfx.WHITE)
    ugfx.area(283, 133, 14, 10, ugfx.WHITE)
    ugfx.area(283, 151, 14, 10, ugfx.WHITE)
    ugfx.area(283, 169, 14, 10, ugfx.WHITE)
    ugfx.area(283, 187, 14, 10, ugfx.WHITE)
Example #4
0
def room_7():
	###Room 7 - exits EW
	room=7
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,1,0,1)	
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
Example #5
0
def room_4():
	###Room 4 - exits west
	room=4
	print ("here")
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,0,0,1)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
Example #6
0
def room_6():
	###Room 6 - exits EW
	room=6
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,1,0,1)
	ugfx.area(90,100,20,20,ugfx.BLUE)
	
	ugfx.fill_circle(80,100,5,ugfx.YELLOW)
Example #7
0
def drawPageIndicator(amount, position):
    x = 5
    size = 4
    offset = 6
    for i in range(amount):
        if i == position:
            ugfx.fill_circle(x, ugfx.height() - 8, size, ugfx.BLACK)
        else:
            ugfx.circle(x, ugfx.height() - 8, size, ugfx.BLACK)
        x += size + offset
Example #8
0
def room_9():
	###Room 9 - exits NES
	room=9
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(1,0,0,0)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
	
	if not haskey1==1:
		ugfx.fill_circle(100,165,5,ugfx.GREEN)
Example #9
0
def room_1():
	### Room 1 - exit north
	room=1
	
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	
	build_room_walls(1,0,0,0)

	
	#corridor N
	ugfx.thickline(90,34,90,0,ugfx.WHITE,7,0)
	ugfx.thickline(110,34,110,0,ugfx.WHITE,7,0)

	#door
	ugfx.thickline(90,180,110,180,ugfx.BLUE,7,0)
	#PC
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
Example #10
0
def render_creation(at_func, creation, cursor_position=None):
    total_width = 0
    characters = []
    for (comp_name, comp_n) in [("ears", 0), ("eyes", 0), ("mouth", 0),
                                ("eyes", 1), ("ears", 1)]:
        comp = font[comp_name][creation[comp_name]]
        char = comp[comp_n % len(comp)]
        total_width += char.width()
        characters.append(char)

    height = font["mouth"][0][0].height()
    (at_x, at_y) = at_func(total_width, height)

    advance_x = at_x
    for i, char in enumerate(characters):
        char.render(advance_x, at_y)
        if i == cursor_position:
            ugfx.fill_circle(advance_x + char.width() // 2,
                             at_y + char.height() + 0, 5, ugfx.BLACK)
        advance_x += char.width()
    return (at_x, at_y, total_width, height)
Example #11
0
def room_5():
	###Room 5 - exits ES
	room=5
	global btn_a_presses
	btn_a_presses=0
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,1,1,0)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
	if orc2>0:
		ugfx.fill_circle(70,70,10,ugfx.GREEN)
	else:
		ugfx.fill_circle(70,70,10,ugfx.RED)
Example #12
0
def room_2():
	###Room 2 - exits south, west, east
	room=2
	
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,1,1,1)
	

	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
	if orc1>0:
		ugfx.fill_circle(130,70,10,ugfx.GREEN)
	else:
		ugfx.fill_circle(130,70,10,ugfx.RED)
Example #13
0
def room_8():
	###Room 8 - exits WS
	global btn_a_presses
	btn_a_presses=0
	room=8
	ugfx.clear(ugfx.BLACK)
	setup_right_menu()
	build_room_walls(0,0,1,1)
	ugfx.fill_circle(100,150,5,ugfx.YELLOW)
	
	if orc3>0:
		ugfx.fill_circle(70,70,20,ugfx.GREEN)
	else:
		ugfx.fill_circle(70,70,30,ugfx.RED)
Example #14
0
import ugfx
import time

ugfx.init()

ugfx.clear(ugfx.BLACK)

ugfx.fill_circle(60, 60, 50, ugfx.WHITE)
ugfx.fill_circle(60, 60, 40, ugfx.BLACK)
ugfx.fill_circle(60, 60, 30, ugfx.WHITE)
ugfx.fill_circle(60, 60, 20, ugfx.BLACK)
ugfx.fill_circle(60, 60, 10, ugfx.WHITE)

ugfx.thickline(1, 1, 100, 100, ugfx.WHITE, 10, 5)
ugfx.box(30, 30, 50, 50, ugfx.WHITE)

ugfx.string(150, 25, "STILL", "Roboto_BlackItalic24", ugfx.WHITE)
ugfx.string(130, 50, "Hacking", "PermanentMarker22", ugfx.WHITE)
len = ugfx.get_string_width("Hacking", "PermanentMarker22")
ugfx.line(130, 72, 144 + len, 72, ugfx.WHITE)
ugfx.line(140 + len, 52, 140 + len, 70, ugfx.WHITE)
ugfx.string(140, 75, "Anyway", "Roboto_BlackItalic24", ugfx.WHITE)

ugfx.flush()


def render(text, pushed):
    if (pushed):
        ugfx.string(100, 10, text, "PermanentMarker22", ugfx.WHITE)
    else:
        ugfx.string(100, 10, text, "PermanentMarker22", ugfx.BLACK)
Example #15
0
ugfx.init()

bgcolor = ugfx.BLACK
fgcolor = ugfx.YELLOW

ugfx.clear(bgcolor)
ugfx.backlight(20)

buttons.init()

t4 = pyb.Timer(4, freq=100, mode=pyb.Timer.CENTER)


while not buttons.is_pressed("BTN_MENU"):
    accel = imu.get_acceleration()
    accel_x = accel.get('x')
    accel_y = accel.get('y')
    accel_z = accel.get('z')
    accel_use = accel_y
    t4.freq(700 + accel_use * 200)
    ch1 = t4.channel(1, pyb.Timer.PWM, pin=pyb.Pin("BUZZ"), pulse_width=(t4.period() + 1) // 2)
    #ugfx.text(10,10,str(accel),ugfx.GREEN)
    ugfx.fill_circle(160, 120, 45 + int(accel_use * 45), fgcolor)
    pyb.delay(100);
    ugfx.clear(bgcolor)

ugfx.clear(ugfx.BLACK)

pyb.Pin("BUZZ", pyb.Pin.OUT).low()

Example #16
0
WHITES = 20
PUPIL = 5
GRAVITY = -1 #1 = googley eyes, -1 = staring into your soul
MAX_ACC = 10

def clamp(val, minmax):
    if val < -minmax:
        val = -minmax
    if val > minmax:
        val = minmax
    return val

while True:
    pyb.wfi()
    ival = imu.get_acceleration()
    xoff = clamp(int(ival['x']*10*GRAVITY), MAX_ACC)
    yoff = clamp(int(ival['y']*10*GRAVITY), MAX_ACC)
    for i in EYES:
        ugfx.fill_circle(i[0], i[1], WHITES, ugfx.WHITE)
        ugfx.fill_circle(i[0]+xoff, i[1]+yoff, PUPIL, ugfx.BLACK)

    if buttons.is_triggered("BTN_MENU") or buttons.is_triggered("BTN_A") or buttons.is_triggered("BTN_B") or buttons.is_triggered("JOY_CENTER"):
        break;

    pyb.delay(100)

ugfx.clear()



Example #17
0
        i += 1
        changed = True
    elif Buttons.is_pressed(Buttons.JOY_Left) and (i > 0):
        i -= 1
        changed = True

    if Buttons.is_pressed(Buttons.JOY_Down) and (j < (ugfx.height() - 1)):
        j += 1
        changed = True
    elif Buttons.is_pressed(Buttons.JOY_Up) and (j > 0):
        j -= 1
        changed = True

    if Buttons.is_pressed(Buttons.JOY_Center):
        circleSize += 1
        ugfx.fill_circle(i, j, circleSize, ugfx.WHITE)
        changed = True
    else:
        circleSize = 3

    if Buttons.is_pressed(Buttons.BTN_A):
        reset()

    if changed:
        ugfx.area((oldI - 1) if oldI > 0 else 0, (oldJ - 1) if oldJ > 0 else 0,
                  3 if (oldI > 0 and oldI < (ugfx.width() - 1)) else 2, 3 if
                  (oldJ > 0 and oldJ < (ugfx.height() - 1)) else 2, ugfx.WHITE)
        ugfx.area((i - 1) if i > 0 else 0, (j - 1) if j > 0 else 0, 3 if
                  (i > 0 and i < (ugfx.width() - 1)) else 2, 3 if
                  (j > 0 and j < (ugfx.height() - 1)) else 2, ugfx.GREY)
Example #18
0
        i += 1
        changed = True
    elif Buttons.is_pressed(Buttons.JOY_Left) and (i > 0):
        i -= 1
        changed = True

    if Buttons.is_pressed(Buttons.JOY_Down) and (j < (maxHeight - 1)):
        j += 1
        changed = True
    elif Buttons.is_pressed(Buttons.JOY_Up) and (j > 0):
        j -= 1
        changed = True

    if Buttons.is_pressed(Buttons.JOY_Center):
        circleSize += 1
        ugfx.fill_circle(i, j, circleSize, colour)
        showColourChangeMenu()

    if Buttons.is_pressed(Buttons.BTN_A):
        circleSize = 3
        reset()

    if Buttons.is_pressed(Buttons.BTN_Menu):
        colour = selectColour()
        circleSize = 3

    if changed:
        circleSize = 3
        ugfx.area((oldI - 1) if oldI > 0 else 0, (oldJ - 1) if oldJ > 0 else 0,
                  3 if (oldI > 0 and oldI < (ugfx.width() - 1)) else 2, 3 if
                  (oldJ > 0 and oldJ < (maxHeight - 1)) else 2, colour)
Example #19
0
				room=8
				room_8()
		if buttons.is_triggered("BTN_A"):
			btn_a_presses+=1
			if room == 2:
				ugfx.area(190,30,300,180, ugfx.BLACK)
				if btn_a_presses==1:
					ugfx.text(190, 30, "With which leg?", ugfx.RED)
					ugfx.text(190, 50, "A: Left", ugfx.RED)
					ugfx.text(190, 70, "B: Right", ugfx.RED)
					ugfx.text(190, 90, "Joy Press: Middle", ugfx.RED)
				
				elif (btn_a_presses>1 and orc1 > 0 and hp >0):
					orc1,hp=orc_kicking(6, orc1, hp)
					if orc1<=0:
						ugfx.fill_circle(130,70,10,ugfx.RED)	
				
				elif (orc1<=0 and hp>0):
					ugfx.text(190, 30, "The orc is dead.", ugfx.RED)
					ugfx.text(190, 50, "It would be mean ", ugfx.RED)
					ugfx.text(190, 70, "to kick it again.", ugfx.RED)
				elif (hp>=0):
					game_over("Arrogance is death!")
					break
			elif room==5:
				ugfx.area(190,30,300,180, ugfx.BLACK)
				if btn_a_presses==1:
					ugfx.text(190, 30, "With which leg?", ugfx.RED)
					ugfx.text(190, 50, "A: Left", ugfx.RED)
					ugfx.text(190, 70, "B: Right", ugfx.RED)
					ugfx.text(190, 90, "Joy Press: Middle", ugfx.RED)
Example #20
0
 def draw(self):
     ugfx.fill_circle(self.x, self.y, QUADCOPTER_BODY_SIZE*2, ugfx.GRAY)
     ugfx.line(self.x, self.y+(QUADCOPTER_BODY_SIZE), self.x, self.y+QUADCOPTER_BODY_SIZE*3, ugfx.BLACK)
     ugfx.area(self.x-5, self.y+QUADCOPTER_BODY_SIZE*3, QUADCOPTER_BODY_SIZE*2, QUADCOPTER_BODY_SIZE, self.color)
     draw_crosshair(crosshair_x, crosshair_y)