danishkirel-turtle 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 1
4
+ :patch: 2
@@ -0,0 +1,8 @@
1
+ require 'turtle'
2
+
3
+ runner
4
+ vor(40)
5
+ rechts(90)
6
+ vor(20)
7
+ links(90)
8
+ vor(10)
@@ -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 = 0.0
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 PI*@@angle/180
23
- dy = sin PI*@@angle/180
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,@@y
27
+ glVertex2f @@x,-@@y
28
28
  @@x += l*dx
29
29
  @@y += l*dy
30
- glVertex2f @@x,@@y
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 rechts w
40
- @@actions << lambda { @@angle -= w % 360 }
39
+ def links(w)
40
+ @@actions << lambda { @@angle = (@@angle + w) % 360 }
41
41
  end
42
42
 
43
- def links(w)
44
- @@actions << lambda { rechts(-w) }
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.1
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