The examples shown at js.la
This commit is contained in:
parent
1064e75128
commit
c5392f3e19
|
@ -1,4 +1,4 @@
|
|||
var Cylon = require('..').instance();
|
||||
var Cylon = require('..');
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: 'looped', adaptor: 'loopback'},
|
||||
|
|
|
@ -8,26 +8,7 @@ Cylon.robot
|
|||
name: 'sphero', driver: 'sphero'
|
||||
|
||||
work: (me) ->
|
||||
|
||||
me.sphero.on 'close', (data) ->
|
||||
Logger.info 'THIS IS ME CLOSSING:'
|
||||
Logger.info data
|
||||
|
||||
me.sphero.on 'message', (data) ->
|
||||
Logger.info 'message:'
|
||||
Logger.info data
|
||||
|
||||
me.sphero.on 'notification', (data) ->
|
||||
Logger.info 'notification:'
|
||||
Logger.info data
|
||||
|
||||
me.sphero.detectCollisions()
|
||||
|
||||
color = 0x000050
|
||||
every 1.second(), ->
|
||||
me.sphero.roll(60, Math.floor(Math.random() * 360), 1)
|
||||
me.sphero.setRGB(color, true)
|
||||
color += 0x005000
|
||||
color = 0x000050 if color > 0xFFFFFF
|
||||
me.sphero.roll 60, Math.floor(Math.random() * 360)
|
||||
|
||||
.start()
|
||||
|
|
|
@ -8,13 +8,7 @@ Cylon.robot
|
|||
name: 'sphero', driver: 'sphero'
|
||||
|
||||
work: (me) ->
|
||||
me.nextColor = ->
|
||||
@color ?= 0x000050
|
||||
@color += 0x005000
|
||||
@color = 0x000050 if @color > 0xFFFFFF
|
||||
@color
|
||||
|
||||
every 1.second(), ->
|
||||
me.sphero.setRGB me.nextColor()
|
||||
me.sphero.setRGB Math.floor(Math.random() * 100000)
|
||||
|
||||
.start()
|
||||
|
|
|
@ -12,20 +12,16 @@ SpheroRobot =
|
|||
device:
|
||||
name: 'sphero', driver: 'sphero'
|
||||
|
||||
work: (self) ->
|
||||
color = 0x000050
|
||||
every 1.second(), ->
|
||||
#me.sphero.roll(60, Math.floor(Math.random() * 360), 1)
|
||||
Logger.info self.name
|
||||
self.sphero.setRGB(color, true)
|
||||
color += 0x005000
|
||||
color = 0x000050 if color > 0xFFFFFF
|
||||
work: (me) ->
|
||||
every 1.seconds(), ->
|
||||
Logger.info me.name
|
||||
me.sphero.setRGB Math.floor(Math.random() * 100000)
|
||||
me.sphero.roll 60, Math.floor(Math.random() * 360)
|
||||
|
||||
for bot in bots
|
||||
robot = Object.create(SpheroRobot)
|
||||
robot.connection.port = bot.port
|
||||
robot.name = bot.name
|
||||
|
||||
Cylon.robot robot
|
||||
|
||||
Cylon.start()
|
||||
|
|
Loading…
Reference in New Issue