gamebox 0.0.5 → 0.0.6

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.
Files changed (47) hide show
  1. data/History.txt +11 -0
  2. data/Manifest.txt +27 -19
  3. data/Rakefile +10 -12
  4. data/TODO.txt +5 -5
  5. data/bin/gamebox +27 -3
  6. data/lib/gamebox.rb +0 -1
  7. data/lib/gamebox/gamebox_application.rb +1 -1
  8. data/lib/gamebox/gamebox_generator.rb +24 -0
  9. data/lib/gamebox/generators/actor_generator.rb +43 -0
  10. data/lib/gamebox/input_manager.rb +19 -3
  11. data/lib/gamebox/level.rb +3 -2
  12. data/lib/gamebox/mode.rb +1 -1
  13. data/lib/gamebox/physical_level.rb +2 -1
  14. data/lib/gamebox/platform.rb +14 -0
  15. data/lib/gamebox/tasks/gamebox_tasks.rb +19 -0
  16. data/lib/gamebox/templates/actor.erb +12 -0
  17. data/lib/gamebox/{template_app → templates/template_app}/README +0 -0
  18. data/lib/gamebox/{template_app → templates/template_app}/Rakefile +8 -0
  19. data/lib/gamebox/{template_app → templates/template_app}/config/boot.rb +0 -0
  20. data/lib/gamebox/{template_app → templates/template_app}/config/environment.rb +0 -0
  21. data/lib/gamebox/{template_app → templates/template_app}/config/game.yml +0 -0
  22. data/lib/gamebox/{template_app → templates/template_app}/config/mode_level_config.yml +0 -0
  23. data/lib/gamebox/{template_app → templates/template_app}/config/objects.yml +0 -0
  24. data/lib/gamebox/{template_app → templates/template_app}/data/fonts/FONTS_GO_HERE +0 -0
  25. data/lib/gamebox/{template_app → templates/template_app}/data/graphics/GRAPHICS_GO_HERE +0 -0
  26. data/lib/gamebox/{template_app → templates/template_app}/data/music/MUSIC_GOES_HERE +0 -0
  27. data/lib/gamebox/{template_app → templates/template_app}/data/sounds/SOUND_FX_GO_HERE +0 -0
  28. data/lib/gamebox/{template_app → templates/template_app}/doc/README_FOR_APP +0 -0
  29. data/lib/gamebox/{template_app → templates/template_app}/lib/code_statistics.rb +0 -0
  30. data/lib/gamebox/{template_app → templates/template_app}/lib/diy.rb +0 -0
  31. data/lib/gamebox/{template_app → templates/template_app}/lib/platform.rb +0 -0
  32. data/lib/gamebox/templates/template_app/script/generate +8 -0
  33. data/lib/gamebox/{template_app → templates/template_app}/src/app.rb +0 -0
  34. data/lib/gamebox/{template_app → templates/template_app}/src/demo_level.rb +1 -1
  35. data/lib/gamebox/{template_app → templates/template_app}/src/game.rb +0 -0
  36. data/lib/gamebox/{template_app → templates/template_app}/src/my_actor.rb +0 -0
  37. data/lib/gamebox/templates/template_app/test/helper.rb +4 -0
  38. data/lib/gamebox/templates/test_actor.erb +11 -0
  39. data/lib/gamebox/version.rb +1 -1
  40. data/test/helper.rb +16 -15
  41. data/test/test_actor.rb +10 -12
  42. data/test/test_animated.rb +16 -18
  43. data/test/test_line_of_site.rb +1 -3
  44. data/test/test_physical.rb +1 -1
  45. data/test/test_polaris.rb +41 -41
  46. data/test/test_viewport.rb +26 -30
  47. metadata +30 -22
data/History.txt CHANGED
@@ -36,3 +36,14 @@
36
36
 
37
37
  * Bug fix release for RubyWeekend #3
38
38
  * sound manager now ignores txt files
39
+
40
+ === 0.0.6 / 2009-06-30
41
+
42
+ * Multiple fixes and features
43
+ * added rake run to all gamebox games
44
+ * added rake debug to all gamebox games
45
+ * added input_manager to levels
46
+ * added usage -help to gamebox
47
+ * added ./script/generate to generate actors (ie ./script/generate actor Foo)
48
+ * migrated all test to use rspec
49
+ * changed clear_hooks to take a listener instance
data/Manifest.txt CHANGED
@@ -28,6 +28,8 @@ lib/gamebox/data/music/GAMEBOX_MUSIC_GOES_HERE
28
28
  lib/gamebox/data/sounds/GAMEBOX_SOUND_FX_GO_HERE
29
29
  lib/gamebox/director.rb
30
30
  lib/gamebox/gamebox_application.rb
31
+ lib/gamebox/gamebox_generator.rb
32
+ lib/gamebox/generators/actor_generator.rb
31
33
  lib/gamebox/graphical.rb
32
34
  lib/gamebox/graphical_actor_view.rb
33
35
  lib/gamebox/inflections.rb
@@ -45,6 +47,7 @@ lib/gamebox/physical.rb
45
47
  lib/gamebox/physical_director.rb
46
48
  lib/gamebox/physical_level.rb
47
49
  lib/gamebox/physics.rb
50
+ lib/gamebox/platform.rb
48
51
  lib/gamebox/publisher_ext.rb
49
52
  lib/gamebox/resource_manager.rb
50
53
  lib/gamebox/score.rb
@@ -53,25 +56,30 @@ lib/gamebox/sound_manager.rb
53
56
  lib/gamebox/surface_ext.rb
54
57
  lib/gamebox/svg_actor.rb
55
58
  lib/gamebox/svg_document.rb
56
- lib/gamebox/template_app/README
57
- lib/gamebox/template_app/Rakefile
58
- lib/gamebox/template_app/config/boot.rb
59
- lib/gamebox/template_app/config/environment.rb
60
- lib/gamebox/template_app/config/game.yml
61
- lib/gamebox/template_app/config/mode_level_config.yml
62
- lib/gamebox/template_app/config/objects.yml
63
- lib/gamebox/template_app/data/fonts/FONTS_GO_HERE
64
- lib/gamebox/template_app/data/graphics/GRAPHICS_GO_HERE
65
- lib/gamebox/template_app/data/music/MUSIC_GOES_HERE
66
- lib/gamebox/template_app/data/sounds/SOUND_FX_GO_HERE
67
- lib/gamebox/template_app/doc/README_FOR_APP
68
- lib/gamebox/template_app/lib/code_statistics.rb
69
- lib/gamebox/template_app/lib/diy.rb
70
- lib/gamebox/template_app/lib/platform.rb
71
- lib/gamebox/template_app/src/app.rb
72
- lib/gamebox/template_app/src/demo_level.rb
73
- lib/gamebox/template_app/src/game.rb
74
- lib/gamebox/template_app/src/my_actor.rb
59
+ lib/gamebox/tasks/gamebox_tasks.rb
60
+ lib/gamebox/templates/actor.erb
61
+ lib/gamebox/templates/template_app/README
62
+ lib/gamebox/templates/template_app/Rakefile
63
+ lib/gamebox/templates/template_app/config/boot.rb
64
+ lib/gamebox/templates/template_app/config/environment.rb
65
+ lib/gamebox/templates/template_app/config/game.yml
66
+ lib/gamebox/templates/template_app/config/mode_level_config.yml
67
+ lib/gamebox/templates/template_app/config/objects.yml
68
+ lib/gamebox/templates/template_app/data/fonts/FONTS_GO_HERE
69
+ lib/gamebox/templates/template_app/data/graphics/GRAPHICS_GO_HERE
70
+ lib/gamebox/templates/template_app/data/music/MUSIC_GOES_HERE
71
+ lib/gamebox/templates/template_app/data/sounds/SOUND_FX_GO_HERE
72
+ lib/gamebox/templates/template_app/doc/README_FOR_APP
73
+ lib/gamebox/templates/template_app/lib/code_statistics.rb
74
+ lib/gamebox/templates/template_app/lib/diy.rb
75
+ lib/gamebox/templates/template_app/lib/platform.rb
76
+ lib/gamebox/templates/template_app/script/generate
77
+ lib/gamebox/templates/template_app/src/app.rb
78
+ lib/gamebox/templates/template_app/src/demo_level.rb
79
+ lib/gamebox/templates/template_app/src/game.rb
80
+ lib/gamebox/templates/template_app/src/my_actor.rb
81
+ lib/gamebox/templates/template_app/test/helper.rb
82
+ lib/gamebox/templates/test_actor.erb
75
83
  lib/gamebox/updatable.rb
76
84
  lib/gamebox/version.rb
77
85
  lib/gamebox/viewport.rb
data/Rakefile CHANGED
@@ -2,9 +2,7 @@ require 'rubygems'
2
2
  gem 'hoe', '>= 2.3.0'
3
3
  require 'hoe'
4
4
 
5
- module Gamebox
6
- VERSION = '0.0.5'
7
- end
5
+ require File.dirname(__FILE__)+'/lib/gamebox/version'
8
6
  Hoe.new 'gamebox' do |spec|
9
7
  spec.developer('Shawn Anderson', 'shawn42@gmail.com')
10
8
  spec.author = "Shawn Anderson"
@@ -12,11 +10,11 @@ Hoe.new 'gamebox' do |spec|
12
10
  spec.email = 'shawn42@gmail.com'
13
11
  spec.summary = "Framework for building and distributing games using Rubygame"
14
12
  spec.url = "http://shawn42.github.com/gamebox"
15
- spec.version = Gamebox::VERSION
16
- spec.changes = spec.paragraphs_of('History.txt', 8..9).join("\n\n")
13
+ spec.version = Gamebox::VERSION::STRING
14
+ spec.changes = spec.paragraphs_of('History.txt', 10..11).join("\n\n")
17
15
  spec.extra_deps << ['constructor']
18
16
  spec.extra_deps << ['publisher']
19
- spec.extra_deps << ['bacon']
17
+ spec.extra_deps << ['rspec']
20
18
  if spec.extra_rdoc_files
21
19
  spec.extra_rdoc_files << 'docs/getting_started.rdoc'
22
20
  end
@@ -33,12 +31,12 @@ task :stats do
33
31
  CodeStatistics.new(*STATS_DIRECTORIES).to_s
34
32
  end
35
33
 
36
- desc "Run all the strips of bacon"
37
- task :bacon do
38
- # sh "bacon -Ilib:test --automatic --quiet"
39
- sh "bacon -Ilib:test --automatic "
34
+ require 'spec/rake/spectask'
35
+ desc "Run all specs"
36
+ Spec::Rake::SpecTask.new('specs') do |t|
37
+ t.spec_opts = ["-r", "./test/helper"]
38
+ t.spec_files = FileList['test//test_*.rb']
40
39
  end
41
-
42
- task :test => :bacon
40
+ task :test => :specs
43
41
 
44
42
  # vim: syntax=Ruby
data/TODO.txt CHANGED
@@ -1,6 +1,7 @@
1
1
  planned features:
2
- create an :updatable behavior for actors that wish to be updated (to remove unnecessarily calling update)
3
- - add auto_update_actors method to Level?
2
+ add basic generator for things like actors/levels/etc with tests
3
+ add while key down K_UP callback?
4
+
4
5
  allow easy pausing of game and physics
5
6
  - fire :pause event w/ a new Director of actors?
6
7
  change Polaris to return partial path when step max is reached
@@ -9,16 +10,15 @@ allow for repeating actors (tiles)
9
10
  allow overriding of animation timing
10
11
  make complex Phyiscal behaviors (made up by a group of shapes/bodies pinned together?)
11
12
  physical objects should have bodies and shapes body/shape should be shorthand for bodies.first/shapes.first
12
- - add basic generator for things like actors/levels/etc with tests
13
+
13
14
  - solidify rdocs (including tutorial)
14
15
  SVGS
15
16
  create a DynamicPhysicalActor that can be built from external verts
16
- add while key down K_UP callback?
17
17
  add nice actor debugging
18
18
  add Extra; actor with a short time to live (TTL); useful for special effects (maybe as a behavior)
19
19
  add some kind of fade in/out for actors w/ smooth interpolation
20
20
 
21
- static deployment bundles (crate)
21
+ static deployment bundles (crate, love-clone; custom C project)
22
22
  ruby
23
23
  SDL
24
24
  rubygame
data/bin/gamebox CHANGED
@@ -3,22 +3,44 @@
3
3
  Signal.trap("INT") { puts; exit }
4
4
 
5
5
  require File.dirname(__FILE__) + '/../lib/gamebox/version'
6
- if %w(--version -v).include? ARGV.first
6
+
7
+ def print_version
7
8
  puts "Gamebox #{Gamebox::VERSION::STRING}"
9
+ end
10
+ def print_usage
11
+ print_version
12
+ puts "Usage:"
13
+ puts "gamebox [opts] game_name"
14
+ puts " -h, --help display this message"
15
+ puts " -v, --version display gamebox version"
16
+ end
17
+
18
+ if %w(--version -v).include? ARGV.first
19
+ print_version
20
+ exit(0)
21
+ end
22
+ if %w(--help -h).include? ARGV.first
23
+ print_usage
24
+ exit(0)
25
+ end
26
+ if ARGV.empty?
27
+ print_usage
8
28
  exit(0)
9
29
  end
10
30
 
11
31
  begin
32
+ # ruby 1.9
12
33
  require 'ftools'
13
34
  fklass = File
14
35
  rescue LoadError
36
+ # ruby 1.8
15
37
  require 'fileutils'
16
38
  fklass = FileUtils
17
39
  end
18
40
 
19
41
  PROJECT_NAME = ARGV[0]
20
42
  TARGET_DIR = File.expand_path(Dir.pwd + "/" + PROJECT_NAME)
21
- SOURCE_DIR = File.expand_path(File.dirname(__FILE__) + "/../lib/gamebox")
43
+ SOURCE_DIR = File.expand_path(File.dirname(__FILE__) + "/../lib/gamebox/templates")
22
44
 
23
45
  Dir.mkdir(TARGET_DIR)
24
46
 
@@ -43,7 +65,9 @@ Dir.glob("**/*").each do |file|
43
65
  target_dir = TARGET_DIR + "/" + file
44
66
  Dir.mkdir(target_dir) unless File.exists? target_dir
45
67
  else
46
- fklass.copy(file, TARGET_DIR + "/" + file)
68
+ new_file = TARGET_DIR + "/" + file
69
+ fklass.install file, new_file
70
+ fklass.chmod 0755, new_file if file =~ /script/
47
71
  end
48
72
  end
49
73
 
data/lib/gamebox.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  $: << File.dirname(__FILE__)+"/gamebox"
2
2
 
3
- # TODO or I could include all my files here... ug
4
3
  GAMEBOX_PATH = File.join(File.dirname(__FILE__),"gamebox/")
5
4
  require 'gamebox_application'
6
5
 
@@ -31,7 +31,7 @@ class GameboxApp
31
31
  @game = @context[:game]
32
32
 
33
33
  @config_manager = @context[:config_manager]
34
- setup_debug_server if @config_manager[:debug_server]
34
+ setup_debug_server if @config_manager[:debug_server] || ARGV.include?("-debug-server")
35
35
  end
36
36
 
37
37
  def setup_debug_server
@@ -0,0 +1,24 @@
1
+ # This is the generator for gamebox
2
+ require 'inflector'
3
+ $: << File.join(File.dirname(__FILE__),'generators')
4
+
5
+ def print_usage
6
+ puts "generate what *opts"
7
+ puts "TODO list all generators here"
8
+ end
9
+ # TODO pull these out into generators/ dir for listing
10
+
11
+ if ARGV.size < 1
12
+ print_usage
13
+ exit 0
14
+ end
15
+
16
+ # TODO load generator file based on ARGV[0]
17
+ generator_klass_name =
18
+ Inflector.camelize ARGV[0].downcase+"_generator"
19
+
20
+ require Inflector.underscore(generator_klass_name)
21
+
22
+ generator_klass = Object.const_get generator_klass_name
23
+ generator_klass.new.generate(ARGV[1..-1])
24
+
@@ -0,0 +1,43 @@
1
+
2
+ class ActorGenerator
3
+ require 'erb'
4
+ def generate(*args)
5
+
6
+ @actor_name = ARGV[1]
7
+ @behaviors = ARGV[2]
8
+ @bind = binding
9
+
10
+ build_actor
11
+ build_test_actor
12
+
13
+ # load test_actor and replace
14
+ end
15
+
16
+ def build_actor
17
+ template_file = File.open(File.join(GAMEBOX_PATH,'templates','actor.erb'))
18
+ template_contents = template_file.readlines.join
19
+ actor_template = ERB.new(template_contents)
20
+
21
+ result = actor_template.result @bind
22
+
23
+ out_file = File.join(APP_ROOT,'src',Inflector.underscore(@actor_name)+".rb")
24
+ raise "File exists [#{out_file}]" if File.exists? out_file
25
+ File.open(out_file,"w+") do |f|
26
+ f.write result
27
+ end
28
+ end
29
+
30
+ def build_test_actor
31
+ template_file = File.open(File.join(GAMEBOX_PATH,'templates','test_actor.erb'))
32
+ template_contents = template_file.readlines.join
33
+ actor_template = ERB.new(template_contents)
34
+
35
+ result = actor_template.result @bind
36
+
37
+ out_file = File.join(APP_ROOT,'test','test_'+Inflector.underscore(@actor_name)+".rb")
38
+ raise "File exists [#{out_file}]" if File.exists? out_file
39
+ File.open(out_file,"w+") do |f|
40
+ f.write result
41
+ end
42
+ end
43
+ end
@@ -117,8 +117,24 @@ class InputManager
117
117
  end
118
118
  alias unreg unregister_hook
119
119
 
120
- def clear_hooks
121
- @hooks = {}
122
- @non_id_hooks = {}
120
+ def clear_hooks(listener=nil)
121
+ if listener
122
+ for event_klass, id_listeners in @hooks
123
+ for key in id_listeners.keys.dup
124
+ id_listeners[key].delete_if do |block|
125
+ eval('self',block.binding).equal?(listener)
126
+ end
127
+ end
128
+ end
129
+
130
+ for key in @non_id_hooks.keys.dup
131
+ @non_id_hooks[key].delete_if do |block|
132
+ eval('self',block.binding).equal?(listener)
133
+ end
134
+ end
135
+ else
136
+ @hooks = {}
137
+ @non_id_hooks = {}
138
+ end
123
139
  end
124
140
  end
data/lib/gamebox/level.rb CHANGED
@@ -8,14 +8,15 @@ class Level
8
8
 
9
9
  can_fire_anything
10
10
  attr_accessor :director, :resource_manager, :sound_manager,
11
- :opts, :viewport
11
+ :opts, :viewport, :input_manager
12
12
 
13
- def initialize(actor_factory, resource_manager, sound_manager, viewport, opts={})
13
+ def initialize(actor_factory, resource_manager, sound_manager, input_manager, viewport, opts={})
14
14
  @director = Director.new
15
15
  @actor_factory = actor_factory
16
16
  @actor_factory.director = @director
17
17
 
18
18
  @sound_manager = sound_manager
19
+ @input_manager = input_manager
19
20
  @resource_manager = resource_manager
20
21
  @viewport = viewport
21
22
  @opts = opts
data/lib/gamebox/mode.rb CHANGED
@@ -62,7 +62,7 @@ class Mode
62
62
  level_klass = ObjectSpace.const_get(Inflector.camelize(level_sym.to_s+"_level"))
63
63
  full_level_def = { :prev_level => prev_level_instance }
64
64
  full_level_def.merge! level_def[level_sym] if level_def[level_sym].is_a? Hash
65
- level = level_klass.new @actor_factory, @resource_manager, @sound_manager, @viewport, full_level_def
65
+ level = level_klass.new @actor_factory, @resource_manager, @sound_manager, @input_manager, @viewport, full_level_def
66
66
  level.when :restart_level do
67
67
  restart_level
68
68
  end
@@ -8,13 +8,14 @@ class PhysicalLevel < Level
8
8
 
9
9
  attr_accessor :space
10
10
 
11
- def initialize(actor_factory, resource_manager, sound_manager, viewport, opts={})
11
+ def initialize(actor_factory, resource_manager, sound_manager, input_manager, viewport, opts={})
12
12
  @actor_factory = actor_factory
13
13
  @director = PhysicalDirector.new
14
14
  @actor_factory.director = @director
15
15
 
16
16
  @resource_manager = resource_manager
17
17
  @sound_manager = sound_manager
18
+ @input_manager = input_manager
18
19
  @viewport = viewport
19
20
  @opts = opts
20
21
 
@@ -0,0 +1,14 @@
1
+ # Helper functions for determining platform
2
+ class Platform
3
+ def self.mac?
4
+ return RUBY_PLATFORM =~ /darwin/
5
+ end
6
+
7
+ def self.windows?
8
+ return RUBY_PLATFORM =~ /mswin/
9
+ end
10
+
11
+ def self.linux?
12
+ return RUBY_PLATFORM =~ /linux/
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ require 'gamebox/platform'
2
+
3
+ task :default => :run
4
+ desc "Run the game"
5
+ task :run do |t|
6
+ if Platform.mac?
7
+ sh "rsdl src/app.rb"
8
+ else
9
+ sh "ruby src/app.rb"
10
+ end
11
+ end
12
+ desc "Run the game with debug server"
13
+ task :debug do |t|
14
+ if Platform.mac?
15
+ sh "rsdl src/app.rb -debug-server"
16
+ else
17
+ sh "ruby src/app.rb -debug-server"
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ require 'actor'
2
+
3
+ class <%= @actor_name %> < Actor
4
+ <% if @behaviors %>
5
+ has_baviors <%= @behaviors.join "," %>
6
+ <% end %>
7
+
8
+ def setup
9
+ # register for events here
10
+ # or pull stuff out of @opts
11
+ end
12
+ end
@@ -4,6 +4,7 @@ confdir = File.dirname(__FILE__)+"/config"
4
4
  $: << confdir
5
5
 
6
6
  require 'environment'
7
+ require 'gamebox/tasks/gamebox_tasks'
7
8
  STATS_DIRECTORIES = [
8
9
  %w(Source src/),
9
10
  %w(Config config/),
@@ -18,3 +19,10 @@ task :stats do
18
19
  CodeStatistics.new(*STATS_DIRECTORIES).to_s
19
20
  end
20
21
 
22
+ require 'spec/rake/spectask'
23
+ desc "Run all specs"
24
+ Spec::Rake::SpecTask.new('specs') do |t|
25
+ t.spec_opts = ["-r", "./test/helper"]
26
+ t.spec_files = FileList['test//test_*.rb']
27
+ end
28
+ task :test => :specs
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ app_root = File.join(File.dirname(__FILE__),'..')
6
+ $: << app_root
7
+ require 'config/environment'
8
+ require 'gamebox_generator'
@@ -7,7 +7,7 @@ class DemoLevel < Level
7
7
  @my_actor.y = 10
8
8
 
9
9
  @stars = []
10
- 20.times { @stars << Ftor.new(rand(@width),rand(@height)) }
10
+ 20.times { @stars << Ftor.new(rand(viewport.width),rand(viewport.height)) }
11
11
  end
12
12
 
13
13
  def draw(target, x_off, y_off)
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'config'))
2
+ require 'spec'
3
+ require 'environment'
4
+ require 'metaclass'
@@ -0,0 +1,11 @@
1
+ require 'helper'
2
+ require '<%= Inflector.underscore @actor_name %>'
3
+
4
+ describe 'a new <%= @actor_name %>' do
5
+ before do
6
+ opts = {:level=>"level", :input=>"input", :resources=>"resource"}
7
+ @test_me = <%= @actor_name %>.new opts
8
+ end
9
+
10
+ it 'should do something'
11
+ end
@@ -2,7 +2,7 @@ module Gamebox
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 6
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/test/helper.rb CHANGED
@@ -1,23 +1,24 @@
1
1
  $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'gamebox'))
2
2
 
3
3
  require 'rubygems'
4
+ require 'spec'
4
5
 
5
- require 'bacon'
6
- require 'mocha'
7
- require 'aliasing'
6
+ #require 'bacon'
7
+ #require 'mocha'
8
+ #require 'aliasing'
8
9
 
9
- class Bacon::Context
10
- include Mocha::Standalone
11
- def it_with_mocha description
12
- it_without_mocha description do
13
- mocha_setup
14
- yield
15
- mocha_verify
16
- mocha_teardown
17
- end
18
- end
19
- alias_method_chain :it, :mocha
20
- end
10
+ #class Bacon::Context
11
+ # include Mocha::Standalone
12
+ # def it_with_mocha description
13
+ # it_without_mocha description do
14
+ # mocha_setup
15
+ # yield
16
+ # mocha_verify
17
+ # mocha_teardown
18
+ # end
19
+ # end
20
+ # alias_method_chain :it, :mocha
21
+ #end
21
22
 
22
23
 
23
24
  require 'metaclass'
data/test/test_actor.rb CHANGED
@@ -8,31 +8,29 @@ describe 'A new actor' do
8
8
  end
9
9
 
10
10
  it 'should be alive' do
11
- @actor.alive?.should.equal true
11
+ @actor.alive?.should be_true
12
12
  end
13
13
 
14
14
  it 'should be at (0,0)' do
15
- @actor.x.should.equal 0
16
- @actor.y.should.equal 0
15
+ @actor.x.should equal(0)
16
+ @actor.y.should equal(0)
17
17
  end
18
18
 
19
19
  it 'should have atts set' do
20
- @actor.level.should.equal "level"
21
- @actor.input_manager.should.equal "input"
22
- @actor.resource_manager.should.equal "resource"
23
- @actor.behaviors.size.should.equal 0
20
+ @actor.level.should == "level"
21
+ @actor.input_manager.should == "input"
22
+ @actor.resource_manager.should == "resource"
23
+ @actor.behaviors.size.should equal(0)
24
24
  end
25
25
 
26
26
  it 'should fire anything' do
27
- should.not.raise do
27
+ Proc.new {
28
28
  @actor.when :foofoo_bar do
29
29
  "blah"
30
30
  end
31
- end
31
+ }.should_not raise_error
32
32
  end
33
33
 
34
- it 'should setup behaviors' do
35
- should.flunk 'cannot test easily!'
36
- end
34
+ it 'should setup behaviors; hard to test'
37
35
 
38
36
  end
@@ -12,11 +12,11 @@ describe 'A new animated behavior' do
12
12
  end
13
13
 
14
14
  it 'should define methods on actor' do
15
- @actor.should.respond_to? :image
16
- @actor.should.respond_to? :start_animating
17
- @actor.should.respond_to? :stop_animating
18
- @actor.should.respond_to? :action=
19
- @actor.should.respond_to? :animated
15
+ @actor.respond_to?(:image).should be(true)
16
+ @actor.respond_to?(:start_animating).should be(true)
17
+ @actor.respond_to?(:stop_animating).should be(true)
18
+ @actor.respond_to?(:action=).should be(true)
19
+ @actor.respond_to?(:animated).should be(true)
20
20
  end
21
21
 
22
22
  it 'shouldn\'t update frame for non-animating' do
@@ -24,41 +24,39 @@ describe 'A new animated behavior' do
24
24
 
25
25
  @animated.update Animated::FRAME_UPDATE_TIME+1
26
26
 
27
- @animated.frame_time.should.equal 0
28
- @animated.frame_num.should.equal 0
27
+ @animated.frame_time.should equal(0)
28
+ @animated.frame_num.should equal(0)
29
29
  end
30
30
 
31
31
  it 'should update frame for animating' do
32
32
  time_passed = Animated::FRAME_UPDATE_TIME-1
33
33
  @animated.update time_passed
34
- @animated.frame_time.should.equal time_passed
35
- @animated.frame_num.should.equal 0
34
+ @animated.frame_time.should equal(time_passed)
35
+ @animated.frame_num.should equal(0)
36
36
 
37
37
  time_passed_again = 2
38
38
  @animated.update time_passed_again
39
39
  # we rolled over the time
40
- @animated.frame_time.should.equal 1
41
- @animated.frame_num.should.equal 1
40
+ @animated.frame_time.should equal(1)
41
+ @animated.frame_num.should equal(1)
42
42
 
43
43
  time_passed_again = Animated::FRAME_UPDATE_TIME
44
44
  @animated.update time_passed_again
45
45
  # we rolled over the time
46
- @animated.frame_time.should.equal 1
47
- @animated.frame_num.should.equal 0
46
+ @animated.frame_time.should equal(1)
47
+ @animated.frame_num.should equal(0)
48
48
  end
49
49
 
50
50
  it 'should stop animating' do
51
51
  @animated.stop_animating
52
- @animated.animating.should.equal false
52
+ @animated.animating.should equal(false)
53
53
  end
54
54
 
55
55
  it 'should start animating' do
56
56
  @animated.start_animating
57
- @animated.animating.should.equal true
57
+ @animated.animating.should equal(true)
58
58
  end
59
59
 
60
- it 'should set the action and animate accordingly' do
61
- should.flunk 'finish me'
62
- end
60
+ it 'should set the action and animate accordingly'
63
61
 
64
62
  end
@@ -8,7 +8,5 @@ describe 'A new LineOfSite' do
8
8
  @los = LineOfSite.new @map
9
9
  end
10
10
 
11
- it 'should be sane' do
12
- true.should == true
13
- end
11
+ it 'should be sane'
14
12
  end
@@ -20,7 +20,7 @@ describe 'A new physical behavior' do
20
20
 
21
21
  it 'should add methods to its actor' do
22
22
  @actor.should.respond_to? :x
23
- should.flunk 'testing this feels dirty...'
23
+ pending 'testing this feels dirty...'
24
24
  end
25
25
 
26
26
  end
data/test/test_polaris.rb CHANGED
@@ -11,19 +11,19 @@ describe 'A new polaris' do
11
11
  it 'should return an empty path if destination is not valid' do
12
12
  from = TwoDGridLocation.new @map.w-1, @map.h-1
13
13
  to = TwoDGridLocation.new @map.w, @map.h
14
- @pather.guide(from,to).should == nil
14
+ @pather.guide(from,to).should be_nil
15
15
 
16
16
  to = TwoDGridLocation.new(-1, -1)
17
- @pather.guide(from,to).should == nil
17
+ @pather.guide(from,to).should be_nil
18
18
  end
19
19
 
20
20
  it 'should return an empty path if start is not valid' do
21
21
  from = TwoDGridLocation.new @map.w, @map.h
22
22
  to = TwoDGridLocation.new @map.w-1, @map.h-1
23
- @pather.guide(from,to).should == nil
23
+ @pather.guide(from,to).should be_nil
24
24
 
25
25
  from = TwoDGridLocation.new -1, -1
26
- @pather.guide(from,to).should == nil
26
+ @pather.guide(from,to).should be_nil
27
27
  end
28
28
 
29
29
  it 'should return the path of "to" for accessible neighbor' do
@@ -31,13 +31,13 @@ describe 'A new polaris' do
31
31
  to = TwoDGridLocation.new 1, 0
32
32
 
33
33
  path = @pather.guide(from,to)
34
- path.should != nil
35
- path.size.should == 1
34
+ path.should_not be_nil
35
+ path.size.should equal(1)
36
36
 
37
- path.first.cost_to.should == TwoDGridMap::TRAVEL_COST_STRAIGHT
38
- path.first.dist_from.should == 0
39
- path.first.location.x.should == to.x
40
- path.first.location.y.should == to.y
37
+ path.first.cost_to.should equal(TwoDGridMap::TRAVEL_COST_STRAIGHT)
38
+ path.first.dist_from.should equal(0)
39
+ path.first.location.x.should equal(to.x)
40
+ path.first.location.y.should equal(to.y)
41
41
  end
42
42
 
43
43
  it 'should return the right horizontal path of length 2' do
@@ -46,11 +46,11 @@ describe 'A new polaris' do
46
46
 
47
47
  path = @pather.guide(from,to)
48
48
 
49
- path.should != nil
50
- path.size.should == 2
49
+ path.should_not be_nil
50
+ path.size.should equal(2)
51
51
 
52
- path.first.location.x.should == 1
53
- path.first.location.y.should == 0
52
+ path.first.location.x.should equal(1)
53
+ path.first.location.y.should equal(0)
54
54
  path.last.location.should == to
55
55
  end
56
56
 
@@ -60,11 +60,11 @@ describe 'A new polaris' do
60
60
 
61
61
  path = @pather.guide(from,to)
62
62
 
63
- path.should != nil
64
- path.size.should == 2
63
+ path.should_not be_nil
64
+ path.size.should equal(2)
65
65
 
66
- path.first.location.x.should == 1
67
- path.first.location.y.should == 0
66
+ path.first.location.x.should equal(1)
67
+ path.first.location.y.should equal(0)
68
68
  path.last.location.should == to
69
69
  end
70
70
 
@@ -75,11 +75,11 @@ describe 'A new polaris' do
75
75
 
76
76
  path = @pather.guide(from,to)
77
77
 
78
- path.should != nil
79
- path.size.should == 2
78
+ path.should_not be_nil
79
+ path.size.should equal(2)
80
80
 
81
- path.first.location.x.should == 1
82
- path.first.location.y.should == 1
81
+ path.first.location.x.should equal(1)
82
+ path.first.location.y.should equal(1)
83
83
  path.last.location.should == to
84
84
  end
85
85
 
@@ -89,11 +89,11 @@ describe 'A new polaris' do
89
89
 
90
90
  path = @pather.guide(from,to)
91
91
 
92
- path.should != nil
93
- path.size.should == 2
92
+ path.should_not be_nil
93
+ path.size.should equal(2)
94
94
 
95
- path.first.location.x.should == 3
96
- path.first.location.y.should == 1
95
+ path.first.location.x.should equal(3)
96
+ path.first.location.y.should equal(1)
97
97
  path.last.location.should == to
98
98
  end
99
99
 
@@ -103,11 +103,11 @@ describe 'A new polaris' do
103
103
 
104
104
  path = @pather.guide(from,to)
105
105
 
106
- path.should != nil
107
- path.size.should == 2
106
+ path.should_not be_nil
107
+ path.size.should equal(2)
108
108
 
109
- path.first.location.x.should == 3
110
- path.first.location.y.should == 3
109
+ path.first.location.x.should equal(3)
110
+ path.first.location.y.should equal(3)
111
111
  path.last.location.should == to
112
112
  end
113
113
 
@@ -117,11 +117,11 @@ describe 'A new polaris' do
117
117
 
118
118
  path = @pather.guide(from,to)
119
119
 
120
- path.should != nil
121
- path.size.should == 2
120
+ path.should_not be_nil
121
+ path.size.should equal(2)
122
122
 
123
- path.first.location.x.should == 1
124
- path.first.location.y.should == 3
123
+ path.first.location.x.should equal(1)
124
+ path.first.location.y.should equal(3)
125
125
  path.last.location.should == to
126
126
  end
127
127
 
@@ -134,11 +134,11 @@ describe 'A new polaris' do
134
134
 
135
135
  path = @pather.guide(from,to)
136
136
 
137
- path.should != nil
138
- path.size.should == 2
137
+ path.should_not be_nil
138
+ path.size.should equal(2)
139
139
 
140
- path.first.location.x.should == 1
141
- path.first.location.y.should == 1
140
+ path.first.location.x.should equal(1)
141
+ path.first.location.y.should equal(1)
142
142
  path.last.location.should == to
143
143
  end
144
144
 
@@ -148,13 +148,13 @@ describe 'A new polaris' do
148
148
 
149
149
  path = @pather.guide(from,to)
150
150
 
151
- path.should != nil
152
- path.size.should == 5
151
+ path.should_not be_nil
152
+ path.size.should equal(5)
153
153
 
154
154
  # make sure that all elements of the path are neighbors
155
155
  prev_el = PathElement.new from, nil
156
156
  path.each do |path_el|
157
- @map.neighbors(prev_el.location).should.include? path_el.location
157
+ @map.neighbors(prev_el.location).include?(path_el.location).should be_true
158
158
  prev_el = path_el
159
159
  end
160
160
 
@@ -15,44 +15,44 @@ describe 'A new viewport' do
15
15
  end
16
16
 
17
17
  it 'should construct with width and height' do
18
- @viewport.width.should == 800
19
- @viewport.height.should == 600
20
- @viewport.x_offset.should == 0
21
- @viewport.y_offset.should == 0
18
+ @viewport.width.should equal(800)
19
+ @viewport.height.should equal(600)
20
+ @viewport.x_offset.should equal(0)
21
+ @viewport.y_offset.should equal(0)
22
22
  end
23
23
 
24
24
  it 'should center the viewport on an actor when follow' do
25
25
  actor = Vec.new 900, 200
26
26
  @viewport.follow actor
27
27
 
28
- @viewport.x_offset.should == -500
29
- @viewport.y_offset.should == 100
30
- @viewport.follow_target.should == actor
28
+ @viewport.x_offset.should equal(-500)
29
+ @viewport.y_offset.should equal(100)
30
+ @viewport.follow_target.should equal(actor)
31
31
  end
32
32
 
33
33
  it 'should center the viewport on an actor (plus offset) when follow' do
34
34
  actor = Vec.new 900, 200
35
35
  @viewport.follow actor, [40,-20]
36
36
 
37
- @viewport.x_offset.should == -460
38
- @viewport.y_offset.should == 80
39
- @viewport.follow_target.should == actor
37
+ @viewport.x_offset.should equal(-460)
38
+ @viewport.y_offset.should equal(80)
39
+ @viewport.follow_target.should equal(actor)
40
40
  end
41
41
 
42
42
  it 'should respect parallax scrolling layers for offsets' do
43
43
  @viewport.x_offset = -200
44
44
  @viewport.y_offset = -300
45
45
 
46
- @viewport.x_offset(2).should == -100
47
- @viewport.y_offset(2).should == -150
46
+ @viewport.x_offset(2).should equal(-100)
47
+ @viewport.y_offset(2).should equal(-150)
48
48
  end
49
49
 
50
50
  it 'should return a zero offset on Infinity' do
51
51
  @viewport.x_offset = -200
52
52
  @viewport.y_offset = -300
53
53
 
54
- @viewport.x_offset(Float::Infinity).should == 0
55
- @viewport.y_offset(Float::Infinity).should == 0
54
+ @viewport.x_offset(Float::Infinity).should equal(0)
55
+ @viewport.y_offset(Float::Infinity).should equal(0)
56
56
  end
57
57
 
58
58
  it 'shouldn\'t update anything unless following a target' do
@@ -61,8 +61,8 @@ describe 'A new viewport' do
61
61
 
62
62
  @viewport.update 3000
63
63
 
64
- @viewport.x_offset.should == -200
65
- @viewport.y_offset.should == -300
64
+ @viewport.x_offset.should equal(-200)
65
+ @viewport.y_offset.should equal(-300)
66
66
  end
67
67
 
68
68
  it 'should follow a target if target has gone right;down of its buffer' do
@@ -74,15 +74,15 @@ describe 'A new viewport' do
74
74
  actor.y = 390
75
75
 
76
76
  @viewport.update 100
77
- @viewport.x_offset.should == -500
78
- @viewport.y_offset.should == 100
77
+ @viewport.x_offset.should equal(-500)
78
+ @viewport.y_offset.should equal(100)
79
79
 
80
80
  actor.x = 1001
81
81
  actor.y = 401
82
82
  @viewport.update 100
83
83
 
84
- @viewport.x_offset.should == -501
85
- @viewport.y_offset.should == 99
84
+ @viewport.x_offset.should equal(-501)
85
+ @viewport.y_offset.should equal(99)
86
86
  end
87
87
 
88
88
  it 'should follow a target if target has gone left;up of its buffer' do
@@ -94,23 +94,19 @@ describe 'A new viewport' do
94
94
  actor.y = 10
95
95
 
96
96
  @viewport.update 100
97
- @viewport.x_offset.should == -500
98
- @viewport.y_offset.should == 100
97
+ @viewport.x_offset.should equal(-500)
98
+ @viewport.y_offset.should equal(100)
99
99
 
100
100
  actor.x = 799
101
101
  actor.y = -1
102
102
  @viewport.update 100
103
103
 
104
- @viewport.x_offset.should == -499
105
- @viewport.y_offset.should == 101
104
+ @viewport.x_offset.should equal(-499)
105
+ @viewport.y_offset.should equal(101)
106
106
  end
107
107
 
108
- it 'should fire :scrolled event when targeting an actor' do
109
- fail 'finish'
110
- end
108
+ it 'should fire :scrolled event when targeting an actor'
111
109
 
112
- it 'should fire :scrolled event from update when the actor moves' do
113
- fail 'finish'
114
- end
110
+ it 'should fire :scrolled event from update when the actor moves'
115
111
 
116
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Anderson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-28 00:00:00 -07:00
12
+ date: 2009-07-04 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: "0"
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
- name: bacon
36
+ name: rspec
37
37
  type: :runtime
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -95,6 +95,8 @@ files:
95
95
  - lib/gamebox/data/sounds/GAMEBOX_SOUND_FX_GO_HERE
96
96
  - lib/gamebox/director.rb
97
97
  - lib/gamebox/gamebox_application.rb
98
+ - lib/gamebox/gamebox_generator.rb
99
+ - lib/gamebox/generators/actor_generator.rb
98
100
  - lib/gamebox/graphical.rb
99
101
  - lib/gamebox/graphical_actor_view.rb
100
102
  - lib/gamebox/inflections.rb
@@ -112,6 +114,7 @@ files:
112
114
  - lib/gamebox/physical_director.rb
113
115
  - lib/gamebox/physical_level.rb
114
116
  - lib/gamebox/physics.rb
117
+ - lib/gamebox/platform.rb
115
118
  - lib/gamebox/publisher_ext.rb
116
119
  - lib/gamebox/resource_manager.rb
117
120
  - lib/gamebox/score.rb
@@ -120,25 +123,30 @@ files:
120
123
  - lib/gamebox/surface_ext.rb
121
124
  - lib/gamebox/svg_actor.rb
122
125
  - lib/gamebox/svg_document.rb
123
- - lib/gamebox/template_app/README
124
- - lib/gamebox/template_app/Rakefile
125
- - lib/gamebox/template_app/config/boot.rb
126
- - lib/gamebox/template_app/config/environment.rb
127
- - lib/gamebox/template_app/config/game.yml
128
- - lib/gamebox/template_app/config/mode_level_config.yml
129
- - lib/gamebox/template_app/config/objects.yml
130
- - lib/gamebox/template_app/data/fonts/FONTS_GO_HERE
131
- - lib/gamebox/template_app/data/graphics/GRAPHICS_GO_HERE
132
- - lib/gamebox/template_app/data/music/MUSIC_GOES_HERE
133
- - lib/gamebox/template_app/data/sounds/SOUND_FX_GO_HERE
134
- - lib/gamebox/template_app/doc/README_FOR_APP
135
- - lib/gamebox/template_app/lib/code_statistics.rb
136
- - lib/gamebox/template_app/lib/diy.rb
137
- - lib/gamebox/template_app/lib/platform.rb
138
- - lib/gamebox/template_app/src/app.rb
139
- - lib/gamebox/template_app/src/demo_level.rb
140
- - lib/gamebox/template_app/src/game.rb
141
- - lib/gamebox/template_app/src/my_actor.rb
126
+ - lib/gamebox/tasks/gamebox_tasks.rb
127
+ - lib/gamebox/templates/actor.erb
128
+ - lib/gamebox/templates/template_app/README
129
+ - lib/gamebox/templates/template_app/Rakefile
130
+ - lib/gamebox/templates/template_app/config/boot.rb
131
+ - lib/gamebox/templates/template_app/config/environment.rb
132
+ - lib/gamebox/templates/template_app/config/game.yml
133
+ - lib/gamebox/templates/template_app/config/mode_level_config.yml
134
+ - lib/gamebox/templates/template_app/config/objects.yml
135
+ - lib/gamebox/templates/template_app/data/fonts/FONTS_GO_HERE
136
+ - lib/gamebox/templates/template_app/data/graphics/GRAPHICS_GO_HERE
137
+ - lib/gamebox/templates/template_app/data/music/MUSIC_GOES_HERE
138
+ - lib/gamebox/templates/template_app/data/sounds/SOUND_FX_GO_HERE
139
+ - lib/gamebox/templates/template_app/doc/README_FOR_APP
140
+ - lib/gamebox/templates/template_app/lib/code_statistics.rb
141
+ - lib/gamebox/templates/template_app/lib/diy.rb
142
+ - lib/gamebox/templates/template_app/lib/platform.rb
143
+ - lib/gamebox/templates/template_app/script/generate
144
+ - lib/gamebox/templates/template_app/src/app.rb
145
+ - lib/gamebox/templates/template_app/src/demo_level.rb
146
+ - lib/gamebox/templates/template_app/src/game.rb
147
+ - lib/gamebox/templates/template_app/src/my_actor.rb
148
+ - lib/gamebox/templates/template_app/test/helper.rb
149
+ - lib/gamebox/templates/test_actor.erb
142
150
  - lib/gamebox/updatable.rb
143
151
  - lib/gamebox/version.rb
144
152
  - lib/gamebox/viewport.rb