gamebox 0.2.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/Gemfile +1 -8
  2. data/Rakefile +13 -37
  3. data/TODO.txt +27 -27
  4. data/docs/getting_started.rdoc +2 -2
  5. data/gamebox.gemspec +33 -191
  6. data/lib/gamebox.rb +18 -14
  7. data/lib/gamebox/actor.rb +37 -27
  8. data/lib/gamebox/actor_factory.rb +4 -5
  9. data/lib/gamebox/actor_view.rb +8 -0
  10. data/lib/gamebox/actors/collidable_debugger.rb +2 -2
  11. data/lib/gamebox/actors/curtain.rb +3 -3
  12. data/lib/gamebox/actors/emitter.rb +51 -0
  13. data/lib/gamebox/actors/label.rb +27 -7
  14. data/lib/gamebox/actors/logo.rb +1 -1
  15. data/lib/gamebox/actors/spatial_debugger.rb +25 -10
  16. data/lib/gamebox/arbiter.rb +61 -34
  17. data/lib/gamebox/behavior.rb +3 -3
  18. data/lib/gamebox/behaviors/animated.rb +1 -1
  19. data/lib/gamebox/behaviors/audible.rb +1 -1
  20. data/lib/gamebox/behaviors/collidable.rb +9 -4
  21. data/lib/gamebox/behaviors/collidable/aabb_collidable.rb +26 -1
  22. data/lib/gamebox/behaviors/collidable/circle_collidable.rb +3 -3
  23. data/lib/gamebox/behaviors/collidable/polygon_collidable.rb +1 -1
  24. data/lib/gamebox/behaviors/graphical.rb +30 -4
  25. data/lib/gamebox/behaviors/layered.rb +1 -1
  26. data/lib/gamebox/behaviors/physical.rb +113 -30
  27. data/lib/gamebox/behaviors/timed.rb +33 -0
  28. data/lib/gamebox/behaviors/updatable.rb +1 -1
  29. data/lib/gamebox/class_finder.rb +1 -21
  30. data/lib/gamebox/console_app.rb +33 -31
  31. data/lib/gamebox/constants.rb +481 -0
  32. data/lib/gamebox/data/config/objects.yml +7 -0
  33. data/lib/gamebox/gamebox_application.rb +10 -33
  34. data/lib/gamebox/gamebox_generator.rb +32 -32
  35. data/lib/gamebox/input_manager.rb +73 -32
  36. data/lib/gamebox/lib/inflector.rb +1 -1
  37. data/lib/gamebox/lib/range_ext.rb +5 -0
  38. data/lib/gamebox/lib/rect.rb +548 -548
  39. data/lib/gamebox/lib/sorted_list.rb +1 -1
  40. data/lib/gamebox/lib/symbol_ext.rb +8 -0
  41. data/lib/gamebox/physical_director.rb +1 -1
  42. data/lib/gamebox/physical_stage.rb +3 -3
  43. data/lib/gamebox/physics.rb +0 -3
  44. data/lib/gamebox/resource_manager.rb +22 -17
  45. data/lib/gamebox/sound_manager.rb +3 -2
  46. data/lib/gamebox/spatial_hash.rb +60 -31
  47. data/lib/gamebox/spatial_stagehand.rb +30 -6
  48. data/lib/gamebox/spec/helper.rb +7 -7
  49. data/lib/gamebox/stage.rb +18 -19
  50. data/lib/gamebox/stage_manager.rb +33 -23
  51. data/lib/gamebox/stagehand.rb +3 -0
  52. data/lib/gamebox/svg_document.rb +1 -1
  53. data/lib/gamebox/tasks/gamebox_tasks.rake +133 -0
  54. data/lib/gamebox/templates/actor.erb +0 -2
  55. data/lib/gamebox/templates/actor_view.erb +1 -3
  56. data/lib/gamebox/templates/template_app/Gemfile +3 -2
  57. data/lib/gamebox/templates/template_app/Rakefile +3 -8
  58. data/lib/gamebox/templates/template_app/config/environment.rb +7 -39
  59. data/lib/gamebox/templates/template_app/src/demo_stage.rb +1 -2
  60. data/lib/gamebox/templates/template_app/src/my_actor.rb +0 -3
  61. data/lib/gamebox/version.rb +2 -2
  62. data/lib/gamebox/viewport.rb +44 -8
  63. data/lib/gamebox/views/graphical_actor_view.rb +22 -16
  64. data/lib/gamebox/wrapped_screen.rb +9 -1
  65. data/script/perf_spatial_hash.rb +49 -58
  66. data/script/perf_struct_vs_array.rb +32 -0
  67. data/spec/actor_factory_spec.rb +61 -0
  68. data/spec/actor_spec.rb +24 -18
  69. data/spec/actor_view_spec.rb +51 -6
  70. data/spec/animated_spec.rb +27 -6
  71. data/spec/arbiter_spec.rb +12 -24
  72. data/spec/backstage_spec.rb +1 -1
  73. data/spec/behavior_spec.rb +3 -3
  74. data/spec/class_finder_spec.rb +13 -0
  75. data/spec/collidable_spec.rb +30 -10
  76. data/spec/emitter_spec.rb +20 -0
  77. data/spec/helper.rb +5 -21
  78. data/spec/input_manager_spec.rb +134 -0
  79. data/spec/label_spec.rb +0 -1
  80. data/spec/physical_spec.rb +114 -5
  81. data/spec/resource_manager_spec.rb +1 -2
  82. data/spec/spatial_hash_spec.rb +23 -7
  83. data/spec/spatial_stagehand_spec.rb +97 -0
  84. data/spec/stage_manager_spec.rb +0 -1
  85. data/spec/stage_spec.rb +2 -2
  86. data/spec/viewport_spec.rb +92 -48
  87. metadata +223 -119
  88. data/.gitignore +0 -11
  89. data/History.txt +0 -80
  90. data/VERSION +0 -1
  91. data/lib/gamebox/event_compat.rb +0 -285
  92. data/lib/gamebox/lib/diy.rb +0 -371
  93. data/lib/gamebox/lib/numbers_ext.rb +0 -3
  94. data/lib/gamebox/tasks/gamebox_tasks.rb +0 -61
  95. data/load_paths.rb +0 -20
data/Gemfile CHANGED
@@ -1,9 +1,2 @@
1
1
  source "http://rubygems.org"
2
- gem "rake"
3
- gem "rspec"
4
- gem "jeweler"
5
- gem "constructor"
6
- gem "publisher"
7
- gem "gosu"
8
- gem "chipmunk"
9
- gem "polaris"
2
+ gemspec
data/Rakefile CHANGED
@@ -1,30 +1,5 @@
1
- begin
2
- require 'jeweler'
3
- require File.dirname(__FILE__)+'/lib/gamebox/version'
4
- Jeweler::Tasks.new do |gem|
5
- gem.name = "gamebox"
6
- gem.executables = "gamebox"
7
- gem.rubyforge_project = "gamebox"
8
- gem.summary = %Q{Framework for building and distributing games using Gosu}
9
- gem.description = %Q{Framework for building and distributing games using Gosu}
10
- gem.email = "shawn42@gmail.com"
11
- gem.homepage = "http://shawn42.github.com/gamebox"
12
- gem.authors = ["Shawn Anderson","Jason Roelofs","Karlin Fox"]
13
- gem.add_development_dependency "rspec"
14
- gem.add_development_dependency "jeweler"
15
- gem.add_dependency 'gosu'
16
- gem.add_dependency 'bundler'
17
- gem.add_dependency 'constructor'
18
- gem.add_dependency 'publisher'
19
- gem.files.exclude 'examples'
20
- gem.test_files = FileList['{spec,test}/**/*.rb']
21
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
- end
23
- Jeweler::GemcutterTasks.new
24
- rescue LoadError
25
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
26
- end
27
-
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
28
3
  begin
29
4
  require 'metric_fu'
30
5
  rescue LoadError
@@ -38,27 +13,28 @@ STATS_DIRECTORIES = [
38
13
 
39
14
  desc "Report code statistics (KLOCs, etc) from the application"
40
15
  task :stats do
41
- require 'code_statistics'
16
+ require "#{File.dirname(__FILE__)}/lib/gamebox/lib/code_statistics"
42
17
  CodeStatistics.new(*STATS_DIRECTORIES).to_s
43
18
  end
44
19
 
45
20
  begin
46
- require 'spec/rake/spectask'
21
+ require 'rspec/core/rake_task'
47
22
  desc "Run all rspecs"
48
- Spec::Rake::SpecTask.new(:spec) do |t|
49
- t.spec_files = FileList['spec/*_spec.rb']
23
+ RSpec::Core::RakeTask.new(:spec) do |t|
24
+ t.pattern = 'spec/**/*_spec.rb'
50
25
  end
51
- task :default => :spec
52
26
 
53
- desc "Run rcov rspecs"
54
- Spec::Rake::SpecTask.new('rcov_rspec') do |t|
55
- t.spec_files = FileList['spec/*_spec.rb']
56
- t.rcov = true
57
- t.rcov_opts = ['--exclude', 'examples']
27
+ desc "Run all specs with rcov"
28
+ RSpec::Core::RakeTask.new(:rcov) do |t|
29
+ t.rcov = true
58
30
  end
31
+
32
+ task :default => :spec
59
33
  rescue LoadError
60
34
  puts "please install rspec to run tests"
61
35
  puts "install with gem install rspec"
62
36
  end
63
37
 
38
+
39
+
64
40
  # vim: syntax=Ruby
data/TODO.txt CHANGED
@@ -1,31 +1,31 @@
1
- planned features:
2
- add network manager stub
3
- highscore upload system (use from chingu)
1
+ TAKE YOUR PICK:
2
+ - specs for stage manager
3
+ - collision detection performance for tiles?
4
+ - collision detection honoring rotation?
5
+ - highscore upload system (use from chingu) (takes json now)
6
+ - rewrite update system to be all callback based
7
+ * what does that do to PhysicalDirector when Director goes away?
8
+ - solidify rdocs (including tutorial)
9
+ - collidable "grouping"
4
10
 
5
- change update system to
6
- on_update do |time|
7
- # do stuff?
8
- end
11
+ EXAMPLES:
12
+ - move to separate repo?
13
+ - nario:
14
+ error on collision
9
15
 
10
- update physical objects to use chipmunk_object.rb
16
+ SOMEDAY:
17
+ - add network manager stub
18
+ - update physical objects to use chipmunk_object.rb
11
19
 
12
- make complex Phyiscal behaviors
13
- - made up by a group of bodies pinned together
14
- - easy joints
15
- physical objects should have bodies and shapes body/shape should be shorthand for bodies.first/shapes.first
16
-
17
- - solidify rdocs (including tutorial)
18
- SVGS
19
- create a DynamicPhysicalActor that can be built from external verts
20
- add nice actor debugging
21
- add Extra; actor with a short time to live (TTL); useful for special effects (maybe as a behavior)
20
+ - make complex Phyiscal behaviors
21
+ * made up by a group of bodies pinned together
22
+ - physical objects should have bodies and shapes body/shape should be shorthand for bodies.first/shapes.first
23
+
24
+ - create a DynamicPhysicalActor that can be built from external verts (SVG)
25
+
26
+ - add nice actor debugging
27
+ - add Extra; actor with a short time to live (TTL); useful for special effects (maybe as a behavior)
22
28
 
23
- static deployment bundles (crate, love-clone; custom C project)
24
- ruby
25
- gosu
26
- possible features:
27
- AI
28
- state machine
29
- rule based
30
- optional GUI via rubygoo
31
- gamebox server (content server?)
29
+ - optional GUI via Fidgit?
30
+ - gamebox server (content server?)
31
+
@@ -66,11 +66,11 @@ The reason I wrote Gamebox is twofold: first, to aid in 48 hour game writing com
66
66
 
67
67
  An Actor is the base class for any game object. A building, the player, the score, the bullet are all examples of actors. Actors can even be invisible. Any number of Behavior s can be added to an Actor to define how it will react to the world via the Actor.has_behaviors method.
68
68
 
69
- So Actors sound fun, how do I get one? That's where the ActorFactory comes in. In your Level class (demo_level.rb by default) you can use the create_actor helper method as shown below.
69
+ So Actors sound fun, how do I get one? That's where the ActorFactory comes in. In your Stage class (demo_stage.rb by default) you can use the spawn helper method as shown below.
70
70
 
71
71
  @score = spawn :score, :x => 10, :y => 10
72
72
 
73
- This call will return an instance of the Score class (the first arg is the symbolized version of the classname). The ActorFactory will try to require the symbolized class name for you. It will also create the view for the actor and register it to be drawn. Which view is instantiated depends on the actor requested. The factory will always look for a class named the same as the actor with View on the end. So the actor Score will look for ScoreView. If ScoreView does not exist, a generic view class will be used based on the behaviors of the actor. Each ActorView class is constructed with a reference to the actor it is displaying. See ActorFactor#build for more details.
73
+ This call will return an instance of the Score class (the first arg is the symbolized version of the classname). It will also create the view for the actor and register it to be drawn. Which view is instantiated depends on the actor requested. The factory will always look for a class named the same as the actor with View on the end. So the actor Score will look for ScoreView. If ScoreView does not exist, a generic view class will be used based on the behaviors of the actor. Each ActorView class is constructed with a reference to the actor it is displaying. See ActorFactor#build for more details.
74
74
 
75
75
  That's great, but how do I tell my actors what to do? They can register for events of course! A common place for this is in your actor's setup method. Here is an example from the roids example.
76
76
 
data/gamebox.gemspec CHANGED
@@ -1,202 +1,44 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gamebox/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{gamebox}
8
- s.version = "0.2.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.name = "gamebox"
7
+ s.version = Gamebox::VERSION::STRING
8
+ s.platform = Gem::Platform::RUBY
11
9
  s.authors = ["Shawn Anderson", "Jason Roelofs", "Karlin Fox"]
12
- s.date = %q{2010-11-02}
13
- s.default_executable = %q{gamebox}
14
- s.description = %q{Framework for building and distributing games using Gosu}
15
10
  s.email = %q{shawn42@gmail.com}
16
- s.executables = ["gamebox"]
17
- s.extra_rdoc_files = [
18
- "README.txt"
19
- ]
20
- s.files = [
21
- ".gitignore",
22
- "Gemfile",
23
- "History.txt",
24
- "README.txt",
25
- "Rakefile",
26
- "TODO.txt",
27
- "VERSION",
28
- "bin/gamebox",
29
- "docs/CODE_REVIEW",
30
- "docs/gamebox.bat",
31
- "docs/getting_started.rdoc",
32
- "docs/logo.ico",
33
- "docs/logo.png",
34
- "gamebox.gemspec",
35
- "lib/gamebox.rb",
36
- "lib/gamebox/actor.rb",
37
- "lib/gamebox/actor_factory.rb",
38
- "lib/gamebox/actor_view.rb",
39
- "lib/gamebox/actors/collidable_debugger.rb",
40
- "lib/gamebox/actors/curtain.rb",
41
- "lib/gamebox/actors/fps.rb",
42
- "lib/gamebox/actors/label.rb",
43
- "lib/gamebox/actors/logo.rb",
44
- "lib/gamebox/actors/score.rb",
45
- "lib/gamebox/actors/spatial_debugger.rb",
46
- "lib/gamebox/actors/svg_actor.rb",
47
- "lib/gamebox/arbiter.rb",
48
- "lib/gamebox/backstage.rb",
49
- "lib/gamebox/behavior.rb",
50
- "lib/gamebox/behaviors/animated.rb",
51
- "lib/gamebox/behaviors/audible.rb",
52
- "lib/gamebox/behaviors/collidable.rb",
53
- "lib/gamebox/behaviors/collidable/aabb_collidable.rb",
54
- "lib/gamebox/behaviors/collidable/circle_collidable.rb",
55
- "lib/gamebox/behaviors/collidable/collidable_shape.rb",
56
- "lib/gamebox/behaviors/collidable/polygon_collidable.rb",
57
- "lib/gamebox/behaviors/graphical.rb",
58
- "lib/gamebox/behaviors/layered.rb",
59
- "lib/gamebox/behaviors/physical.rb",
60
- "lib/gamebox/behaviors/updatable.rb",
61
- "lib/gamebox/class_finder.rb",
62
- "lib/gamebox/config_manager.rb",
63
- "lib/gamebox/console_app.rb",
64
- "lib/gamebox/data/config/objects.yml",
65
- "lib/gamebox/data/fonts/Asimov.ttf",
66
- "lib/gamebox/data/fonts/GAMEBOX_FONTS_GO_HERE",
67
- "lib/gamebox/data/graphics/GAMEBOX_GRAPHICS_GO_HERE",
68
- "lib/gamebox/data/graphics/logo.png",
69
- "lib/gamebox/data/music/GAMEBOX_MUSIC_GOES_HERE",
70
- "lib/gamebox/data/sounds/GAMEBOX_SOUND_FX_GO_HERE",
71
- "lib/gamebox/director.rb",
72
- "lib/gamebox/event_compat.rb",
73
- "lib/gamebox/ftor.rb",
74
- "lib/gamebox/gamebox_application.rb",
75
- "lib/gamebox/gamebox_generator.rb",
76
- "lib/gamebox/generators/actor_generator.rb",
77
- "lib/gamebox/generators/view_generator.rb",
78
- "lib/gamebox/hooked_gosu_window.rb",
79
- "lib/gamebox/input_manager.rb",
80
- "lib/gamebox/lib/aliasing.rb",
81
- "lib/gamebox/lib/code_statistics.rb",
82
- "lib/gamebox/lib/diy.rb",
83
- "lib/gamebox/lib/inflections.rb",
84
- "lib/gamebox/lib/inflector.rb",
85
- "lib/gamebox/lib/linked_list.rb",
86
- "lib/gamebox/lib/metaclass.rb",
87
- "lib/gamebox/lib/numbers_ext.rb",
88
- "lib/gamebox/lib/platform.rb",
89
- "lib/gamebox/lib/publisher_ext.rb",
90
- "lib/gamebox/lib/rect.rb",
91
- "lib/gamebox/lib/sorted_list.rb",
92
- "lib/gamebox/physical_director.rb",
93
- "lib/gamebox/physical_stage.rb",
94
- "lib/gamebox/physics.rb",
95
- "lib/gamebox/resource_manager.rb",
96
- "lib/gamebox/sound_manager.rb",
97
- "lib/gamebox/spatial_hash.rb",
98
- "lib/gamebox/spatial_stagehand.rb",
99
- "lib/gamebox/spec/helper.rb",
100
- "lib/gamebox/stage.rb",
101
- "lib/gamebox/stage_manager.rb",
102
- "lib/gamebox/stagehand.rb",
103
- "lib/gamebox/svg_document.rb",
104
- "lib/gamebox/tasks/gamebox_tasks.rb",
105
- "lib/gamebox/templates/actor.erb",
106
- "lib/gamebox/templates/actor_spec.erb",
107
- "lib/gamebox/templates/actor_view.erb",
108
- "lib/gamebox/templates/actor_view_spec.erb",
109
- "lib/gamebox/templates/template_app/.gitignore",
110
- "lib/gamebox/templates/template_app/Gemfile",
111
- "lib/gamebox/templates/template_app/README",
112
- "lib/gamebox/templates/template_app/Rakefile",
113
- "lib/gamebox/templates/template_app/config/boot.rb",
114
- "lib/gamebox/templates/template_app/config/environment.rb",
115
- "lib/gamebox/templates/template_app/config/game.yml",
116
- "lib/gamebox/templates/template_app/config/stage_config.yml",
117
- "lib/gamebox/templates/template_app/data/fonts/FONTS_GO_HERE",
118
- "lib/gamebox/templates/template_app/data/graphics/GRAPHICS_GO_HERE",
119
- "lib/gamebox/templates/template_app/data/music/MUSIC_GOES_HERE",
120
- "lib/gamebox/templates/template_app/data/sounds/SOUND_FX_GO_HERE",
121
- "lib/gamebox/templates/template_app/script/generate",
122
- "lib/gamebox/templates/template_app/spec/helper.rb",
123
- "lib/gamebox/templates/template_app/src/app.rb",
124
- "lib/gamebox/templates/template_app/src/demo_stage.rb",
125
- "lib/gamebox/templates/template_app/src/game.rb",
126
- "lib/gamebox/templates/template_app/src/my_actor.rb",
127
- "lib/gamebox/version.rb",
128
- "lib/gamebox/viewport.rb",
129
- "lib/gamebox/views/graphical_actor_view.rb",
130
- "lib/gamebox/wrapped_screen.rb",
131
- "load_paths.rb",
132
- "script/perf_polaris.rb",
133
- "script/perf_spatial_hash.rb",
134
- "spec/actor_spec.rb",
135
- "spec/actor_view_spec.rb",
136
- "spec/animated_spec.rb",
137
- "spec/arbiter_spec.rb",
138
- "spec/backstage_spec.rb",
139
- "spec/behavior_spec.rb",
140
- "spec/collidable_spec.rb",
141
- "spec/helper.rb",
142
- "spec/label_spec.rb",
143
- "spec/physical_spec.rb",
144
- "spec/resource_manager_spec.rb",
145
- "spec/spatial_hash_spec.rb",
146
- "spec/stage_manager_spec.rb",
147
- "spec/stage_spec.rb",
148
- "spec/viewport_spec.rb"
149
- ]
150
11
  s.homepage = %q{http://shawn42.github.com/gamebox}
151
- s.rdoc_options = ["--charset=UTF-8"]
152
- s.require_paths = ["lib"]
153
- s.rubyforge_project = %q{gamebox}
154
- s.rubygems_version = %q{1.3.7}
12
+ s.description = %q{Framework for building and distributing games using Gosu}
155
13
  s.summary = %q{Framework for building and distributing games using Gosu}
156
- s.test_files = [
157
- "spec/actor_spec.rb",
158
- "spec/actor_view_spec.rb",
159
- "spec/animated_spec.rb",
160
- "spec/arbiter_spec.rb",
161
- "spec/backstage_spec.rb",
162
- "spec/behavior_spec.rb",
163
- "spec/collidable_spec.rb",
164
- "spec/helper.rb",
165
- "spec/label_spec.rb",
166
- "spec/physical_spec.rb",
167
- "spec/resource_manager_spec.rb",
168
- "spec/spatial_hash_spec.rb",
169
- "spec/stage_manager_spec.rb",
170
- "spec/stage_spec.rb",
171
- "spec/viewport_spec.rb"
172
- ]
14
+ s.rubyforge_project = "gamebox"
15
+
16
+ s.files = `git ls-files`.split("\n").reject{ |f| f[/^examples\//] || f[/^\./] }
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency "gosu"
22
+ s.add_dependency "constructor"
23
+ s.add_dependency "publisher"
24
+ s.add_dependency "diy"
25
+ s.add_dependency "tween"
26
+ s.add_dependency "require_all"
27
+ s.add_dependency "kvo"
28
+ s.add_dependency "pry", '0.9.6'
29
+ s.add_dependency "pry-remote"
30
+
31
+ # TODO make this optional
32
+ s.add_dependency "chipmunk"
173
33
 
174
- if s.respond_to? :specification_version then
175
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
176
- s.specification_version = 3
34
+ s.add_development_dependency "rspec-core"
35
+ s.add_development_dependency "rspec-mocks"
36
+ s.add_development_dependency "rspec-expectations"
37
+ s.add_development_dependency "mocha"
38
+ s.add_development_dependency "rspec"
39
+ s.add_development_dependency "rake"
40
+ s.add_development_dependency "polaris"
41
+ s.add_development_dependency 'rcov'
177
42
 
178
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
179
- s.add_development_dependency(%q<rspec>, [">= 0"])
180
- s.add_development_dependency(%q<jeweler>, [">= 0"])
181
- s.add_runtime_dependency(%q<gosu>, [">= 0"])
182
- s.add_runtime_dependency(%q<bundler>, [">= 0"])
183
- s.add_runtime_dependency(%q<constructor>, [">= 0"])
184
- s.add_runtime_dependency(%q<publisher>, [">= 0"])
185
- else
186
- s.add_dependency(%q<rspec>, [">= 0"])
187
- s.add_dependency(%q<jeweler>, [">= 0"])
188
- s.add_dependency(%q<gosu>, [">= 0"])
189
- s.add_dependency(%q<bundler>, [">= 0"])
190
- s.add_dependency(%q<constructor>, [">= 0"])
191
- s.add_dependency(%q<publisher>, [">= 0"])
192
- end
193
- else
194
- s.add_dependency(%q<rspec>, [">= 0"])
195
- s.add_dependency(%q<jeweler>, [">= 0"])
196
- s.add_dependency(%q<gosu>, [">= 0"])
197
- s.add_dependency(%q<bundler>, [">= 0"])
198
- s.add_dependency(%q<constructor>, [">= 0"])
199
- s.add_dependency(%q<publisher>, [">= 0"])
200
- end
201
43
  end
202
44
 
data/lib/gamebox.rb CHANGED
@@ -1,16 +1,20 @@
1
- [
2
- "gamebox",
3
- "gamebox/actors",
4
- "gamebox/ai",
5
- "gamebox/behaviors",
6
- "gamebox/generators",
7
- "gamebox/lib",
8
- "gamebox/tasks",
9
- "gamebox/views"
10
- ].each do |path|
11
- $: << File.dirname(__FILE__)+"/"+path
12
- end
13
-
14
1
  GAMEBOX_PATH = File.join(File.dirname(__FILE__),"gamebox/")
15
- require 'gamebox_application'
2
+ require 'chipmunk'
3
+ require 'diy'
4
+ require 'constructor'
5
+ require 'kvo'
6
+ require 'tween'
7
+ require 'gosu'
8
+ include Gosu
9
+ require 'pry'
10
+ require 'pry-remote'
11
+
12
+
13
+ # TODO move this to some logging class
14
+ def log(output, level = :debug)
15
+ t = Time.now
16
+ puts "[#{t.min}:#{t.sec}:#{t.usec}] [#{level}] #{output}"
17
+ end
16
18
 
19
+ require 'require_all'
20
+ require_all Dir.glob("#{GAMEBOX_PATH}/**/*.rb").reject { |f| f.match("template_app") || f.match("spec") || f.match("gamebox_application.rb")}
data/lib/gamebox/actor.rb CHANGED
@@ -1,29 +1,36 @@
1
- require 'publisher'
2
- require 'inflector'
3
-
4
1
  # Actor represent a game object.
5
2
  # Actors can have behaviors added and removed from them. Such as :physical or :animated.
6
3
  # They are created and hooked up to their optional View class in Stage#create_actor.
7
4
  class Actor
8
- extend Publisher
9
- can_fire_anything
5
+ include Kvo
10
6
 
11
- attr_accessor :behaviors, :x, :y, :stage, :input_manager,
7
+ attr_accessor :behaviors, :stage, :input_manager,
12
8
  :resource_manager, :alive, :opts, :visible, :director,
9
+ :wrapped_screen,
13
10
  :actor_type
14
11
 
12
+ # TODO change alive and visible to be KVO
13
+ kvo_attr_accessor :x, :y, :alive, :visible
14
+
15
+ can_fire_anything
16
+
17
+ DEFAULT_PARAMS = {
18
+ :x => 0,
19
+ :y => 0,
20
+ }.freeze
21
+
15
22
  def initialize(opts={}) # :nodoc:
16
- @opts = opts
17
- @x = opts[:x]
18
- @y = opts[:y]
19
- @x ||= 0
20
- @y ||= 0
21
- @stage = opts[:stage]
22
- @input_manager = opts[:input]
23
- @resource_manager = opts[:resources]
24
- @director = opts[:director]
25
- @actor_type = opts[:actor_type]
26
- @alive = true
23
+ @opts = DEFAULT_PARAMS.merge opts
24
+ self.x = @opts[:x]
25
+ self.y = @opts[:y]
26
+
27
+ @stage = @opts[:stage]
28
+ @input_manager = @opts[:input]
29
+ @resource_manager = @opts[:resources]
30
+ @director = @opts[:director]
31
+ @actor_type = @opts[:actor_type]
32
+ @wrapped_screen = @opts[:wrapped_screen]
33
+ self.alive = true
27
34
 
28
35
  @behaviors = {}
29
36
 
@@ -62,13 +69,17 @@ class Actor
62
69
 
63
70
  # Is the actor still alive?
64
71
  def alive?
65
- @alive
72
+ self.alive
73
+ end
74
+
75
+ def screen
76
+ @wrapped_screen
66
77
  end
67
78
 
68
79
  # Tells the actor's Director that he wants to be removed; and unsubscribes
69
80
  # the actor from all input events.
70
81
  def remove_self
71
- @alive = false
82
+ self.alive = false
72
83
  fire :remove_me
73
84
  @input_manager.unsubscribe_all self
74
85
  end
@@ -91,11 +102,6 @@ class Actor
91
102
  behavior_sym = behavior_def
92
103
  behavior_opts = {}
93
104
  end
94
- begin
95
- require behavior_sym.to_s;
96
- rescue LoadError
97
- # maybe its included somewhere else
98
- end
99
105
  klass = Object.const_get Inflector.camelize(behavior_sym)
100
106
  @behaviors[behavior_sym] = klass.new self, behavior_opts
101
107
  end
@@ -131,16 +137,20 @@ class Actor
131
137
 
132
138
  def hide
133
139
  fire :hide_me if visible?
134
- @visible = false
140
+ self.visible = false
135
141
  end
136
142
 
137
143
  def show
138
144
  fire :show_me unless visible?
139
- @visible = true
145
+ self.visible = true
140
146
  end
141
147
 
142
148
  def visible?
143
- @visible
149
+ self.visible
150
+ end
151
+
152
+ def viewport
153
+ @stage.viewport
144
154
  end
145
155
 
146
156
  def self.behaviors