chingu 0.7.0 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/History.txt +1 -1
  2. data/README.rdoc +110 -49
  3. data/benchmarks/game_objects_benchmark.rb +50 -0
  4. data/chingu.gemspec +24 -12
  5. data/examples/example10_traits_retrofy.rb +6 -4
  6. data/examples/example11_animation.rb +14 -23
  7. data/examples/example12_trait_timer.rb +1 -1
  8. data/examples/example13_high_scores.rb +1 -1
  9. data/examples/example14_bounding_box_circle.rb +6 -10
  10. data/examples/example15_trait_timer2.rb +1 -1
  11. data/examples/example16_online_high_scores.rb +1 -1
  12. data/examples/example17_gosu_tutorial.rb +4 -4
  13. data/examples/example18_animation_trait.rb +98 -0
  14. data/examples/example19_edit_viewport.rb +223 -0
  15. data/examples/example19_game_objects.yml +1591 -0
  16. data/examples/example20_trait_inheritence_test.rb +58 -0
  17. data/examples/example3_parallax.rb +1 -1
  18. data/examples/example4_gamestates.rb +1 -1
  19. data/examples/example7_gfx_helpers.rb +14 -9
  20. data/examples/example8_traits.rb +4 -4
  21. data/examples/example9_collision_detection.rb +1 -1
  22. data/examples/game1.rb +33 -38
  23. data/examples/game_of_life.rb +291 -0
  24. data/examples/media/droid_11x15.bmp +0 -0
  25. data/examples/media/droid_11x15.gal +0 -0
  26. data/examples/media/heli.bmp +0 -0
  27. data/examples/media/heli.gal +0 -0
  28. data/examples/media/star_25x25_default.png +0 -0
  29. data/examples/media/star_25x25_explode.gal +0 -0
  30. data/examples/media/star_25x25_explode.png +0 -0
  31. data/examples/media/stone_wall.bmp +0 -0
  32. data/lib/chingu.rb +1 -1
  33. data/lib/chingu/animation.rb +78 -9
  34. data/lib/chingu/basic_game_object.rb +16 -8
  35. data/lib/chingu/game_object.rb +36 -7
  36. data/lib/chingu/game_object_list.rb +20 -3
  37. data/lib/chingu/game_state.rb +8 -7
  38. data/lib/chingu/game_states/edit.rb +177 -90
  39. data/lib/chingu/helpers/class_inheritable_accessor.rb +12 -5
  40. data/lib/chingu/helpers/game_object.rb +45 -4
  41. data/lib/chingu/helpers/gfx.rb +150 -172
  42. data/lib/chingu/helpers/input_client.rb +7 -0
  43. data/lib/chingu/inflector.rb +16 -2
  44. data/lib/chingu/traits/animation.rb +84 -0
  45. data/lib/chingu/traits/bounding_box.rb +16 -3
  46. data/lib/chingu/traits/bounding_circle.rb +18 -4
  47. data/lib/chingu/traits/collision_detection.rb +10 -1
  48. data/lib/chingu/traits/velocity.rb +26 -3
  49. data/lib/chingu/traits/viewport.rb +10 -9
  50. data/lib/chingu/viewport.rb +103 -22
  51. data/lib/chingu/window.rb +8 -2
  52. metadata +46 -16
  53. data/examples/example18_viewport.rb +0 -173
  54. data/examples/media/city1.csv +0 -2
  55. data/examples/media/plane.csv +0 -2
  56. data/examples/media/saucer.csv +0 -4
  57. data/examples/media/stickfigure.bmp +0 -0
  58. data/examples/media/stickfigure.png +0 -0
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chingu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 5
10
+ version: 0.7.5
5
11
  platform: ruby
6
12
  authors:
7
13
  - ippa
@@ -9,19 +15,25 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-14 00:00:00 +01:00
18
+ date: 2010-06-13 00:00:00 +02:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: gosu
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 39
30
+ segments:
31
+ - 0
32
+ - 7
33
+ - 18
23
34
  version: 0.7.18
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  description: 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.
26
38
  email: ippa@rubylicio.us
27
39
  executables: []
@@ -43,6 +55,7 @@ files:
43
55
  - benchmarks/benchmark4.rb
44
56
  - benchmarks/benchmark5.rb
45
57
  - benchmarks/benchmark6.rb
58
+ - benchmarks/game_objects_benchmark.rb
46
59
  - benchmarks/meta_benchmark.rb
47
60
  - benchmarks/meta_benchmark2.rb
48
61
  - chingu.gemspec
@@ -54,8 +67,11 @@ files:
54
67
  - examples/example15_trait_timer2.rb
55
68
  - examples/example16_online_high_scores.rb
56
69
  - examples/example17_gosu_tutorial.rb
57
- - examples/example18_viewport.rb
70
+ - examples/example18_animation_trait.rb
71
+ - examples/example19_edit_viewport.rb
72
+ - examples/example19_game_objects.yml
58
73
  - examples/example1_basics.rb
74
+ - examples/example20_trait_inheritence_test.rb
59
75
  - examples/example2_gamestate_basics.rb
60
76
  - examples/example3_parallax.rb
61
77
  - examples/example4_gamestates.rb
@@ -65,6 +81,7 @@ files:
65
81
  - examples/example8_traits.rb
66
82
  - examples/example9_collision_detection.rb
67
83
  - examples/game1.rb
84
+ - examples/game_of_life.rb
68
85
  - examples/high_score_list.yml
69
86
  - examples/media/Parallax-scroll-example-layer-0.png
70
87
  - examples/media/Parallax-scroll-example-layer-1.png
@@ -76,26 +93,29 @@ files:
76
93
  - examples/media/bullet.png
77
94
  - examples/media/bullet_hit.wav
78
95
  - examples/media/circle.png
79
- - examples/media/city1.csv
80
96
  - examples/media/city1.png
81
97
  - examples/media/city2.png
82
98
  - examples/media/droid.bmp
99
+ - examples/media/droid_11x15.bmp
100
+ - examples/media/droid_11x15.gal
83
101
  - examples/media/enemy_bullet.png
84
102
  - examples/media/explosion.wav
85
103
  - examples/media/fire_bullet.png
86
104
  - examples/media/fireball.png
105
+ - examples/media/heli.bmp
106
+ - examples/media/heli.gal
87
107
  - examples/media/laser.wav
88
108
  - examples/media/particle.png
89
- - examples/media/plane.csv
90
109
  - examples/media/plane.png
91
110
  - examples/media/rect.png
92
111
  - examples/media/ruby.png
93
- - examples/media/saucer.csv
94
112
  - examples/media/saucer.gal
95
113
  - examples/media/saucer.png
96
114
  - examples/media/spaceship.png
97
- - examples/media/stickfigure.bmp
98
- - examples/media/stickfigure.png
115
+ - examples/media/star_25x25_default.png
116
+ - examples/media/star_25x25_explode.gal
117
+ - examples/media/star_25x25_explode.png
118
+ - examples/media/stone_wall.bmp
99
119
  - examples/media/video_games.png
100
120
  - examples/media/wood.png
101
121
  - lib/chingu.rb
@@ -130,6 +150,7 @@ files:
130
150
  - lib/chingu/rect.rb
131
151
  - lib/chingu/require_all.rb
132
152
  - lib/chingu/text.rb
153
+ - lib/chingu/traits/animation.rb
133
154
  - lib/chingu/traits/bounding_box.rb
134
155
  - lib/chingu/traits/bounding_circle.rb
135
156
  - lib/chingu/traits/collision_detection.rb
@@ -150,21 +171,27 @@ rdoc_options:
150
171
  require_paths:
151
172
  - lib
152
173
  required_ruby_version: !ruby/object:Gem::Requirement
174
+ none: false
153
175
  requirements:
154
176
  - - ">="
155
177
  - !ruby/object:Gem::Version
178
+ hash: 3
179
+ segments:
180
+ - 0
156
181
  version: "0"
157
- version:
158
182
  required_rubygems_version: !ruby/object:Gem::Requirement
183
+ none: false
159
184
  requirements:
160
185
  - - ">="
161
186
  - !ruby/object:Gem::Version
187
+ hash: 3
188
+ segments:
189
+ - 0
162
190
  version: "0"
163
- version:
164
191
  requirements: []
165
192
 
166
193
  rubyforge_project: chingu
167
- rubygems_version: 1.3.5
194
+ rubygems_version: 1.3.7
168
195
  signing_key:
169
196
  specification_version: 3
170
197
  summary: OpenGL accelerated 2D game framework for Ruby
@@ -177,8 +204,10 @@ test_files:
177
204
  - examples/example15_trait_timer2.rb
178
205
  - examples/example16_online_high_scores.rb
179
206
  - examples/example17_gosu_tutorial.rb
180
- - examples/example18_viewport.rb
207
+ - examples/example18_animation_trait.rb
208
+ - examples/example19_edit_viewport.rb
181
209
  - examples/example1_basics.rb
210
+ - examples/example20_trait_inheritence_test.rb
182
211
  - examples/example2_gamestate_basics.rb
183
212
  - examples/example3_parallax.rb
184
213
  - examples/example4_gamestates.rb
@@ -188,3 +217,4 @@ test_files:
188
217
  - examples/example8_traits.rb
189
218
  - examples/example9_collision_detection.rb
190
219
  - examples/game1.rb
220
+ - examples/game_of_life.rb
@@ -1,173 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require 'opengl'
4
- require File.join(File.dirname($0), "..", "lib", "chingu")
5
- include Gosu
6
- include Chingu
7
-
8
- #
9
- # viewport-trait example
10
- #
11
- # Gotcha: collision_detection-trait debug mode currently borks up with viewports (only the visuals)
12
- #
13
- class Game < Chingu::Window
14
- attr_reader :factor
15
-
16
- def initialize
17
- super
18
- @factor = 6
19
- self.input = { :escape => :exit }
20
- switch_game_state(Level)
21
- end
22
- end
23
-
24
- class Level < GameState
25
- #
26
- # This adds accessor 'viewport' to class and overrides draw() to use it.
27
- #
28
- has_trait :viewport
29
-
30
- #
31
- # We create our 3 different game objects in this order:
32
- # 1) map 2) stars 3) player
33
- # Since we don't give any zorders Chingu automatically increments zorder between each object created, putting player on top
34
- #
35
- def initialize(options = {})
36
- super
37
- @map = GameObject.create(:image => "background1.png", :factor => $window.factor, :rotation_center => :top_left, :retrofy => true)
38
- self.viewport.x_min = 0
39
- self.viewport.y_min = 0
40
- self.viewport.x_max = @map.image.width * $window.factor - $window.width
41
- self.viewport.y_max = @map.image.height * $window.factor - $window.height
42
-
43
- # Create 40 stars scattered around the map
44
- 40.times { |nr| Star.create(:x => rand * self.viewport.x_max, :y => rand * self.viewport.y_max) }
45
-
46
- @droid = Droid.create(:x => 100, :y => 100)
47
- end
48
-
49
- def update
50
- super
51
-
52
- @droid.each_collision(Star) do |droid, star|
53
- star.destroy
54
- Sound["laser.wav"].play(0.5)
55
- end
56
-
57
- #
58
- # Align viewport with the droid in the middle.
59
- # This will make droid will be in the center of the screen all the time...
60
- # ...except when hitting outer borders and viewport x/y _ min/max kicks in.
61
- #
62
- self.viewport.x = @droid.x - $window.width / 2
63
- self.viewport.y = @droid.y - $window.height / 2
64
-
65
- $window.caption = "viewport-trait example. Move with arrows! x/y: #{@droid.x}/#{@droid.y} - viewport x/y: #{self.viewport.x}/#{self.viewport.y} - FPS: #{$window.fps}"
66
- end
67
- end
68
-
69
- class Droid < Chingu::GameObject
70
- has_trait :bounding_box
71
- has_traits :timer, :collision_detection
72
-
73
- attr_accessor :last_x, :last_y
74
-
75
- def initialize(options = {})
76
- super
77
-
78
- #
79
- # This shows up the shorten versio of input-maps, where each key calls a method of the very same name.
80
- # Use this by giving an array of symbols to self.input
81
- #
82
- self.input = [:holding_left, :holding_right, :holding_up, :holding_down]
83
-
84
- # Load the full animation from tile-file media/droid.bmp
85
- @full_animation = Chingu::Animation.new(:file => "droid.bmp", :size => [11,16]).retrofy
86
-
87
- # Create new animations from specific frames and stuff them into easy to access hash
88
- @animations = {}
89
- @animations[:scan] = @full_animation[0..5]
90
- @animations[:up] = @full_animation[6..7]
91
- @animations[:down] = @full_animation[8..9]
92
- @animations[:left] = @full_animation[10..11]
93
- @animations[:right] = @full_animation[12..13]
94
-
95
- # Start out by animation frames 0-5 (contained by @animations[:scan])
96
- @animation = @animations[:scan]
97
-
98
- self.factor = $window.factor
99
- @last_x, @last_y = @x, @y
100
- @speed = 3
101
-
102
- update
103
- end
104
-
105
- def holding_left
106
- @x -= @speed
107
- @animation = @animations[:left]
108
- end
109
-
110
- def holding_right
111
- @x += @speed
112
- @animation = @animations[:right]
113
- end
114
-
115
- def holding_up
116
- @y -= @speed
117
- @animation = @animations[:up]
118
- end
119
-
120
- def holding_down
121
- @y += @speed
122
- @animation = @animations[:down]
123
- end
124
-
125
- # We don't need to call super() in update().
126
- # By default GameObject#update is empty since it doesn't contain any gamelogic to speak of.
127
- def update
128
-
129
- # Move the animation forward by fetching the next frame and putting it into @image
130
- # @image is drawn by default by GameObject#draw
131
- @image = @animation.next
132
-
133
- #
134
- # If droid stands still, use the scanning animation
135
- #
136
- if @x == @last_x && @y == @last_y
137
- @animation = @animations[:scan]
138
- end
139
-
140
- @x, @y = @last_x, @last_y if self.parent.outside_viewport?(self)
141
- @last_x, @last_y = @x, @y
142
- end
143
- end
144
-
145
- class Star < GameObject
146
- has_trait :bounding_circle
147
- has_trait :collision_detection
148
-
149
- def initialize(options={})
150
- super
151
-
152
- @animation = Chingu::Animation.new(:file => media_path("Star.png"), :size => 25)
153
- @image = @animation.next
154
- self.color = Gosu::Color.new(0xff000000)
155
- self.color.red = rand(255 - 40) + 40
156
- self.color.green = rand(255 - 40) + 40
157
- self.color.blue = rand(255 - 40) + 40
158
-
159
- #
160
- # A cached bounding circle will not adapt to changes in size, but it will follow objects X / Y
161
- # Same is true for "cache_bounding_box"
162
- #
163
- cache_bounding_circle
164
- end
165
-
166
- def update
167
- # Move the animation forward by fetching the next frame and putting it into @image
168
- # @image is drawn by default by GameObject#draw
169
- @image = @animation.next
170
- end
171
- end
172
-
173
- Game.new.show
@@ -1,2 +0,0 @@
1
- "Name","Transparent Color","Transparent Color(Hex)"
2
- "Frame1","-1","FFFFFFFF"
@@ -1,2 +0,0 @@
1
- "Name","Transparent Color","Transparent Color(Hex)"
2
- "Frame1","-1","FFFFFFFF"
@@ -1,4 +0,0 @@
1
- "Name","Transparent Color","Transparent Color(Hex)"
2
- "Frame1","-1","FFFFFFFF"
3
- "Copy_Frame1","-1","FFFFFFFF"
4
- "Copy_Copy_Frame1","-1","FFFFFFFF"