sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from smartphone_connector import Connector, SpriteClickedMsg, Colors from examples.server_address import SERVER_ADDRESS device = Connector(SERVER_ADDRESS, 'FooBar') score = 0 device.clear_playground() device.configure_playground(width=100, height=180, color=Colors.ALICEBLUE, images='images') device.add_sprite(id='score', pos_x=0, pos_y=160, height=20, width=30, text=f'Score: {score}', form='rectangle', color=Colors.LIGHTBLUE) device.add_sprite(id='cookie', pos_x=30, pos_y=40, height=30, width=30, form='rectanle', color=Colors.BROWN, clickable=True, image='firefox') def on_sprite_clicked():
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()
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)
color='yellow', form='round', height=7, width=7, collision_detection=True, pos_x=50 + SHIFT_X, pos_y=50 + SHIFT_Y) add(id='player3', color='yellow', form='round', height=4, width=4, collision_detection=True, pos_x=70 + SHIFT_X, pos_y=70 + SHIFT_Y) sprite_count = 0 while True: sprite_count += 1 device.sleep(0.5) w = randint(2, 10) device.add_sprite(color=random_color(), direction=[0, -1], form='round', height=randint(2, 10), width=w, id=f'asdfa{sprite_count}', pos_x=randint(0, WIDTH - w) + SHIFT_X, pos_y=HEIGHT + SHIFT_Y, speed=randint(1, 60) / 10)