kame 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,117 +1,129 @@
1
1
  kame (Japanese for turtle)
2
2
  ==========================
3
3
 
4
- Kame is an implementation of the Logo programming language built as a challenge to myself. I wanted a simple way to introduce programming in Ruby to my daughter and thought this would be fun.
4
+ kame is an implementation of the Logo programming language built as a challenge to myself. I wanted a simple way to introduce programming in Ruby to my daughter and thought this would be fun.
5
5
 
6
- With Kame, you control the movement of a turtle around a piece of paper by programming commands. With these simple commands your turtle will draw you a picture.
6
+ With kame, you control the movement of a turtle around a piece of paper by programming commands. With these simple commands your turtle will draw you a picture.
7
7
 
8
8
  It's a nice introduction to programming for kids and will also help their maths :o)
9
9
 
10
10
  What it does
11
11
  ------------
12
12
 
13
- You create a Ruby file with commands that instructs a turtle (kame) to move around. You can tell the turtle to move forward or backward, rotate, put his pen down on the paper or pick it up. You can also change the colour of the pen and background.
13
+ You create a Ruby file with commands that instructs a turtle (kame) to move around. You can tell the turtle to move forward or backward, rotate, put his pen down on the paper or pick it up. You can also change the colour of the pen and paper.
14
14
 
15
- The turtle starts in the top left corner of the kame window and will move from there depending on your commands.
15
+ The turtle starts in the top left corner of the kame window facing to the right and will move from there depending on your commands.
16
16
 
17
17
  Each command is on a new line and they are executed in order.
18
18
 
19
- As this is using ruby, you also have access to Ruby constructs such as loops and functions.
19
+ As this is using Ruby, you also have access to Ruby constructs such as loops and functions.
20
+
21
+ Notice
22
+ ------
23
+
24
+ I've tested this on OSX and it works fine. However, there seems to be an issue on Windows 7 when creating the Gosu window. I'll investigate.
20
25
 
21
26
  Install
22
27
  -------
23
28
 
24
- gem install kame
29
+ gem install kame
25
30
 
26
31
  Simple Sample
27
32
  -------------
28
33
 
29
34
  Create a new text file called square.rb and paste the below code in and save it:
30
35
 
31
- require "kame"
32
-
33
- Kame.new do
34
- forward 100
35
- turn_right 90
36
- forward 100
37
-
38
- colour :red
39
- pen_down
40
-
41
- 4.times do
42
- turn_right 90
43
- forward 50
44
- end
45
- end
36
+ require "kame"
37
+
38
+ Kame.new do
39
+ forward 100
40
+ turn_right 90
41
+ forward 100
42
+
43
+ colour :red
44
+ pen_down
45
+
46
+ 4.times do
47
+ turn_right 90
48
+ forward 50
49
+ end
50
+ end
51
+
52
+ More samples
53
+ ------------
54
+
55
+ You can find more samples in my [kame_samples](https://github.com/andypike/kame_samples) repro. One of which is this little flower <3
56
+
57
+ ![kame flower](https://github.com/andypike/kame_samples/raw/master/kame-flower.png)
46
58
 
47
59
  Running
48
60
  -------
49
61
 
50
62
  In the console use this:
51
63
 
52
- ruby square.rb
64
+ ruby square.rb
53
65
 
54
66
  Commands
55
67
  --------
56
68
 
57
69
  To move the turtle forward by 50 pixels from it's current position, you can use the `forward` command:
58
70
 
59
- forward 50
71
+ forward 50
60
72
 
61
73
  To move the turtle backward by 75 pixels from it's current position, you can use the `backward` command:
62
74
 
63
- backward 75
75
+ backward 75
64
76
 
65
77
  To tell the turtle to put his pen down onto the paper use the `pen_down` command:
66
78
 
67
- pen_down
79
+ pen_down
68
80
 
69
81
  To tell the turtle to pick his pen up again, use the `pen_up` command:
70
82
 
71
- pen_up
83
+ pen_up
72
84
 
73
85
  You can ask the turtle to rotate 90 degrees to the left (anti-clockwise) on the spot without moving by using the `turn_left` command:
74
86
 
75
- turn_left 90
87
+ turn_left 90
76
88
 
77
89
  You can ask the turtle to rotate 90 degrees to the right (clockwise) on the spot without moving by using the `turn_right` command:
78
90
 
79
- turn_right 90
91
+ turn_right 90
80
92
 
81
93
  You can change the colour of the turtle's pen at any time (on the paper or not) with the `colour` command:
82
94
 
83
- colour :pink
95
+ colour :pink
84
96
 
85
97
  Colours
86
98
  -------
87
99
 
88
100
  Here is a list of the available colours:
89
101
 
90
- :white
91
- :black
92
- :red
93
- :green
94
- :blue
95
- :yellow
96
- :pink
97
- :grey
102
+ :white
103
+ :black
104
+ :red
105
+ :green
106
+ :blue
107
+ :yellow
108
+ :pink
109
+ :grey
98
110
 
99
111
  Options
100
112
  -------
101
113
 
102
114
  In addition to commanding the turtle, there are some options you can specify. You pass these options to the Kame constructor like so:
103
115
 
104
- Kame.new(:width => 800, :height => 600) do
105
- ...
106
- end
116
+ Kame.new(:width => 800, :height => 600) do
117
+ ...
118
+ end
107
119
 
108
120
  Here is a list of all options with their default values (all are optional):
109
121
 
110
- :width => 640 # The width of the paper in pixels
111
- :height => 480 # The height of the paper in pixels
112
- :paper => :white # The colour of the paper (from the list above)
113
- :title => 'Kame' # The window title
114
- :speed => 10 # The speed that the turtle draws. This is how many lines per second should be drawn
122
+ :width => 640 # The width of the paper in pixels
123
+ :height => 480 # The height of the paper in pixels
124
+ :paper => :white # The colour of the paper (from the list above)
125
+ :title => 'Kame' # The window title
126
+ :speed => 10 # The speed that the turtle draws. This is how many lines per second should be drawn
115
127
 
116
128
 
117
129
  Contributing to kame
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
data/kame.gemspec ADDED
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "kame"
8
+ s.version = "0.4.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Andy Pike"]
12
+ s.date = "2011-11-11"
13
+ s.description = "Kame (Japanese for turtle) is an implementation of the Logo programming language built as a challenge to myself. I wanted a simple way to introduce programming in Ruby to my daughter and thought this would be fun. With Kame, you control the movement of a turtle around the screen by programming commands. With these simple commands your turtle will draw you a picture. It's a nice introduction to programming for kids and will also help their maths :o)"
14
+ s.extra_rdoc_files = [
15
+ "LICENSE.txt",
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "LICENSE.txt",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "kame.gemspec",
27
+ "lib/kame.rb",
28
+ "lib/kame/kame_colours.rb",
29
+ "lib/kame/kame_window.rb"
30
+ ]
31
+ s.homepage = "http://github.com/andypike/kame"
32
+ s.licenses = ["MIT"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = "1.8.10"
35
+ s.summary = "Kame (Japanese for turtle) is an implementation of the Logo programming language for kids"
36
+
37
+ if s.respond_to? :specification_version then
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
+ s.add_runtime_dependency(%q<gosu>, [">= 0"])
42
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
43
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
44
+ else
45
+ s.add_dependency(%q<gosu>, [">= 0"])
46
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
47
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<gosu>, [">= 0"])
51
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
53
+ end
54
+ end
55
+
data/lib/kame.rb CHANGED
@@ -9,7 +9,7 @@ class Kame
9
9
  :x => 0,
10
10
  :y => 0,
11
11
  :rotation => 0,
12
- :line_colour => KameColours::lookup[:white]
12
+ :line_colour => KameColours::lookup[:black]
13
13
  }
14
14
 
15
15
  opts = {
@@ -22,7 +22,7 @@ class Kame
22
22
 
23
23
  instance_eval(&block)
24
24
 
25
- window = KameWindow.new(@lines, opts).show
25
+ KameWindow.new(@lines, opts).show
26
26
  end
27
27
 
28
28
  def pen_up
@@ -22,13 +22,13 @@ class KameWindow < Gosu::Window
22
22
  end
23
23
 
24
24
  def update
25
- @this_frame = Gosu::milliseconds
26
- @seconds_since_last_frame = (@this_frame - @first_frame) / 1000.0
25
+ @this_frame = Gosu::milliseconds
26
+ @seconds_since_last_frame = (@this_frame - @first_frame) / 1000.0
27
27
  end
28
28
 
29
29
  def draw
30
30
  self.draw_background
31
- return if @lines.nil? || @lines.count == 0
31
+ return if @lines.nil? || @lines.count == 0 || @seconds_since_last_frame.nil?
32
32
 
33
33
  max = (@seconds_since_last_frame * @speed).round
34
34
  if max > @lines.count - 1
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kame
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.0
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andy Pike
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-11-10 00:00:00 Z
13
+ date: 2011-11-11 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gosu
@@ -62,6 +62,7 @@ files:
62
62
  - README.md
63
63
  - Rakefile
64
64
  - VERSION
65
+ - kame.gemspec
65
66
  - lib/kame.rb
66
67
  - lib/kame/kame_colours.rb
67
68
  - lib/kame/kame_window.rb
@@ -78,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
79
  requirements:
79
80
  - - ">="
80
81
  - !ruby/object:Gem::Version
81
- hash: -1997320679435807352
82
+ hash: 3112740880397074236
82
83
  segments:
83
84
  - 0
84
85
  version: "0"