chingu 0.7.7.5 → 0.8rc1
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/History.txt +1 -1
- data/Rakefile +4 -2
- data/chingu.gemspec +25 -10
- data/examples/example10_traits_retrofy.rb +3 -2
- data/examples/example11_animation.rb +3 -2
- data/examples/example12_trait_timer.rb +3 -2
- data/examples/example13_high_scores.rb +3 -2
- data/examples/example14_bounding_box_circle.rb +6 -5
- data/examples/example15_trait_timer2.rb +3 -2
- data/examples/example16_online_high_scores.rb +3 -2
- data/examples/example17_gosu_tutorial.rb +104 -103
- data/examples/example18_animation_trait.rb +3 -2
- data/examples/example19_edit_viewport.rb +3 -2
- data/examples/example1_basics.rb +3 -2
- data/examples/example20_trait_inheritence_test.rb +3 -2
- data/examples/example21.yml +306 -306
- data/examples/example21_sidescroller_with_edit.rb +3 -2
- data/examples/example22_text.rb +3 -2
- data/examples/example23_chipmunk.rb +3 -2
- data/examples/example24_enter_name.rb +19 -0
- data/examples/example24_input_codes.rb +41 -0
- data/examples/example25.yml +625 -0
- data/examples/example25_fibers_state_machine.rb +167 -0
- data/examples/example2_gamestate_basics.rb +3 -2
- data/examples/example3_parallax.rb +3 -2
- data/examples/example4_gamestates.rb +3 -2
- data/examples/example5_gamestates_in_pure_gosu.rb +3 -2
- data/examples/example6_transitional_game_state.rb +3 -2
- data/examples/example7_gfx_helpers.rb +3 -2
- data/examples/example8_traits.rb +3 -2
- data/examples/example9_collision_detection.rb +3 -2
- data/examples/game1.rb +3 -2
- data/examples/game_of_life.rb +291 -290
- data/lib/chingu.rb +6 -1
- data/lib/chingu/animation.rb +3 -2
- data/lib/chingu/game_object.rb +7 -1
- data/lib/chingu/game_object_map.rb +6 -12
- data/lib/chingu/game_states/edit.rb +63 -66
- data/lib/chingu/game_states/enter_name.rb +97 -0
- data/lib/chingu/helpers/game_object.rb +10 -21
- data/lib/chingu/input.rb +2 -0
- data/lib/chingu/online_high_score_list.rb +1 -4
- data/lib/chingu/rect.rb +2 -1
- data/lib/chingu/window.rb +10 -1
- data/spec/chingu/game_object_spec.rb +22 -22
- data/spec/chingu/input_spec.rb +22 -0
- metadata +48 -22
- data/spec/chingu/rect_20x20.png +0 -0
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -14,10 +14,12 @@ begin
|
|
14
14
|
gemspec.rubyforge_project = "chingu"
|
15
15
|
gemspec.version = Chingu::VERSION
|
16
16
|
|
17
|
-
gemspec.add_dependency 'gosu', '>= 0.7.
|
18
|
-
gemspec.add_development_dependency 'rspec', '>= 2.0.0
|
17
|
+
gemspec.add_dependency 'gosu', '>= 0.7.24'
|
18
|
+
gemspec.add_development_dependency 'rspec', '>= 2.0.0'
|
19
19
|
gemspec.add_development_dependency 'watchr'
|
20
20
|
gemspec.add_development_dependency 'rcov'
|
21
|
+
gemspec.add_development_dependency 'rest_client'
|
22
|
+
gemspec.add_development_dependency 'crack'
|
21
23
|
end
|
22
24
|
Jeweler::GemcutterTasks.new
|
23
25
|
rescue LoadError
|
data/chingu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{chingu}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.8rc1"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ippa"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-14}
|
13
13
|
s.description = %q{OpenGL accelerated 2D game framework for Ruby. Builds on Gosu (Ruby/C++) which provides all the core functionality. Chingu adds simple yet powerful game states, prettier input handling, deployment safe asset-handling, a basic re-usable game object and stackable game logic.}
|
14
14
|
s.email = %q{ippa@rubylicio.us}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -50,6 +50,10 @@ Gem::Specification.new do |s|
|
|
50
50
|
"examples/example21_sidescroller_with_edit.rb",
|
51
51
|
"examples/example22_text.rb",
|
52
52
|
"examples/example23_chipmunk.rb",
|
53
|
+
"examples/example24_enter_name.rb",
|
54
|
+
"examples/example24_input_codes.rb",
|
55
|
+
"examples/example25.yml",
|
56
|
+
"examples/example25_fibers_state_machine.rb",
|
53
57
|
"examples/example2_gamestate_basics.rb",
|
54
58
|
"examples/example3_parallax.rb",
|
55
59
|
"examples/example4_gamestates.rb",
|
@@ -117,6 +121,7 @@ Gem::Specification.new do |s|
|
|
117
121
|
"lib/chingu/game_state_manager.rb",
|
118
122
|
"lib/chingu/game_states/debug.rb",
|
119
123
|
"lib/chingu/game_states/edit.rb",
|
124
|
+
"lib/chingu/game_states/enter_name.rb",
|
120
125
|
"lib/chingu/game_states/fade_to.rb",
|
121
126
|
"lib/chingu/game_states/pause.rb",
|
122
127
|
"lib/chingu/game_states/popup.rb",
|
@@ -159,7 +164,7 @@ Gem::Specification.new do |s|
|
|
159
164
|
"spec/chingu/helpers/options_setter_spec.rb",
|
160
165
|
"spec/chingu/images/rect_20x20.png",
|
161
166
|
"spec/chingu/inflector_spec.rb",
|
162
|
-
"spec/chingu/
|
167
|
+
"spec/chingu/input_spec.rb",
|
163
168
|
"spec/chingu/text_spec.rb",
|
164
169
|
"spec/spec_helper.rb",
|
165
170
|
"specs.watchr"
|
@@ -177,6 +182,7 @@ Gem::Specification.new do |s|
|
|
177
182
|
"spec/chingu/helpers/input_dispatcher_spec.rb",
|
178
183
|
"spec/chingu/helpers/options_setter_spec.rb",
|
179
184
|
"spec/chingu/inflector_spec.rb",
|
185
|
+
"spec/chingu/input_spec.rb",
|
180
186
|
"spec/chingu/text_spec.rb",
|
181
187
|
"spec/spec_helper.rb",
|
182
188
|
"examples/example10_traits_retrofy.rb",
|
@@ -194,6 +200,9 @@ Gem::Specification.new do |s|
|
|
194
200
|
"examples/example21_sidescroller_with_edit.rb",
|
195
201
|
"examples/example22_text.rb",
|
196
202
|
"examples/example23_chipmunk.rb",
|
203
|
+
"examples/example24_enter_name.rb",
|
204
|
+
"examples/example24_input_codes.rb",
|
205
|
+
"examples/example25_fibers_state_machine.rb",
|
197
206
|
"examples/example2_gamestate_basics.rb",
|
198
207
|
"examples/example3_parallax.rb",
|
199
208
|
"examples/example4_gamestates.rb",
|
@@ -211,21 +220,27 @@ Gem::Specification.new do |s|
|
|
211
220
|
s.specification_version = 3
|
212
221
|
|
213
222
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
214
|
-
s.add_runtime_dependency(%q<gosu>, [">= 0.7.
|
215
|
-
s.add_development_dependency(%q<rspec>, [">= 2.0.0
|
223
|
+
s.add_runtime_dependency(%q<gosu>, [">= 0.7.24"])
|
224
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
|
216
225
|
s.add_development_dependency(%q<watchr>, [">= 0"])
|
217
226
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
227
|
+
s.add_development_dependency(%q<rest_client>, [">= 0"])
|
228
|
+
s.add_development_dependency(%q<crack>, [">= 0"])
|
218
229
|
else
|
219
|
-
s.add_dependency(%q<gosu>, [">= 0.7.
|
220
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0
|
230
|
+
s.add_dependency(%q<gosu>, [">= 0.7.24"])
|
231
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
221
232
|
s.add_dependency(%q<watchr>, [">= 0"])
|
222
233
|
s.add_dependency(%q<rcov>, [">= 0"])
|
234
|
+
s.add_dependency(%q<rest_client>, [">= 0"])
|
235
|
+
s.add_dependency(%q<crack>, [">= 0"])
|
223
236
|
end
|
224
237
|
else
|
225
|
-
s.add_dependency(%q<gosu>, [">= 0.7.
|
226
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0
|
238
|
+
s.add_dependency(%q<gosu>, [">= 0.7.24"])
|
239
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
227
240
|
s.add_dependency(%q<watchr>, [">= 0"])
|
228
241
|
s.add_dependency(%q<rcov>, [">= 0"])
|
242
|
+
s.add_dependency(%q<rest_client>, [">= 0"])
|
243
|
+
s.add_dependency(%q<crack>, [">= 0"])
|
229
244
|
end
|
230
245
|
end
|
231
246
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
$stderr.sync = $stdout.sync = true
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
|
@@ -12,6 +13,7 @@ class Game < Chingu::Window
|
|
12
13
|
super(640,400)
|
13
14
|
self.input = {:esc => :exit, :q => :decrease_size, :w => :increase_size, :a => :decrease_speed, :s => :increase_speed}
|
14
15
|
|
16
|
+
self.factor = 1
|
15
17
|
20.times { Circle.create(:x => width/2, :y => height/2) }
|
16
18
|
20.times { Box.create(:x => width/2, :y => height/2) }
|
17
19
|
@blue = Color.new(0xFF0000FF)
|
@@ -71,7 +73,6 @@ class Circle < GameObject
|
|
71
73
|
@image = Image["circle.png"]
|
72
74
|
self.velocity_x = 3 - rand * 6
|
73
75
|
self.velocity_y = 3 - rand * 6
|
74
|
-
self.factor = 2
|
75
76
|
self.input = [:holding_left, :holding_right, :holding_down, :holding_up] # NOTE: giving input an Array, not a Hash
|
76
77
|
cache_bounding_circle
|
77
78
|
end
|
@@ -99,10 +100,10 @@ class Box < GameObject
|
|
99
100
|
# Test to make sure the bounding_box works with all bellow combos
|
100
101
|
#self.factor = 2
|
101
102
|
#self.factor = -2
|
102
|
-
|
103
|
+
self.rotation_center = :left_top
|
103
104
|
#self.rotation_center = :center
|
104
105
|
#self.rotation_center = :right_bottom
|
105
|
-
|
106
|
+
|
106
107
|
cache_bounding_box
|
107
108
|
end
|
108
109
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
|
@@ -1,104 +1,105 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
|
5
|
-
include
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@
|
17
|
-
@
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
self.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
self.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
self.
|
69
|
-
|
70
|
-
|
71
|
-
@
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
trait :
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
@
|
83
|
-
|
84
|
-
self.color
|
85
|
-
self.color.
|
86
|
-
self.color.
|
87
|
-
self.
|
88
|
-
self.
|
89
|
-
|
90
|
-
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
#
|
100
|
-
@image
|
101
|
-
|
102
|
-
end
|
103
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
5
|
+
include Gosu
|
6
|
+
include Chingu
|
7
|
+
|
8
|
+
# Set to true to see bounding circles used for collision detection
|
9
|
+
DEBUG = false
|
10
|
+
|
11
|
+
class Game < Chingu::Window
|
12
|
+
def initialize
|
13
|
+
super(640,400)
|
14
|
+
self.input = {:esc => :exit}
|
15
|
+
|
16
|
+
@player = Player.create(:zorder => 2, :x=>320, :y=>240)
|
17
|
+
@score = 0
|
18
|
+
@score_text = Text.create("Score: #{@score}", :x => 10, :y => 10, :zorder => 55, :size=>20)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update
|
22
|
+
super
|
23
|
+
|
24
|
+
if rand(100) < 4 && Star.all.size < 25
|
25
|
+
Star.create
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Collide @player with all instances of class Star
|
30
|
+
#
|
31
|
+
@player.each_collision(Star) do |player, star|
|
32
|
+
star.destroy
|
33
|
+
@score+=10
|
34
|
+
end
|
35
|
+
|
36
|
+
@score_text.text = "Score: #{@score}"
|
37
|
+
self.caption = "Chingu Game - " + @score_text.text
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Player < GameObject
|
42
|
+
trait :bounding_circle, :debug => DEBUG
|
43
|
+
traits :collision_detection, :effect, :velocity
|
44
|
+
|
45
|
+
def initialize(options={})
|
46
|
+
super(options)
|
47
|
+
@image = Image["Starfighter.bmp"]
|
48
|
+
self.input = {:holding_right=>:turn_right, :holding_left=>:turn_left, :holding_up=>:accelerate}
|
49
|
+
self.max_velocity = 10
|
50
|
+
end
|
51
|
+
|
52
|
+
def accelerate
|
53
|
+
self.velocity_x = Gosu::offset_x(self.angle, 0.5)*self.max_velocity_x
|
54
|
+
self.velocity_y = Gosu::offset_y(self.angle, 0.5)*self.max_velocity_y
|
55
|
+
end
|
56
|
+
|
57
|
+
def turn_right
|
58
|
+
# The same can be achieved without trait 'effect' as: self.angle += 4.5
|
59
|
+
rotate(4.5)
|
60
|
+
end
|
61
|
+
|
62
|
+
def turn_left
|
63
|
+
# The same can be achieved without trait 'effect' as: self.angle -= 4.5
|
64
|
+
rotate(-4.5)
|
65
|
+
end
|
66
|
+
|
67
|
+
def update
|
68
|
+
self.velocity_x *= 0.95 # dampen the movement
|
69
|
+
self.velocity_y *= 0.95
|
70
|
+
|
71
|
+
@x %= $window.width # wrap around the screen
|
72
|
+
@y %= $window.height
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class Star < GameObject
|
77
|
+
trait :bounding_circle, :debug => DEBUG
|
78
|
+
trait :collision_detection
|
79
|
+
|
80
|
+
def initialize(options={})
|
81
|
+
super(:zorder=>1)
|
82
|
+
@animation = Chingu::Animation.new(:file => media_path("Star.png"), :size => 25)
|
83
|
+
@image = @animation.next
|
84
|
+
self.color = Gosu::Color.new(0xff000000)
|
85
|
+
self.color.red = rand(255 - 40) + 40
|
86
|
+
self.color.green = rand(255 - 40) + 40
|
87
|
+
self.color.blue = rand(255 - 40) + 40
|
88
|
+
self.x =rand * 640
|
89
|
+
self.y =rand * 480
|
90
|
+
|
91
|
+
#
|
92
|
+
# A cached bounding circle will not adapt to changes in size, but it will follow objects X / Y
|
93
|
+
# Same is true for "cache_bounding_box"
|
94
|
+
#
|
95
|
+
cache_bounding_circle
|
96
|
+
end
|
97
|
+
|
98
|
+
def update
|
99
|
+
# Move the animation forward by fetching the next frame and putting it into @image
|
100
|
+
# @image is drawn by default by GameObject#draw
|
101
|
+
@image = @animation.next
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
104
105
|
Game.new.show
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
2
|
+
require 'rubygems' rescue nil
|
3
|
+
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
|
4
|
+
require 'chingu'
|
4
5
|
include Gosu
|
5
6
|
include Chingu
|
6
7
|
|