From f8b822e852acb19e86b749647776da769220aca0 Mon Sep 17 00:00:00 2001 From: Edgar O Silva Date: Sun, 17 Nov 2013 23:37:46 -0600 Subject: [PATCH] Updated sphero salesforce example with bankruptcy and changeDirection. --- examples/sphero-pebble-sf.coffee | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/sphero-pebble-sf.coffee b/examples/sphero-pebble-sf.coffee index c82c081..ca0ddec 100644 --- a/examples/sphero-pebble-sf.coffee +++ b/examples/sphero-pebble-sf.coffee @@ -68,19 +68,27 @@ class SpheroRobot robot.roll 90, Math.floor(Math.random() * 360) @payingPower = true - work: (me) -> - every 1.seconds(), () -> + bankrupt: () -> + every 3.seconds(), () -> me.totalBucks-- if payingPower and me.totalBucks > 0 if me.totalBucks == 0 - me.sphero.setRGB(0x0000FF, me) + me.sphero.setRGB(0xFF0000, me) me.sphero.stop() + changeDirection: () + every 1.seconds(), () -> + me.sphero.roll 90, Math.floor(Math.random() * 360) if @payingPower + + work: (me) -> + me.sphero.on 'connect', -> Logger.info('Setting up Collision Detection...') me.sphero.detectCollisions() me.sphero.stop() me.sphero.setRGB(0x00FF00) me.sphero.roll 90, Math.floor(Math.random() * 360) + me.bankrupt() + me.changeDirection() me.sphero.on 'collision', (data) -> me.sphero.setRGB(0x0000FF, me)