chingu 0.7.7.5 → 0.8rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/History.txt +1 -1
  2. data/Rakefile +4 -2
  3. data/chingu.gemspec +25 -10
  4. data/examples/example10_traits_retrofy.rb +3 -2
  5. data/examples/example11_animation.rb +3 -2
  6. data/examples/example12_trait_timer.rb +3 -2
  7. data/examples/example13_high_scores.rb +3 -2
  8. data/examples/example14_bounding_box_circle.rb +6 -5
  9. data/examples/example15_trait_timer2.rb +3 -2
  10. data/examples/example16_online_high_scores.rb +3 -2
  11. data/examples/example17_gosu_tutorial.rb +104 -103
  12. data/examples/example18_animation_trait.rb +3 -2
  13. data/examples/example19_edit_viewport.rb +3 -2
  14. data/examples/example1_basics.rb +3 -2
  15. data/examples/example20_trait_inheritence_test.rb +3 -2
  16. data/examples/example21.yml +306 -306
  17. data/examples/example21_sidescroller_with_edit.rb +3 -2
  18. data/examples/example22_text.rb +3 -2
  19. data/examples/example23_chipmunk.rb +3 -2
  20. data/examples/example24_enter_name.rb +19 -0
  21. data/examples/example24_input_codes.rb +41 -0
  22. data/examples/example25.yml +625 -0
  23. data/examples/example25_fibers_state_machine.rb +167 -0
  24. data/examples/example2_gamestate_basics.rb +3 -2
  25. data/examples/example3_parallax.rb +3 -2
  26. data/examples/example4_gamestates.rb +3 -2
  27. data/examples/example5_gamestates_in_pure_gosu.rb +3 -2
  28. data/examples/example6_transitional_game_state.rb +3 -2
  29. data/examples/example7_gfx_helpers.rb +3 -2
  30. data/examples/example8_traits.rb +3 -2
  31. data/examples/example9_collision_detection.rb +3 -2
  32. data/examples/game1.rb +3 -2
  33. data/examples/game_of_life.rb +291 -290
  34. data/lib/chingu.rb +6 -1
  35. data/lib/chingu/animation.rb +3 -2
  36. data/lib/chingu/game_object.rb +7 -1
  37. data/lib/chingu/game_object_map.rb +6 -12
  38. data/lib/chingu/game_states/edit.rb +63 -66
  39. data/lib/chingu/game_states/enter_name.rb +97 -0
  40. data/lib/chingu/helpers/game_object.rb +10 -21
  41. data/lib/chingu/input.rb +2 -0
  42. data/lib/chingu/online_high_score_list.rb +1 -4
  43. data/lib/chingu/rect.rb +2 -1
  44. data/lib/chingu/window.rb +10 -1
  45. data/spec/chingu/game_object_spec.rb +22 -22
  46. data/spec/chingu/input_spec.rb +22 -0
  47. metadata +48 -22
  48. data/spec/chingu/rect_20x20.png +0 -0
data/History.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  === 0.6 / 2009-11-21
2
2
  More traits, better input, fixes
3
- This file is kind of deprecated -- see github commit-history instead!
3
+ This file is deprecated -- see github commit-history instead!
4
4
 
5
5
  === 0.5.7 / 2009-10-15
6
6
  See github commithistory.
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.22'
18
- gemspec.add_development_dependency 'rspec', '>= 2.0.0.beta.12'
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.7.7.5"
8
+ s.version = "0.8rc1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
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-08-23}
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/rect_20x20.png",
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.22"])
215
- s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.12"])
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.22"])
220
- s.add_dependency(%q<rspec>, [">= 2.0.0.beta.12"])
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.22"])
226
- s.add_dependency(%q<rspec>, [">= 2.0.0.beta.12"])
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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
- #self.rotation_center = :left_top
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
4
- include Gosu
5
- include Chingu
6
-
7
- # Set to true to see bounding circles used for collision detection
8
- DEBUG = false
9
-
10
- class Game < Chingu::Window
11
- def initialize
12
- super(640,400)
13
- self.input = {:esc => :exit}
14
-
15
- @player = Player.create(:zorder => 2, :x=>320, :y=>240)
16
- @score = 0
17
- @score_text = Text.create("Score: #{@score}", :x => 10, :y => 10, :zorder => 55, :size=>20)
18
- end
19
-
20
- def update
21
- super
22
-
23
- if rand(100) < 4 && Star.all.size < 25
24
- Star.create
25
- end
26
-
27
- #
28
- # Collide @player with all instances of class Star
29
- #
30
- @player.each_collision(Star) do |player, star|
31
- star.destroy
32
- @score+=10
33
- end
34
-
35
- @score_text.text = "Score: #{@score}"
36
- self.caption = "Chingu Game - " + @score_text.text
37
- end
38
- end
39
-
40
- class Player < GameObject
41
- trait :bounding_circle, :debug => DEBUG
42
- traits :collision_detection, :effect, :velocity
43
-
44
- def initialize(options={})
45
- super(options)
46
- @image = Image["Starfighter.bmp"]
47
- self.input = {:holding_right=>:turn_right, :holding_left=>:turn_left, :holding_up=>:accelerate}
48
- self.max_velocity = 10
49
- end
50
-
51
- def accelerate
52
- self.velocity_x = Gosu::offset_x(self.angle, 0.5)*self.max_velocity_x
53
- self.velocity_y = Gosu::offset_y(self.angle, 0.5)*self.max_velocity_y
54
- end
55
-
56
- def turn_right
57
- # The same can be achieved without trait 'effect' as: self.angle += 4.5
58
- rotate(4.5)
59
- end
60
-
61
- def turn_left
62
- # The same can be achieved without trait 'effect' as: self.angle -= 4.5
63
- rotate(-4.5)
64
- end
65
-
66
- def update
67
- self.velocity_x *= 0.95 # dampen the movement
68
- self.velocity_y *= 0.95
69
-
70
- @x %= $window.width # wrap around the screen
71
- @y %= $window.height
72
- end
73
- end
74
-
75
- class Star < GameObject
76
- trait :bounding_circle, :debug => DEBUG
77
- trait :collision_detection
78
-
79
- def initialize(options={})
80
- super(:zorder=>1)
81
- @animation = Chingu::Animation.new(:file => media_path("Star.png"), :size => 25)
82
- @image = @animation.next
83
- self.color = Gosu::Color.new(0xff000000)
84
- self.color.red = rand(255 - 40) + 40
85
- self.color.green = rand(255 - 40) + 40
86
- self.color.blue = rand(255 - 40) + 40
87
- self.x =rand * 640
88
- self.y =rand * 480
89
-
90
- #
91
- # A cached bounding circle will not adapt to changes in size, but it will follow objects X / Y
92
- # Same is true for "cache_bounding_box"
93
- #
94
- cache_bounding_circle
95
- end
96
-
97
- def update
98
- # Move the animation forward by fetching the next frame and putting it into @image
99
- # @image is drawn by default by GameObject#draw
100
- @image = @animation.next
101
- end
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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
- require File.join(File.dirname($0), "..", "lib", "chingu")
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