birdbrain 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -1
- data/lib/birdbrain/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57430481a0680c019369bcb21d0964dbe9b29da6ed5c30b2c7b85e44c872602a
|
4
|
+
data.tar.gz: cdd7f4fde44394b07885fd10ad9d655e4a7fe6fe83d02d36faec8e6068069825
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a74a4bb565cbb1f1c52bcc84cec3e58f51a69f7dfa2f5dee2580521356852e815d2b944bbc9f570d79a9f7dfcf63a7d7514c90439e23f13f35f0db0a0411e9c
|
7
|
+
data.tar.gz: 1663ed637c26fa02dd6eff6f8d8533fc3cfbaea209e885ede6e9447a14f52f11080e111a99f33cdac20b33ae152b6c1a2afef00f1a35e1579a92ea1fc57c0f54
|
data/README.md
CHANGED
@@ -28,7 +28,60 @@ The library is distributed through https://rubygems.org/gems/birdbrain/
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
|
31
|
+
Below are two examples causing a Finch 2 to move in the path of a box. The first example is the long way to do it:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'birdbrain'
|
35
|
+
|
36
|
+
finch = BirdbrainFinch.connect('A')
|
37
|
+
|
38
|
+
finch.beak(0, 50, 0)
|
39
|
+
|
40
|
+
finch.tail(1, 0, 50, 0)
|
41
|
+
finch.move(BirdbrainFinch::FORWARD, 2, 20)
|
42
|
+
finch.turn(BirdbrainFinch::LEFT, 90, 50)
|
43
|
+
|
44
|
+
finch.tail(2, 0, 50, 0)
|
45
|
+
finch.move(BirdbrainFinch::FORWARD, 2, 20)
|
46
|
+
finch.turn(BirdbrainFinch::RIGHT, 90, 50)
|
47
|
+
finch.tail(3, 0, 50, 0)
|
48
|
+
|
49
|
+
finch.move(BirdbrainFinch::BACKWARD, 2, 20)
|
50
|
+
finch.turn(BirdbrainFinch::RIGHT, 90, 50)
|
51
|
+
finch.tail(4, 0, 50, 0)
|
52
|
+
|
53
|
+
finch.move(BirdbrainFinch::FORWARD, 2, 20)
|
54
|
+
finch.turn(BirdbrainFinch::LEFT, 90, 50)
|
55
|
+
sleep(1)
|
56
|
+
|
57
|
+
finch.disconnect
|
58
|
+
```
|
59
|
+
|
60
|
+
The second way has the same result, but is more concise:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
require 'birdbrain'
|
64
|
+
|
65
|
+
def draw(finch, step, move_direction, turn_direction)
|
66
|
+
finch.tail(step, 0, 50, 0)
|
67
|
+
finch.move(move_direction, 2, 20)
|
68
|
+
finch.turn(turn_direction, 90, 50)
|
69
|
+
end
|
70
|
+
|
71
|
+
finch = BirdbrainFinch.connect('A')
|
72
|
+
|
73
|
+
finch.beak(0, 50, 0)
|
74
|
+
|
75
|
+
draw(finch, 1, BirdbrainFinch::FORWARD, BirdbrainFinch::LEFT)
|
76
|
+
draw(finch, 2, BirdbrainFinch::FORWARD, BirdbrainFinch::RIGHT)
|
77
|
+
draw(finch, 3, BirdbrainFinch::BACKWARD, BirdbrainFinch::RIGHT)
|
78
|
+
draw(finch, 4, BirdbrainFinch::FORWARD, BirdbrainFinch::LEFT)
|
79
|
+
sleep(1)
|
80
|
+
|
81
|
+
finch.disconnect
|
82
|
+
```
|
83
|
+
|
84
|
+
Rdoc files are available at https://rdoc.info/github/fmorton/BirdBrain-Ruby-Library/
|
32
85
|
|
33
86
|
## Development
|
34
87
|
|
data/lib/birdbrain/version.rb
CHANGED