예제 #1
0
def move():
	global board_position_bottom
	mv_y = readCH(vry_channel)
	mv = 0
	# to avoid small variances
	if mv_y > 530 or mv_y < 500:
		mv = ((mv_y+1) - 512) / -float(512)
	board_position_bottom = min( max(0, board_position_bottom + mv ), 8*LEDMatrix.MATRIX_HEIGHT - board_height )
	LEDMatrix.gfx_line( 8*LEDMatrix.MATRIX_WIDTH-1, int(round(board_position_bottom)), 8*LEDMatrix.MATRIX_WIDTH-1, int(round(board_position_bottom)) + board_height-1 , GFX_ON)
예제 #2
0
def moveCPU():
	global cpu_position_bottom
	# towards player
	if dot_dir[0] > 0:
		cpu_position_bottom = min(max(0, cpu_position_bottom + dot_dir[1]*0.5), 8*LEDMatrix.MATRIX_HEIGHT - board_height)
	# towards cpu
	else:
		if dot[1] > (cpu_position_bottom + board_height):
			cpu_position_bottom = min(max(0, cpu_position_bottom + cpu_speed), 8*LEDMatrix.MATRIX_HEIGHT - board_height)
		elif dot[1] < (cpu_position_bottom):
			cpu_position_bottom = min(max(0, cpu_position_bottom - cpu_speed), 8*LEDMatrix.MATRIX_HEIGHT - board_height)
	LEDMatrix.gfx_line( 0, int(round(cpu_position_bottom)), 0, int(round(cpu_position_bottom)) + board_height-1 , GFX_ON)
예제 #3
0
def move():
    global board_position_bottom
    mv_y = readCH(vry_channel)
    mv = 0
    # to avoid small variances
    if mv_y > 530 or mv_y < 500:
        mv = ((mv_y + 1) - 512) / -float(512)
    board_position_bottom = min(max(0, board_position_bottom + mv),
                                8 * LEDMatrix.MATRIX_HEIGHT - board_height)
    LEDMatrix.gfx_line(8 * LEDMatrix.MATRIX_WIDTH - 1,
                       int(round(board_position_bottom)),
                       8 * LEDMatrix.MATRIX_WIDTH - 1,
                       int(round(board_position_bottom)) + board_height - 1,
                       GFX_ON)
예제 #4
0
def moveCPU():
    global cpu_position_bottom
    # towards player
    if dot_dir[0] > 0:
        cpu_position_bottom = min(
            max(0, cpu_position_bottom + dot_dir[1] * 0.5),
            8 * LEDMatrix.MATRIX_HEIGHT - board_height)
    # towards cpu
    else:
        if dot[1] > (cpu_position_bottom + board_height):
            cpu_position_bottom = min(
                max(0, cpu_position_bottom + cpu_speed),
                8 * LEDMatrix.MATRIX_HEIGHT - board_height)
        elif dot[1] < (cpu_position_bottom):
            cpu_position_bottom = min(
                max(0, cpu_position_bottom - cpu_speed),
                8 * LEDMatrix.MATRIX_HEIGHT - board_height)
    LEDMatrix.gfx_line(0, int(round(cpu_position_bottom)), 0,
                       int(round(cpu_position_bottom)) + board_height - 1,
                       GFX_ON)
예제 #5
0
	
	# Display a clock
	LEDMatrix.gfx_set_all(GFX_OFF)
	clock = [[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
	centerX = 11	# position for the clockhand
	centerY = 11
	clockHandSec = 8 # length of the clockhand
	clockHandMin = 6
	clockHandHour = 5
	for s in range(30):
		sec = int(time.strftime('%S'))*6
		min = int(time.strftime('%M'))*6
		hour = int(time.strftime('%I'))*30 + int(time.strftime('%M'))/2
		LEDMatrix.gfx_set_all(GFX_OFF)
		LEDMatrix.gfx_sprite_array(clock,0,0,GFX_ON)
		LEDMatrix.gfx_line(centerX, centerY, centerX + math.sin(sec*(math.pi/180))*clockHandSec, centerY + math.cos(sec*(math.pi/180))*clockHandSec, GFX_ON)
		LEDMatrix.gfx_line(centerX, centerY, centerX + math.sin(min*(math.pi/180))*clockHandMin, centerY + math.cos(min*(math.pi/180))*clockHandMin, GFX_ON)
		LEDMatrix.gfx_line(centerX, centerY, centerX + math.sin(hour*(math.pi/180))*clockHandHour, centerY + math.cos(hour*(math.pi/180))*clockHandHour, GFX_ON)
		LEDMatrix.gfx_render()
		time.sleep(1)


	# Continuous marquee display
	diamonds = chr(4) * 5
	LEDMatrix.scroll_message_horiz([" This is the end of the demo " + diamonds, "                             Press <Ctrl><C> to end ",""], 0, 5)

except KeyboardInterrupt:
    # reset array
    LEDMatrix.scroll_message_horiz(["","Goodbye!",""], 1, 8)
    LEDMatrix.clear_all()