Updated sphero salesforce example with bankruptcy and changeDirection.

This commit is contained in:
Edgar O Silva 2013-11-17 23:37:46 -06:00
parent 8717ea5f98
commit f8b822e852
1 changed files with 11 additions and 3 deletions

View File

@ -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)