device.add_text( id='y', pos_x=-5, pos_y=20, text=f'y = {0}', rotate=-90 ) for y in range(8): device.update_text( id='y', text=f'y = {y}', pos_y=y * 20 + 5 ) for x in range(8): device.update_text( id='x', text=f'x = {x}', pos_x=x * 20 + 5 ) device.add_square( pos_x=x * 20, pos_y=y * 20, size=20, color=color(x, y), clickable=True ) device.sleep(0.6) device.disconnect()
import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from smartphone_connector import Connector from examples.server_address import SERVER_ADDRESS device = Connector(SERVER_ADDRESS, 'FooBar') while True: device.set_color('yellow') device.sleep(0.5) device.set_color('black') device.sleep(0.5)
height=100, origin_x=50, origin_y=50 ) id = device.add_circle( pos_x=0, pos_y=40, radius=5, color=Colors.RED, direction=[0, -1], speed=1, time_span=4 ) device.sleep(3) speed = 1 device.update_circle( id=id, movements={ 'repeat': 2, 'movements': [ { 'movement': 'relative', 'direction': [1, 0], 'distance': 10, 'speed': speed }, {
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from smartphone_connector import Connector, Colors from examples.server_address import SERVER_ADDRESS from math import sin, cos DT = 2 device = Connector(SERVER_ADDRESS, 'FooBar') device.clear_playground() device.configure_playground(width=100, height=100, shift_x=-50, shift_y=-50, color='lightblue') device.add_sprite(id='circler', height=10, width=10, form='round', speed=1, color='yellow') angle = 0 while True: device.update_sprite(id='circler', direction=[cos(angle), sin(angle)], color=Colors.next()) angle += 0.4 device.sleep(0.05)
import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from smartphone_connector import Connector, Colors from examples.server_address import SERVER_ADDRESS device = Connector(SERVER_ADDRESS, 'FooBar') score = 0 device.clear_playground() device.configure_playground( width=100, height=60, images='images', color=Colors.ALICEBLUE, image='waterfall' ) device.add_sprite( id='cookie', width=20, height=20, pos_x=10, pos_y=10, image='cookie' ) for rotation in range(360): device.update_sprite(id='cookie', rotate=rotation) device.sleep(0.1) device.disconnect()
import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from smartphone_connector import Connector from examples.server_address import SERVER_ADDRESS device = Connector(SERVER_ADDRESS, 'FooBar') d = device.latest_acceleration() drink = device.select('Was wosch trinkä?', ['Pingusirup', 'Wasser', 'Orangensaft']) food = device.select('Was wosch ässä?', ['Fischstäbli', 'Cordonblö', 'Zürigschnätzlets']) device.print(f'Bestellung: {food} mit {drink}', display_time=3) device.sleep(0.3) device.disconnect()
width=100, height=100, origin_x=50, origin_y=50 ) id = device.add_circle( pos_x=0, pos_y=0, radius=5, color=Colors.RED ) pos_x = 0 def on_key(data: KeyMsg): global pos_x if (data.key == 'right'): device.move_to(id, [pos_x + 5, 0], time=1, via=[pos_x + 2.5, 30]) pos_x = pos_x + 5 if (data.key == 'left'): device.move_to(id, [pos_x - 5, 0], time=1, via=[pos_x - 2.5, 30]) pos_x = pos_x - 5 device.on('key', on_key) device.on('auto_movement_pos', lambda d: print(d.object)) device.sleep()
import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from examples.server_address import SERVER_ADDRESS from smartphone_connector import Connector device = Connector(SERVER_ADDRESS, 'FooBar') device.clear_playground() device.configure_playground(100, 100, 50, 50, color="white") device.add_circle(pos_x=0, pos_y=0, radius=5, color='red') device.add_square(pos_x=0, pos_y=0, size=10, color='yellow', text='hi', clickable=True) device.add_rectangle(pos_x=-20, pos_y=-40, width=10, height=5, color='orange', text='hi', clickable=True, z_index=999) device.add_circle(pos_x=0, pos_y=0, radius=13, color='green', clickable=True) device.add_square(pos_x=15, pos_y=0, size=10, color='red', anchor=[0.5, 0.5]) device.add_text(text='1', pos_x=-20, pos_y=10) device.add_text(text='1', pos_x=-20, pos_y=10, background_color='unset') device.add_text(text='Hello', pos_x=-20, pos_y=0, border_color='red') device.add_text(text='Hello', pos_x=-20, pos_y=0, border_color='red', rotate=90, anchor=[0, 1]) device.add_text(text='Hello My Friend', pos_x=-20, pos_y=-10, clickable=True) device.add_text(text='Hello There', pos_x=-40, pos_y=-40, font_color='white', font_size=10) device.add_text(text='Hello There', pos_x=-40, pos_y=-40, font_color='white', font_size=10, rotate=-90) device.on_sprite_clicked = lambda x: print(x) device.sleep(10) device.disconnect()