training_wheels 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +2 -0
- data/bin/training_wheels +6 -0
- data/images/button.png +0 -0
- data/images/scorpion.png +0 -0
- data/lib/text.rb +24 -0
- data/lib/timer.rb +16 -0
- data/lib/training_wheels.rb +62 -0
- data/lib/training_wheels/version.rb +3 -0
- data/lib/word.rb +55 -0
- data/sounds/bottlerocket.wav +0 -0
- data/sounds/oh_no.wav +0 -0
- data/training_wheels.gemspec +23 -0
- metadata +116 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 j05h
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= Training Wheels
|
2
|
+
|
3
|
+
A Gosu gem to help teach kids. Currently it is only reading for kindergarteners.
|
4
|
+
|
5
|
+
== Features
|
6
|
+
|
7
|
+
$ gem install training_wheels
|
8
|
+
|
9
|
+
$ training_wheels
|
10
|
+
|
11
|
+
The game itself is trivial, but for now you need to play with your child.
|
12
|
+
There is a list of reading words which are used. The child must guess them
|
13
|
+
within the alloted time. If they do, simply hit the space bar, and they'll
|
14
|
+
get another word. If not, they lose points and continue. Knowing a word
|
15
|
+
3 times removes it from the list.
|
16
|
+
|
17
|
+
|
data/Rakefile
ADDED
data/bin/training_wheels
ADDED
data/images/button.png
ADDED
Binary file
|
data/images/scorpion.png
ADDED
Binary file
|
data/lib/text.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class Text
|
2
|
+
attr_accessor :value, :font, :color, :vertical, :horizontal, :window
|
3
|
+
|
4
|
+
def initialize window, val, font, v, h, color = 0xffffff00
|
5
|
+
self.window = window
|
6
|
+
self.value = val
|
7
|
+
self.font = font
|
8
|
+
self.color = color
|
9
|
+
self.vertical = v
|
10
|
+
self.horizontal = h
|
11
|
+
end
|
12
|
+
|
13
|
+
def vert
|
14
|
+
(vertical == :top) ? 10 : window.height - font.height - 5
|
15
|
+
end
|
16
|
+
|
17
|
+
def horizon
|
18
|
+
(horizontal == :left) ? 10 : window.width - font.text_width(value) - 10
|
19
|
+
end
|
20
|
+
|
21
|
+
def draw
|
22
|
+
font.draw value, horizon, vert, 1.0, 1.0, 1.0, color
|
23
|
+
end
|
24
|
+
end
|
data/lib/timer.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class Timer < Text
|
2
|
+
attr_accessor :max, :start
|
3
|
+
def initialize window, max, font
|
4
|
+
super window, max, font, :top, :right
|
5
|
+
self.max = max
|
6
|
+
self.reset
|
7
|
+
end
|
8
|
+
|
9
|
+
def value
|
10
|
+
max - (Time.now - self.start).to_i
|
11
|
+
end
|
12
|
+
|
13
|
+
def reset
|
14
|
+
self.start = Time.now
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'gosu'
|
3
|
+
|
4
|
+
%w{word text timer}.each do |lib|
|
5
|
+
require File.dirname(__FILE__) + '/' + lib
|
6
|
+
end
|
7
|
+
|
8
|
+
class TrainingWheels < Gosu::Window
|
9
|
+
def initialize
|
10
|
+
super 800, 600, false
|
11
|
+
@font = Gosu::Font.new self, Gosu::default_font_name, 40
|
12
|
+
@small_font = Gosu::Font.new self, Gosu::default_font_name, 25
|
13
|
+
@rocket = Gosu::Sample.new self, 'sounds/bottlerocket.wav'
|
14
|
+
@ohno = Gosu::Sample.new self, 'sounds/oh_no.wav'
|
15
|
+
@word = Word.new self
|
16
|
+
@timer = Timer.new self, 15, @font
|
17
|
+
@scoreboard = Text.new self, 0, @font, :bottom, :left
|
18
|
+
end
|
19
|
+
|
20
|
+
def objects
|
21
|
+
@objects ||= [
|
22
|
+
Text.new(self, 'Training Wheels!', @font, :top, :left),
|
23
|
+
Text.new(self, 'Space for correct answers; Esc to exit', @small_font, :bottom, :right),
|
24
|
+
@word,
|
25
|
+
@scoreboard,
|
26
|
+
@timer
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
wrong if @timer.value == 0
|
32
|
+
end
|
33
|
+
|
34
|
+
def draw
|
35
|
+
objects.each {|str| str.draw}
|
36
|
+
end
|
37
|
+
|
38
|
+
def button_down(id)
|
39
|
+
case id
|
40
|
+
when Gosu::Button::KbEscape
|
41
|
+
close
|
42
|
+
when Gosu::Button::KbRight
|
43
|
+
wrong
|
44
|
+
when Gosu::Button::KbSpace
|
45
|
+
correct
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def wrong
|
50
|
+
@timer.reset
|
51
|
+
@ohno.play
|
52
|
+
@scoreboard.value = @scoreboard.value - 50
|
53
|
+
@word.wrong
|
54
|
+
end
|
55
|
+
|
56
|
+
def correct
|
57
|
+
@timer.reset
|
58
|
+
@rocket.play
|
59
|
+
@scoreboard.value = @scoreboard.value + (10 * @timer.value)
|
60
|
+
@word.correct
|
61
|
+
end
|
62
|
+
end
|
data/lib/word.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
class Word
|
2
|
+
attr_reader :current
|
3
|
+
|
4
|
+
def initialize window
|
5
|
+
@window = window
|
6
|
+
@font = Gosu::Font.new window, Gosu::default_font_name, 80
|
7
|
+
@words = {}
|
8
|
+
word_list.each do |word|
|
9
|
+
@words[word] = 0
|
10
|
+
end
|
11
|
+
self.next
|
12
|
+
end
|
13
|
+
|
14
|
+
def word_list
|
15
|
+
%w{and to it for a up so dad the said dog I am cat my can you an go in is of like do see he she me mom no we at}
|
16
|
+
end
|
17
|
+
|
18
|
+
def next
|
19
|
+
@current = @words.keys[rand(1000)%@words.keys.size]
|
20
|
+
end
|
21
|
+
|
22
|
+
def wrong
|
23
|
+
count = @words[current] = @words[current] - 1 unless @words[current] == 0
|
24
|
+
self.next
|
25
|
+
return count
|
26
|
+
end
|
27
|
+
|
28
|
+
def correct
|
29
|
+
count = @words[current] = @words[current] + 1
|
30
|
+
puts "You know #{current} (#{@words.delete(current)})" if @words[current] > 2
|
31
|
+
self.next
|
32
|
+
return count
|
33
|
+
end
|
34
|
+
|
35
|
+
def vert
|
36
|
+
@window.width/2 - @font.text_width(current)/2
|
37
|
+
end
|
38
|
+
|
39
|
+
def horizon
|
40
|
+
@window.height/2 - @font.height/2
|
41
|
+
end
|
42
|
+
|
43
|
+
def color
|
44
|
+
case @words[current]
|
45
|
+
when 0: 0xffff0000
|
46
|
+
when 1: 0xffffff00
|
47
|
+
else 0xff00ff00
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def draw
|
52
|
+
@font.draw self.current, self.vert, self.horizon, 1.0, 1.0, 1.0, color
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
Binary file
|
data/sounds/oh_no.wav
ADDED
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/training_wheels/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'training_wheels'
|
6
|
+
s.version = TrainingWheels::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ['Josh Kleinpeter']
|
9
|
+
s.email = ['josh@kleinpeter.org']
|
10
|
+
s.homepage = 'http://github.com/j05h/training_wheels'
|
11
|
+
s.summary = 'A Gosu gem to help teach kids'
|
12
|
+
s.description = 'For now this gem helps kindergarteners learn sight words.'
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "training_wheels"
|
16
|
+
|
17
|
+
s.add_runtime_dependency 'gosu', '~> 0.7.23'
|
18
|
+
s.add_development_dependency 'bundler', '~> 1.0.0'
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
22
|
+
s.require_path = 'lib'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: training_wheels
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Josh Kleinpeter
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-15 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: gosu
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 45
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 7
|
33
|
+
- 23
|
34
|
+
version: 0.7.23
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 23
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
version: 1.0.0
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
description: For now this gem helps kindergarteners learn sight words.
|
54
|
+
email:
|
55
|
+
- josh@kleinpeter.org
|
56
|
+
executables:
|
57
|
+
- training_wheels
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files: []
|
61
|
+
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.rdoc
|
67
|
+
- Rakefile
|
68
|
+
- bin/training_wheels
|
69
|
+
- images/button.png
|
70
|
+
- images/scorpion.png
|
71
|
+
- lib/text.rb
|
72
|
+
- lib/timer.rb
|
73
|
+
- lib/training_wheels.rb
|
74
|
+
- lib/training_wheels/version.rb
|
75
|
+
- lib/word.rb
|
76
|
+
- sounds/bottlerocket.wav
|
77
|
+
- sounds/oh_no.wav
|
78
|
+
- training_wheels.gemspec
|
79
|
+
has_rdoc: true
|
80
|
+
homepage: http://github.com/j05h/training_wheels
|
81
|
+
licenses: []
|
82
|
+
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 3
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
version: "0"
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 23
|
103
|
+
segments:
|
104
|
+
- 1
|
105
|
+
- 3
|
106
|
+
- 6
|
107
|
+
version: 1.3.6
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project: training_wheels
|
111
|
+
rubygems_version: 1.3.7
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: A Gosu gem to help teach kids
|
115
|
+
test_files: []
|
116
|
+
|