danishkirel-turtle 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +12 -0
- data/VERSION.yml +1 -1
- data/examples/line.rb +8 -0
- data/lib/turtle.rb +9 -9
- metadata +3 -1
data/README.rdoc
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
A turtle crouching on the floor.
|
4
4
|
|
5
|
+
You get a 640x480 pane (coordinates from -319 to 320 and -239 to 240) to draw on.
|
6
|
+
Start at (0,0) looking up.
|
7
|
+
|
8
|
+
require('turtle')
|
9
|
+
|
10
|
+
runner
|
11
|
+
vor(20)
|
12
|
+
links(45)
|
13
|
+
vor(70)
|
14
|
+
ruff
|
15
|
+
|
16
|
+
|
5
17
|
== Copyright
|
6
18
|
|
7
19
|
Copyright (c) 2009 danishkirel. See LICENSE for details.
|
data/VERSION.yml
CHANGED
data/examples/line.rb
ADDED
data/lib/turtle.rb
CHANGED
@@ -5,7 +5,7 @@ include Math
|
|
5
5
|
module Turtle
|
6
6
|
|
7
7
|
@@r, @@g, @@b = 0.0, 0.0, 0.0
|
8
|
-
@@angle =
|
8
|
+
@@angle = 90.0
|
9
9
|
@@x, @@y = 0.0, 0.0
|
10
10
|
@@paint = false
|
11
11
|
@@actions = []
|
@@ -19,15 +19,15 @@ module Turtle
|
|
19
19
|
# sin = y, cos = x
|
20
20
|
def vor l
|
21
21
|
@@actions << lambda do
|
22
|
-
dx = cos
|
23
|
-
dy = sin
|
22
|
+
dx = cos(PI*@@angle/180)
|
23
|
+
dy = sin(PI*@@angle/180)
|
24
24
|
if @@paint
|
25
25
|
glBegin GL_LINE_STRIP
|
26
26
|
glColor3f @@r, @@g, @@b
|
27
|
-
glVertex2f @@x
|
27
|
+
glVertex2f @@x,-@@y
|
28
28
|
@@x += l*dx
|
29
29
|
@@y += l*dy
|
30
|
-
glVertex2f @@x
|
30
|
+
glVertex2f @@x,-@@y
|
31
31
|
glEnd
|
32
32
|
else
|
33
33
|
@@x += l*dx
|
@@ -36,12 +36,12 @@ module Turtle
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
@@actions << lambda { @@angle
|
39
|
+
def links(w)
|
40
|
+
@@actions << lambda { @@angle = (@@angle + w) % 360 }
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
43
|
+
def rechts(w)
|
44
|
+
links(-w)
|
45
45
|
end
|
46
46
|
|
47
47
|
def ruff
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danishkirel-turtle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- danishkirel
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- VERSION.yml
|
39
39
|
- examples/figures.rb
|
40
|
+
- examples/line.rb
|
40
41
|
- lib/turtle.rb
|
41
42
|
- test/test_helper.rb
|
42
43
|
- test/turtle_test.rb
|
@@ -70,3 +71,4 @@ test_files:
|
|
70
71
|
- test/test_helper.rb
|
71
72
|
- test/turtle_test.rb
|
72
73
|
- examples/figures.rb
|
74
|
+
- examples/line.rb
|