gamebox 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/History.txt +18 -0
  2. data/Manifest.txt +85 -0
  3. data/README.txt +33 -0
  4. data/Rakefile +42 -0
  5. data/TODO.txt +29 -0
  6. data/bin/gamebox +49 -0
  7. data/docs/gamebox04_big.png +0 -0
  8. data/docs/getting_started.rdoc +99 -0
  9. data/docs/logo.png +0 -0
  10. data/lib/gamebox.rb +6 -0
  11. data/lib/gamebox/actor.rb +143 -0
  12. data/lib/gamebox/actor_factory.rb +64 -0
  13. data/lib/gamebox/actor_view.rb +35 -0
  14. data/lib/gamebox/ai/line_of_site.rb +61 -0
  15. data/lib/gamebox/ai/polaris.rb +107 -0
  16. data/lib/gamebox/ai/two_d_grid_location.rb +21 -0
  17. data/lib/gamebox/ai/two_d_grid_map.rb +77 -0
  18. data/lib/gamebox/aliasing.rb +16 -0
  19. data/lib/gamebox/animated.rb +84 -0
  20. data/lib/gamebox/behavior.rb +16 -0
  21. data/lib/gamebox/config_manager.rb +22 -0
  22. data/lib/gamebox/console_app.rb +39 -0
  23. data/lib/gamebox/data/fonts/Asimov.ttf +0 -0
  24. data/lib/gamebox/data/fonts/GAMEBOX_FONTS_GO_HERE +0 -0
  25. data/lib/gamebox/data/graphics/GAMEBOX_GRAPHICS_GO_HERE +0 -0
  26. data/lib/gamebox/data/graphics/logo.png +0 -0
  27. data/lib/gamebox/data/music/GAMEBOX_MUSIC_GOES_HERE +0 -0
  28. data/lib/gamebox/data/sounds/GAMEBOX_SOUND_FX_GO_HERE +0 -0
  29. data/lib/gamebox/director.rb +47 -0
  30. data/lib/gamebox/gamebox_application.rb +77 -0
  31. data/lib/gamebox/graphical.rb +24 -0
  32. data/lib/gamebox/graphical_actor_view.rb +31 -0
  33. data/lib/gamebox/inflections.rb +52 -0
  34. data/lib/gamebox/inflector.rb +278 -0
  35. data/lib/gamebox/input_manager.rb +104 -0
  36. data/lib/gamebox/layered.rb +34 -0
  37. data/lib/gamebox/level.rb +64 -0
  38. data/lib/gamebox/linked_list.rb +137 -0
  39. data/lib/gamebox/logo.rb +11 -0
  40. data/lib/gamebox/metaclass.rb +6 -0
  41. data/lib/gamebox/mode.rb +123 -0
  42. data/lib/gamebox/mode_manager.rb +80 -0
  43. data/lib/gamebox/numbers_ext.rb +3 -0
  44. data/lib/gamebox/physical.rb +139 -0
  45. data/lib/gamebox/physical_director.rb +17 -0
  46. data/lib/gamebox/physical_level.rb +89 -0
  47. data/lib/gamebox/physics.rb +27 -0
  48. data/lib/gamebox/publisher_ext.rb +13 -0
  49. data/lib/gamebox/resource_manager.rb +122 -0
  50. data/lib/gamebox/score.rb +35 -0
  51. data/lib/gamebox/sorted_list.rb +59 -0
  52. data/lib/gamebox/sound_manager.rb +84 -0
  53. data/lib/gamebox/surface_ext.rb +37 -0
  54. data/lib/gamebox/svg_actor.rb +55 -0
  55. data/lib/gamebox/svg_document.rb +160 -0
  56. data/lib/gamebox/template_app/README +30 -0
  57. data/lib/gamebox/template_app/Rakefile +20 -0
  58. data/lib/gamebox/template_app/config/boot.rb +5 -0
  59. data/lib/gamebox/template_app/config/environment.rb +29 -0
  60. data/lib/gamebox/template_app/config/game.yml +6 -0
  61. data/lib/gamebox/template_app/config/mode_level_config.yml +3 -0
  62. data/lib/gamebox/template_app/config/objects.yml +29 -0
  63. data/lib/gamebox/template_app/data/fonts/FONTS_GO_HERE +0 -0
  64. data/lib/gamebox/template_app/data/graphics/GRAPHICS_GO_HERE +0 -0
  65. data/lib/gamebox/template_app/data/music/MUSIC_GOES_HERE +0 -0
  66. data/lib/gamebox/template_app/data/sounds/SOUND_FX_GO_HERE +0 -0
  67. data/lib/gamebox/template_app/doc/README_FOR_APP +1 -0
  68. data/lib/gamebox/template_app/lib/code_statistics.rb +107 -0
  69. data/lib/gamebox/template_app/lib/diy.rb +371 -0
  70. data/lib/gamebox/template_app/lib/platform.rb +16 -0
  71. data/lib/gamebox/template_app/src/app.rb +8 -0
  72. data/lib/gamebox/template_app/src/demo_level.rb +20 -0
  73. data/lib/gamebox/template_app/src/game.rb +22 -0
  74. data/lib/gamebox/template_app/src/my_actor.rb +17 -0
  75. data/lib/gamebox/version.rb +10 -0
  76. data/lib/gamebox/viewport.rb +81 -0
  77. data/lib/gamebox/wrapped_screen.rb +15 -0
  78. data/script/perf_polaris.rb +36 -0
  79. data/test/helper.rb +25 -0
  80. data/test/test_actor.rb +38 -0
  81. data/test/test_animated.rb +64 -0
  82. data/test/test_line_of_site.rb +14 -0
  83. data/test/test_physical.rb +26 -0
  84. data/test/test_polaris.rb +193 -0
  85. data/test/test_viewport.rb +116 -0
  86. metadata +188 -0
@@ -0,0 +1,116 @@
1
+ require 'helper'
2
+ require 'viewport'
3
+
4
+ class Vec
5
+ attr_accessor :x, :y
6
+ def initialize(x,y)
7
+ @x = x
8
+ @y = y
9
+ end
10
+ end
11
+
12
+ describe 'A new viewport' do
13
+ before do
14
+ @viewport = Viewport.new 800, 600
15
+ end
16
+
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
22
+ end
23
+
24
+ it 'should center the viewport on an actor when follow' do
25
+ actor = Vec.new 900, 200
26
+ @viewport.follow actor
27
+
28
+ @viewport.x_offset.should == -500
29
+ @viewport.y_offset.should == 100
30
+ @viewport.follow_target.should == actor
31
+ end
32
+
33
+ it 'should center the viewport on an actor (plus offset) when follow' do
34
+ actor = Vec.new 900, 200
35
+ @viewport.follow actor, [40,-20]
36
+
37
+ @viewport.x_offset.should == -460
38
+ @viewport.y_offset.should == 80
39
+ @viewport.follow_target.should == actor
40
+ end
41
+
42
+ it 'should respect parallax scrolling layers for offsets' do
43
+ @viewport.x_offset = -200
44
+ @viewport.y_offset = -300
45
+
46
+ @viewport.x_offset(2).should == -100
47
+ @viewport.y_offset(2).should == -150
48
+ end
49
+
50
+ it 'should return a zero offset on Infinity' do
51
+ @viewport.x_offset = -200
52
+ @viewport.y_offset = -300
53
+
54
+ @viewport.x_offset(Float::Infinity).should == 0
55
+ @viewport.y_offset(Float::Infinity).should == 0
56
+ end
57
+
58
+ it 'shouldn\'t update anything unless following a target' do
59
+ @viewport.x_offset = -200
60
+ @viewport.y_offset = -300
61
+
62
+ @viewport.update 3000
63
+
64
+ @viewport.x_offset.should == -200
65
+ @viewport.y_offset.should == -300
66
+ end
67
+
68
+ it 'should follow a target if target has gone right;down of its buffer' do
69
+ actor = Vec.new 900, 200
70
+ @viewport.follow actor, [0,0], [100,200]
71
+
72
+ @viewport.update 100
73
+ actor.x = 990
74
+ actor.y = 390
75
+
76
+ @viewport.update 100
77
+ @viewport.x_offset.should == -500
78
+ @viewport.y_offset.should == 100
79
+
80
+ actor.x = 1001
81
+ actor.y = 401
82
+ @viewport.update 100
83
+
84
+ @viewport.x_offset.should == -501
85
+ @viewport.y_offset.should == 99
86
+ end
87
+
88
+ it 'should follow a target if target has gone left;up of its buffer' do
89
+ actor = Vec.new 900, 200
90
+ @viewport.follow actor, [0,0], [100,200]
91
+
92
+ @viewport.update 100
93
+ actor.x = 810
94
+ actor.y = 10
95
+
96
+ @viewport.update 100
97
+ @viewport.x_offset.should == -500
98
+ @viewport.y_offset.should == 100
99
+
100
+ actor.x = 799
101
+ actor.y = -1
102
+ @viewport.update 100
103
+
104
+ @viewport.x_offset.should == -499
105
+ @viewport.y_offset.should == 101
106
+ end
107
+
108
+ it 'should fire :scrolled event when targeting an actor' do
109
+ fail 'finish'
110
+ end
111
+
112
+ it 'should fire :scrolled event from update when the actor moves' do
113
+ fail 'finish'
114
+ end
115
+
116
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gamebox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shawn Anderson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-19 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: constructor
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: publisher
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: bacon
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: hoe
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.12.2
54
+ version:
55
+ description: Framework for building and distributing games using Rubygame
56
+ email: shawn42@gmail.com
57
+ executables:
58
+ - gamebox
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - History.txt
63
+ - Manifest.txt
64
+ - README.txt
65
+ - TODO.txt
66
+ - docs/getting_started.rdoc
67
+ files:
68
+ - History.txt
69
+ - Manifest.txt
70
+ - README.txt
71
+ - Rakefile
72
+ - TODO.txt
73
+ - bin/gamebox
74
+ - docs/gamebox04_big.png
75
+ - docs/getting_started.rdoc
76
+ - docs/logo.png
77
+ - lib/gamebox.rb
78
+ - lib/gamebox/actor.rb
79
+ - lib/gamebox/actor_factory.rb
80
+ - lib/gamebox/actor_view.rb
81
+ - lib/gamebox/ai/line_of_site.rb
82
+ - lib/gamebox/ai/polaris.rb
83
+ - lib/gamebox/ai/two_d_grid_location.rb
84
+ - lib/gamebox/ai/two_d_grid_map.rb
85
+ - lib/gamebox/aliasing.rb
86
+ - lib/gamebox/animated.rb
87
+ - lib/gamebox/behavior.rb
88
+ - lib/gamebox/config_manager.rb
89
+ - lib/gamebox/console_app.rb
90
+ - lib/gamebox/data/fonts/Asimov.ttf
91
+ - lib/gamebox/data/fonts/GAMEBOX_FONTS_GO_HERE
92
+ - lib/gamebox/data/graphics/GAMEBOX_GRAPHICS_GO_HERE
93
+ - lib/gamebox/data/graphics/logo.png
94
+ - lib/gamebox/data/music/GAMEBOX_MUSIC_GOES_HERE
95
+ - lib/gamebox/data/sounds/GAMEBOX_SOUND_FX_GO_HERE
96
+ - lib/gamebox/director.rb
97
+ - lib/gamebox/gamebox_application.rb
98
+ - lib/gamebox/graphical.rb
99
+ - lib/gamebox/graphical_actor_view.rb
100
+ - lib/gamebox/inflections.rb
101
+ - lib/gamebox/inflector.rb
102
+ - lib/gamebox/input_manager.rb
103
+ - lib/gamebox/layered.rb
104
+ - lib/gamebox/level.rb
105
+ - lib/gamebox/linked_list.rb
106
+ - lib/gamebox/logo.rb
107
+ - lib/gamebox/metaclass.rb
108
+ - lib/gamebox/mode.rb
109
+ - lib/gamebox/mode_manager.rb
110
+ - lib/gamebox/numbers_ext.rb
111
+ - lib/gamebox/physical.rb
112
+ - lib/gamebox/physical_director.rb
113
+ - lib/gamebox/physical_level.rb
114
+ - lib/gamebox/physics.rb
115
+ - lib/gamebox/publisher_ext.rb
116
+ - lib/gamebox/resource_manager.rb
117
+ - lib/gamebox/score.rb
118
+ - lib/gamebox/sorted_list.rb
119
+ - lib/gamebox/sound_manager.rb
120
+ - lib/gamebox/surface_ext.rb
121
+ - lib/gamebox/svg_actor.rb
122
+ - 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
142
+ - lib/gamebox/version.rb
143
+ - lib/gamebox/viewport.rb
144
+ - lib/gamebox/wrapped_screen.rb
145
+ - script/perf_polaris.rb
146
+ - test/helper.rb
147
+ - test/test_actor.rb
148
+ - test/test_animated.rb
149
+ - test/test_line_of_site.rb
150
+ - test/test_physical.rb
151
+ - test/test_polaris.rb
152
+ - test/test_viewport.rb
153
+ has_rdoc: true
154
+ homepage: http://shawn42.github.com/gamebox
155
+ licenses: []
156
+
157
+ post_install_message:
158
+ rdoc_options:
159
+ - --main
160
+ - README.txt
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: "0"
168
+ version:
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: "0"
174
+ version:
175
+ requirements: []
176
+
177
+ rubyforge_project: gamebox
178
+ rubygems_version: 1.3.4
179
+ signing_key:
180
+ specification_version: 3
181
+ summary: Framework for building and distributing games using Rubygame
182
+ test_files:
183
+ - test/test_actor.rb
184
+ - test/test_animated.rb
185
+ - test/test_line_of_site.rb
186
+ - test/test_physical.rb
187
+ - test/test_polaris.rb
188
+ - test/test_viewport.rb