コード例 #1
0
def point4():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.point(7,7,color=10)
    expected_fb = '''
        0000000A
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        '''
    return arrays_equal(expected_fb, fb)
コード例 #2
0
def point2():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.point((0,0), color=1)
    expected_fb = '''
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        10000000
        '''
    return arrays_equal(expected_fb, fb)
コード例 #3
0
def point3():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.point(1,2,color=3)
    expected_fb = '''
        00000000
        00000000
        00000000
        00000000
        00000000
        03000000
        00000000
        00000000
        '''
    return arrays_equal(expected_fb, fb)
コード例 #4
0
def point4():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.point(7, 7, color=10)
    expected_fb = '''
        0000000A
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        '''
    return arrays_equal(expected_fb, fb)
コード例 #5
0
def point3():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.point(1, 2, color=3)
    expected_fb = '''
        00000000
        00000000
        00000000
        00000000
        00000000
        03000000
        00000000
        00000000
        '''
    return arrays_equal(expected_fb, fb)
コード例 #6
0
def point2():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.point((0, 0), color=1)
    expected_fb = '''
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        10000000
        '''
    return arrays_equal(expected_fb, fb)
コード例 #7
0
def point1():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.point(0, 0)
    expected_fb = '''
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        F0000000
        '''
    return arrays_equal(expected_fb, fb)
コード例 #8
0
def point1():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.point(0,0)
    expected_fb = '''
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        00000000
        F0000000
        '''
    return arrays_equal(expected_fb, fb)
コード例 #9
0
    # Check for collision
    if missile_y == alien_row and missile_x in alien_columns:
        alien_columns.remove(missile_x)
        missile_x, missile_y = -1, -1
        if not alien_columns:
            break

    # ########################################
    # Show world
    # ########################################

    fb.erase()

    # Draw missile
    if missile_x >= 0:
        fb.point(missile_x, missile_y, MISSILE_COLOR)

    # Draw spaceship
    spaceship_x = round(spaceship_position) - spaceship_middle
    fb.draw(spaceship, origin=(spaceship_x, 0))

    # Draw aliens
    for column in alien_columns:
        fb.point(column, alien_row)

    # Show FrameBuffer on LED Matrix
    fb.show()
    time.sleep(0.001)

if alien_columns:
    print("Ouch!")
コード例 #10
0
from rstem.accel import Accel
from rstem.led_matrix import FrameBuffer
import time

fb = FrameBuffer()
accel = Accel()

TILT_FORCE = 0.1
STEP = 0.1
x, y = (3, 3)
while True:
    x_force, y_force, z_force = accel.forces()
    
    if x_force > TILT_FORCE:
        x -= STEP
    elif x_force < -TILT_FORCE:
        x += STEP

    fb.erase()
    fb.point(round(x), round(y))
    fb.show()
    
    time.sleep(.1)


コード例 #11
0
     if missile_y == alien_row and missile_x in alien_columns:
         alien_columns.remove(missile_x)
         missile_x, missile_y = -1, -1
         hit_sound.play()
         if not alien_columns:
             break
 
     # ########################################
     # Show world
     # ########################################
 
     fb.erase()
 
     # Draw missile
     if missile_x >= 0:
         fb.point(missile_x, missile_y, MISSILE_COLOR)
 
     # Draw spaceship
     spaceship_x = round(spaceship_position) - spaceship_middle
     fb.draw(spaceship, origin=(spaceship_x, 0))
 
     # Draw aliens
     for column in alien_columns:
         fb.point(column, alien_row)
 
     # Show FrameBuffer on LED Matrix
     fb.show()
     time.sleep(0.001)
 
 if alien_columns:
     print("Ouch!")
コード例 #12
0
from rstem.led_matrix import FrameBuffer

fb = FrameBuffer()

fb.erase()
fb.point(3, 0)
fb.show()
コード例 #13
0
while True:
    # ########################################
    # Get inputs
    # ########################################
    x_force, y_force, z_force = accel.forces()

    # ########################################
    # Change the World
    # ########################################

    # Move spaceship
    if x_force > TILT_FORCE:
        spaceship_position -= SPACESHIP_STEP
    elif x_force < -TILT_FORCE:
        spaceship_position += SPACESHIP_STEP
    spaceship_position = max(0, min(fb.width - 1, spaceship_position))

    # ########################################
    # Show world
    # ########################################

    fb.erase()

    # Draw spaceship
    fb.point(round(spaceship_position), 0)

    # Show FrameBuffer on LED Matrix
    fb.show()
    time.sleep(0.001)
コード例 #14
0
def out_of_bounds_point4():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.point(0, fb.height)
    return fb._framebuffer() == erased_fb()
コード例 #15
0
def out_of_bounds_point3():
    fb = FrameBuffer(matrix_layout=[(0, 0, 0)])
    fb.point(fb.width, 0)
    return fb._framebuffer() == erased_fb()
コード例 #16
0
def out_of_bounds_point3():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.point(fb.width, 0)
    return fb._framebuffer() == erased_fb()
コード例 #17
0
def out_of_bounds_point4():
    fb = FrameBuffer(matrix_layout=[(0,0,0)])
    fb.point(0, fb.height)
    return fb._framebuffer() == erased_fb()
コード例 #18
0
from rstem.led_matrix import FrameBuffer
import time

fb = FrameBuffer()

x, y = (3, 3)
while True:
    fb.erase()
    fb.point(x, y)
    fb.show()

    time.sleep(.1)
コード例 #19
0
mc = minecraft.Minecraft.create()

SCALE = 25
fb = FrameBuffer()

count = 0
FLASH_COUNT = 3
flash_lit = True
while True:
	pos = mc.player.getTilePos()

	x = round(pos.x/SCALE + (fb.width-1)/2)
	x_out_of_bounds = not 0 <= x < fb.width
	x = min(fb.width-1, max(0, x))

	z = round(pos.z/SCALE + (fb.height-1)/2)
	z_out_of_bounds = not 0 <= z < fb.height
	z = min(fb.height-1, max(0, z))

	fb.erase()
	count += 1
	if count > FLASH_COUNT:
		flash_lit = not flash_lit
		count = 0
	if not x_out_of_bounds and not z_out_of_bounds or flash_lit:
		fb.point(z, x)
	fb.show()

	time.sleep(0.01)
コード例 #20
0
    # ########################################
    x_force, y_force, z_force = accel.forces()

    # ########################################
    # Change the World
    # ########################################

    # Move spaceship
    if x_force > TILT_FORCE:
        spaceship_position -= SPACESHIP_STEP
    elif x_force < -TILT_FORCE:
        spaceship_position += SPACESHIP_STEP
    spaceship_position = max(0, min(fb.width - 1, spaceship_position))

    # ########################################
    # Show world
    # ########################################

    fb.erase()

    # Draw spaceship
    fb.point(round(spaceship_position), 0)

    # Draw aliens
    for column in alien_columns:
        fb.point(column, alien_row)

    # Show FrameBuffer on LED Matrix
    fb.show()
    time.sleep(0.001)
コード例 #21
0
    # Check for collision
    if missile_y == alien_row and missile_x in alien_columns:
        alien_columns.remove(missile_x)
        missile_x, missile_y = -1, -1
        if not alien_columns:
            break

    # ########################################
    # Show world
    # ########################################

    fb.erase()

    # Draw missile
    if missile_x >= 0:
        fb.point(missile_x, missile_y, MISSILE_COLOR)

    # Draw spaceship
    fb.point(round(spaceship_position), 0)

    # Draw aliens
    for column in alien_columns:
        fb.point(column, alien_row)

    # Show FrameBuffer on LED Matrix
    fb.show()
    time.sleep(0.001)

if alien_columns:
    print("Ouch!")
else:
コード例 #22
0
from rstem.accel import Accel
from rstem.led_matrix import FrameBuffer
import time

fb = FrameBuffer()
accel = Accel()

TILT_FORCE = 0.1
STEP = 0.1
x, y = (3, 3)
while True:
    x_force, y_force, z_force = accel.forces()
    
    if x_force > TILT_FORCE:
        x -= STEP
    elif x_force < -TILT_FORCE:
        x += STEP
    x = max(min(fb.width, x), 0)

    fb.erase()
    fb.point(round(x), round(y))
    fb.show()
    
    time.sleep(.1)


コード例 #23
0
mc = minecraft.Minecraft.create()

SCALE = 25
fb = FrameBuffer()

count = 0
FLASH_COUNT = 3
flash_lit = True
while True:
    pos = mc.player.getTilePos()

    x = round(pos.x / SCALE + (fb.width - 1) / 2)
    x_out_of_bounds = not 0 <= x < fb.width
    x = min(fb.width - 1, max(0, x))

    z = round(pos.z / SCALE + (fb.height - 1) / 2)
    z_out_of_bounds = not 0 <= z < fb.height
    z = min(fb.height - 1, max(0, z))

    fb.erase()
    count += 1
    if count > FLASH_COUNT:
        flash_lit = not flash_lit
        count = 0
    if not x_out_of_bounds and not z_out_of_bounds or flash_lit:
        fb.point(z, x)
    fb.show()

    time.sleep(0.01)
コード例 #24
0
from rstem.led_matrix import FrameBuffer
import time

fb = FrameBuffer()

x, y = (3, 3)
while True:
    fb.erase()
    fb.point(x, y)
    fb.show()
    
    time.sleep(.1)