if data.key == 'up': player.pos_y += DT device.update_sprite(id='player1', pos_y=player.pos_y) if data.key == 'down': player.pos_y -= DT device.update_sprite(id='player1', pos_y=player.pos_y) if data.key == 'home': if player.form == 'round': player.form = 'rectangle' else: player.form = 'round' device.update_sprite(id='player1', form=player.form) device.on_key = on_key device.on_sprite_collision = lambda data: print(data) device.configure_playground(width=100, height=100, shift_x=0, shift_y=0, color=Colors.ALICEBLUE) with device.add_sprites() as add: add(**player) add(color='red', direction=[1, 1], form='round', height=5, width=5, id='asdfa1', pos_x=0,
if data.collision_detection and data.border == 'bottom': device.update_sprite(id=data.id, color='red') def on_collision(data: SpriteCollisionMsg): if data.overlap == 'in' and data.sprites[ 0].collision_detection and data.sprites[1].collision_detection: device.update_sprite(id=data.sprites[0].id, color='pink') return for s in data.sprites: if not s.collision_detection: device.update_sprite(id=s.id, color='grey', text='x') device.on_key = on_key device.on_sprite_collision = on_collision device.on_border_overlap = on_overlap device.on_acceleration = on_acc device.clear_playground() device.configure_playground(width=WIDTH, height=HEIGHT, shift_x=SHIFT_X, shift_y=SHIFT_Y, color='red') with device.add_sprites() as add: add(id='player1', color='yellow', form='round', height=10,