game 0.0.1
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.
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +81 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/examples/super_ruby_bros/Gemfile +39 -0
- data/examples/super_ruby_bros/app/controllers/game_controller.rb +7 -0
- data/examples/super_ruby_bros/app/controllers/main_menu_controller.rb +13 -0
- data/examples/super_ruby_bros/app/entities/logo.rb +12 -0
- data/examples/super_ruby_bros/app/entities/main_menu_list_item.rb +3 -0
- data/examples/super_ruby_bros/app/helpers/game_helpers.rb +3 -0
- data/examples/super_ruby_bros/app/views/main_menu/show.rb +10 -0
- data/examples/super_ruby_bros/app/windows/game_window.rb +16 -0
- data/examples/super_ruby_bros/config/application.rb +49 -0
- data/examples/super_ruby_bros/config/boot.rb +6 -0
- data/examples/super_ruby_bros/config/environment.rb +5 -0
- data/examples/super_ruby_bros/config/locales/en.yml +8 -0
- data/examples/super_ruby_bros/config/routes.rb +3 -0
- data/game.gemspec +44 -0
- data/lib/core_ext/array.rb +13 -0
- data/lib/core_ext/hash.rb +13 -0
- data/lib/game.rb +65 -0
- data/lib/game/application.rb +15 -0
- data/lib/game/controller.rb +17 -0
- data/lib/game/window.rb +87 -0
- metadata +195 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Ryan Scott Lewis <ryan@rynet.us>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Game
|
2
|
+
|
3
|
+
A Ruby-powered MVC game framework.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
```sh
|
8
|
+
$ gem install game
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
### Setup
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ game new my_cool_game
|
17
|
+
```
|
18
|
+
|
19
|
+
This will create a new directory named `my_cool_game` in the current working directory.
|
20
|
+
The directory is laid out very much like a Rails application:
|
21
|
+
|
22
|
+
my_cool_game
|
23
|
+
├── Gemfile
|
24
|
+
├── Guardfile
|
25
|
+
├── README
|
26
|
+
├── app
|
27
|
+
| ├── assets
|
28
|
+
│ │ ├── fonts
|
29
|
+
│ │ ├── images
|
30
|
+
│ │ ├── music
|
31
|
+
│ │ └── sounds
|
32
|
+
| ├── controllers
|
33
|
+
│ │ └── game_controller.rb
|
34
|
+
| ├── helpers
|
35
|
+
│ │ └── game_helpers.rb
|
36
|
+
| ├── models
|
37
|
+
| ├── views
|
38
|
+
| └── windows
|
39
|
+
│ │ └── game_window.rb
|
40
|
+
├── config
|
41
|
+
│ ├── environments
|
42
|
+
│ │ ├── development.rb
|
43
|
+
│ │ ├── production.rb
|
44
|
+
│ │ └── test.rb
|
45
|
+
│ ├── initializers
|
46
|
+
│ ├── locales
|
47
|
+
│ │ └── en.yml
|
48
|
+
│ ├── application.rb
|
49
|
+
│ ├── boot.rb
|
50
|
+
│ └── database.yml
|
51
|
+
│ ├── environment.rb
|
52
|
+
│ └── routes.rb
|
53
|
+
├── log
|
54
|
+
├── spec
|
55
|
+
| └── spec_helper.rb
|
56
|
+
└── tmp
|
57
|
+
|
58
|
+
## Acknowledgements
|
59
|
+
|
60
|
+
* [Rails][rails] for making MVC very popular in the [Ruby][ruby] universe
|
61
|
+
* [Gamebox][gamebox] for inspiration.
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
66
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
67
|
+
* Fork the project
|
68
|
+
* Start or switch to a testing/unstable/feature/bugfix branch
|
69
|
+
* Commit and push until you are happy with your contribution
|
70
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
71
|
+
* Please try not to mess with the Rakefile, VERSION or gemspec.
|
72
|
+
|
73
|
+
## Copyright
|
74
|
+
|
75
|
+
Copyright © 2012 Ryan Scott Lewis <ryan@rynet.us>.
|
76
|
+
|
77
|
+
The MIT License (MIT) - See LICENSE for further details.
|
78
|
+
|
79
|
+
[rails]: https://github.com/rails/rails
|
80
|
+
[ruby]: https://github.com/ruby/ruby
|
81
|
+
[gamebox]: https://github.com/shawn42/gamebox
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
def require_task(path)
|
4
|
+
begin
|
5
|
+
require path
|
6
|
+
|
7
|
+
yield
|
8
|
+
rescue LoadError
|
9
|
+
puts '', "Could not load '#{path}'.", 'Try to `rake gem:spec` and `bundle install` and try again.', ''
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
|
15
|
+
# Variables
|
16
|
+
s.name = 'game'
|
17
|
+
s.authors = ['Ryan Scott Lewis']
|
18
|
+
s.email = ['ryan@rynet.us']
|
19
|
+
s.summary = 'Game is a cross-platform and cross-implementation MVC framework for creating video games in Ruby.'
|
20
|
+
|
21
|
+
# Dependencies
|
22
|
+
s.add_dependency 'version', '~> 1.0'
|
23
|
+
s.add_development_dependency 'guard-rspec', '~> 2.1'
|
24
|
+
s.add_development_dependency 'guard-yard', '~> 2.0'
|
25
|
+
s.add_development_dependency 'rb-fsevent', '~> 0.9'
|
26
|
+
s.add_development_dependency 'fuubar', '~> 1.1'
|
27
|
+
s.add_development_dependency 'github-markup', '~> 0.7'
|
28
|
+
|
29
|
+
# Pragmatically set variables
|
30
|
+
s.homepage = "http://github.com/RyanScottLewis/#{s.name}"
|
31
|
+
s.version = Pathname.glob('VERSION*').first.read
|
32
|
+
s.description = Pathname.glob('README*').first.read
|
33
|
+
s.require_paths = ['lib']
|
34
|
+
s.files = `git ls-files`.lines.to_a.collect { |s| s.strip }
|
35
|
+
s.executables = `git ls-files -- bin/*`.lines.to_a.collect { |s| File.basename(s.strip) }
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Generate the gemspec defined in this Rakefile'
|
40
|
+
task :gemspec do
|
41
|
+
Pathname.new("#{spec.name}.gemspec").open('w') { |f| f.write(spec.to_ruby) }
|
42
|
+
end
|
43
|
+
|
44
|
+
require_task 'rake/version_task' do
|
45
|
+
Rake::VersionTask.new do |t|
|
46
|
+
t.with_git_tag = true
|
47
|
+
t.with_gemspec = spec
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
require 'rubygems/package_task'
|
52
|
+
Gem::PackageTask.new(spec) do |t|
|
53
|
+
t.need_zip = false
|
54
|
+
t.need_tar = false
|
55
|
+
end
|
56
|
+
|
57
|
+
task :default => :gemspec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,39 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'game'
|
4
|
+
|
5
|
+
# === Choose a game engine
|
6
|
+
|
7
|
+
gem 'game-gosu'
|
8
|
+
|
9
|
+
# gem 'game-ray'
|
10
|
+
# gem 'game-rubygame'
|
11
|
+
# gem 'game-slick', platforms: :jruby
|
12
|
+
|
13
|
+
# === Choose a physics engine
|
14
|
+
|
15
|
+
gem 'game-chipmunk'
|
16
|
+
|
17
|
+
# platforms :ruby, :mswin do
|
18
|
+
# gem 'game-box2d'
|
19
|
+
# gem 'game-bullet'
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# platforms :jruby do
|
23
|
+
# gem 'game-jbullet'
|
24
|
+
# gem 'game-jbox2d'
|
25
|
+
# end
|
26
|
+
|
27
|
+
group :development do
|
28
|
+
gem 'game-compiler', platforms: [:rbx, :jruby]
|
29
|
+
|
30
|
+
gem 'game-noiti'
|
31
|
+
|
32
|
+
# === Choose a test engine
|
33
|
+
|
34
|
+
gem 'game-rspec'
|
35
|
+
|
36
|
+
# gem 'game-test-unit'
|
37
|
+
# gem 'game-cucumber'
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class MainMenuController < Game::Controller
|
2
|
+
|
3
|
+
def show
|
4
|
+
@logo = Logo.new
|
5
|
+
@main_menu_list_items = [
|
6
|
+
MainMenuListItem.new(text: t('main_menu.show.menu_list_items.new'), action: 'session#new'),
|
7
|
+
MainMenuListItem.new(text: t('main_menu.show.menu_list_items.load'), action: 'load_menu#show'),
|
8
|
+
MainMenuListItem.new(text: t('main_menu.show.menu_list_items.options'), action: 'options_menu#show'),
|
9
|
+
MainMenuListItem.new(text: t('main_menu.show.menu_list_items.quit'), action: 'game#exit')
|
10
|
+
]
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Each view gets drawn every single frame. Have little to no logic in here.
|
2
|
+
# Never EVER call Entity#draw directly. The Entity's renderer will take care of that for us.
|
3
|
+
|
4
|
+
@logo.position x: @window.position.center.x, y: @logo.height + 10
|
5
|
+
# Or - @logo.position = { x: @window.position.center.x, y: @logo.height + 10 }
|
6
|
+
|
7
|
+
@main_menu_list_items.each_with_index do |main_menu_list_item, index|
|
8
|
+
main_menu_list_item.position.center_at x: @window.position.center.x
|
9
|
+
main_menu_list_item.position.y = (index + 1) * @main_menu_list_item.size.height
|
10
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class GameWindow < Game::Window
|
2
|
+
size width: 600, height: 400
|
3
|
+
# Or - dimensions w: 600, h: 400 - Or any combination of those..
|
4
|
+
# Default is Screen.resolution/4
|
5
|
+
|
6
|
+
position Screen.center
|
7
|
+
# Or - pos x: 123, y: 456
|
8
|
+
# Default is this
|
9
|
+
|
10
|
+
fullscreen false
|
11
|
+
# Default is this
|
12
|
+
|
13
|
+
title 'Super Ruby Bros'
|
14
|
+
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
if defined?(Bundler)
|
4
|
+
# If you precompile assets before deploying to production, use this line
|
5
|
+
Bundler.require(*Game.groups(:assets => %w(development test)))
|
6
|
+
# If you want your assets lazily compiled in production, use this line
|
7
|
+
# Bundler.require(:default, :assets, Rails.env)
|
8
|
+
end
|
9
|
+
|
10
|
+
module SuperRubyBros
|
11
|
+
class Application < Game::Application
|
12
|
+
# Settings in config/environments/* take precedence over those specified here.
|
13
|
+
#
|
14
|
+
# Application configuration should go into files in config/initializers
|
15
|
+
# -- all .rb files in that directory are automatically loaded.
|
16
|
+
|
17
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
18
|
+
#
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
22
|
+
#
|
23
|
+
# config.i18n.load_path += Dir[Game.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
24
|
+
# config.i18n.default_locale = :de
|
25
|
+
|
26
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
27
|
+
#
|
28
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
29
|
+
|
30
|
+
# The game engine you would like to use. You can have multiple game engines installed.
|
31
|
+
# When you require the game engine gem, such as `game-gosu`, it will automatically set
|
32
|
+
# this option. You can override it here.
|
33
|
+
# You can use the Symbol registered as the game engine's name or the actual game engine class.
|
34
|
+
# For example, you may use `config.game_engine = :gosu` or `config.game_engine = RubyGame`.
|
35
|
+
#
|
36
|
+
# config.game_engine = :ray
|
37
|
+
|
38
|
+
# The physics engine you would like to use. You can have multiple physics engines installed.
|
39
|
+
# When you require the physics engine gem, such as `game-chipmunk`, it will automatically set
|
40
|
+
# this option. You can override it here.
|
41
|
+
# You can use the Symbol registered as the physics engine's name or the actual physics engine class.
|
42
|
+
# For example, you may use `config.game_engine = :chipmunk` or `config.game_engine = Box2D`.
|
43
|
+
#
|
44
|
+
# config.game_engine = :chipmunk
|
45
|
+
|
46
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
47
|
+
config.encoding = "utf-8"
|
48
|
+
end
|
49
|
+
end
|
data/game.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "game"
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Ryan Scott Lewis"]
|
9
|
+
s.date = "2012-11-22"
|
10
|
+
s.description = "# Game\n\nA Ruby-powered MVC game framework.\n\n## Install\n\n```sh\n$ gem install game\n```\n\n## Usage\n\n### Setup\n\n```sh\n$ game new my_cool_game\n```\n\nThis will create a new directory named `my_cool_game` in the current working directory. \nThe directory is laid out very much like a Rails application:\n\n my_cool_game\n \u{251c}\u{2500}\u{2500} Gemfile\n \u{251c}\u{2500}\u{2500} Guardfile\n \u{251c}\u{2500}\u{2500} README\n \u{251c}\u{2500}\u{2500} app\n | \u{251c}\u{2500}\u{2500} assets\n \u{2502} \u{2502} \u{251c}\u{2500}\u{2500} fonts\n \u{2502} \u{2502} \u{251c}\u{2500}\u{2500} images\n \u{2502} \u{2502} \u{251c}\u{2500}\u{2500} music\n \u{2502} \u{2502} \u{2514}\u{2500}\u{2500} sounds\n | \u{251c}\u{2500}\u{2500} controllers\n \u{2502} \u{2502} \u{2514}\u{2500}\u{2500} game_controller.rb\n | \u{251c}\u{2500}\u{2500} helpers\n \u{2502} \u{2502} \u{2514}\u{2500}\u{2500} game_helpers.rb\n | \u{251c}\u{2500}\u{2500} models\n | \u{251c}\u{2500}\u{2500} views\n | \u{2514}\u{2500}\u{2500} windows\n \u{2502} \u{2502} \u{2514}\u{2500}\u{2500} game_window.rb\n \u{251c}\u{2500}\u{2500} config\n \u{2502} \u{251c}\u{2500}\u{2500} environments\n \u{2502} \u{2502} \u{251c}\u{2500}\u{2500} development.rb\n \u{2502} \u{2502} \u{251c}\u{2500}\u{2500} production.rb\n \u{2502} \u{2502} \u{2514}\u{2500}\u{2500} test.rb\n \u{2502} \u{251c}\u{2500}\u{2500} initializers\n \u{2502} \u{251c}\u{2500}\u{2500} locales\n \u{2502} \u{2502} \u{2514}\u{2500}\u{2500} en.yml\n \u{2502} \u{251c}\u{2500}\u{2500} application.rb\n \u{2502} \u{251c}\u{2500}\u{2500} boot.rb\n \u{2502} \u{2514}\u{2500}\u{2500} database.yml\n \u{2502} \u{251c}\u{2500}\u{2500} environment.rb\n \u{2502} \u{2514}\u{2500}\u{2500} routes.rb\n \u{251c}\u{2500}\u{2500} log\n \u{251c}\u{2500}\u{2500} spec\n | \u{2514}\u{2500}\u{2500} spec_helper.rb\n \u{2514}\u{2500}\u{2500} tmp\n\n## Acknowledgements\n\n* [Rails][rails] for making MVC very popular in the [Ruby][ruby] universe\n* [Gamebox][gamebox] for inspiration.\n\n## Contributing\n\n* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet\n* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it\n* Fork the project\n* Start or switch to a testing/unstable/feature/bugfix branch\n* Commit and push until you are happy with your contribution\n* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.\n* Please try not to mess with the Rakefile, VERSION or gemspec.\n\n## Copyright\n\nCopyright \u{a9} 2012 Ryan Scott Lewis <ryan@rynet.us>.\n\nThe MIT License (MIT) - See LICENSE for further details.\n\n[rails]: https://github.com/rails/rails\n[ruby]: https://github.com/ruby/ruby\n[gamebox]: https://github.com/shawn42/gamebox\n"
|
11
|
+
s.email = ["ryan@rynet.us"]
|
12
|
+
s.files = [".gitignore", "Gemfile", "LICENSE", "README.md", "Rakefile", "VERSION", "examples/super_ruby_bros/Gemfile", "examples/super_ruby_bros/app/controllers/game_controller.rb", "examples/super_ruby_bros/app/controllers/main_menu_controller.rb", "examples/super_ruby_bros/app/entities/logo.rb", "examples/super_ruby_bros/app/entities/main_menu_list_item.rb", "examples/super_ruby_bros/app/helpers/game_helpers.rb", "examples/super_ruby_bros/app/views/main_menu/show.rb", "examples/super_ruby_bros/app/windows/game_window.rb", "examples/super_ruby_bros/config/application.rb", "examples/super_ruby_bros/config/boot.rb", "examples/super_ruby_bros/config/environment.rb", "examples/super_ruby_bros/config/locales/en.yml", "examples/super_ruby_bros/config/routes.rb", "game.gemspec", "lib/core_ext/array.rb", "lib/core_ext/hash.rb", "lib/game.rb", "lib/game/application.rb", "lib/game/controller.rb", "lib/game/window.rb"]
|
13
|
+
s.homepage = "http://github.com/RyanScottLewis/game"
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.rubygems_version = "1.8.24"
|
16
|
+
s.summary = "Game is a cross-platform and cross-implementation MVC framework for creating video games in Ruby."
|
17
|
+
|
18
|
+
if s.respond_to? :specification_version then
|
19
|
+
s.specification_version = 3
|
20
|
+
|
21
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
22
|
+
s.add_runtime_dependency(%q<version>, ["~> 1.0"])
|
23
|
+
s.add_development_dependency(%q<guard-rspec>, ["~> 2.1"])
|
24
|
+
s.add_development_dependency(%q<guard-yard>, ["~> 2.0"])
|
25
|
+
s.add_development_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
26
|
+
s.add_development_dependency(%q<fuubar>, ["~> 1.1"])
|
27
|
+
s.add_development_dependency(%q<github-markup>, ["~> 0.7"])
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<version>, ["~> 1.0"])
|
30
|
+
s.add_dependency(%q<guard-rspec>, ["~> 2.1"])
|
31
|
+
s.add_dependency(%q<guard-yard>, ["~> 2.0"])
|
32
|
+
s.add_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
33
|
+
s.add_dependency(%q<fuubar>, ["~> 1.1"])
|
34
|
+
s.add_dependency(%q<github-markup>, ["~> 0.7"])
|
35
|
+
end
|
36
|
+
else
|
37
|
+
s.add_dependency(%q<version>, ["~> 1.0"])
|
38
|
+
s.add_dependency(%q<guard-rspec>, ["~> 2.1"])
|
39
|
+
s.add_dependency(%q<guard-yard>, ["~> 2.0"])
|
40
|
+
s.add_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
41
|
+
s.add_dependency(%q<fuubar>, ["~> 1.1"])
|
42
|
+
s.add_dependency(%q<github-markup>, ["~> 0.7"])
|
43
|
+
end
|
44
|
+
end
|
data/lib/game.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
module Game
|
3
|
+
|
4
|
+
class Config
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
class Entity
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def physics_engine(physics_engine)
|
13
|
+
unregister_physics_engine
|
14
|
+
register_physics_engine(physics_engine)
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def unregister_physics_engine
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def register_physics_engine(physics_engine)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class PhysicsEngine
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
# # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
|
38
|
+
# # -= game-chipmunk
|
39
|
+
#
|
40
|
+
# # ./lib/game-chipmunk.rb # MANDATORY CONVENTION
|
41
|
+
#
|
42
|
+
# require 'game/physics_engine/chipmunk'
|
43
|
+
#
|
44
|
+
# # ./lib/game/chipmunk.rb # MANDATORY CONVENTION
|
45
|
+
#
|
46
|
+
# require 'game/physics_engine/chipmunk'
|
47
|
+
#
|
48
|
+
# # ./lib/game/physics_engine/chipmunk # ACTUAL PLUGIN
|
49
|
+
#
|
50
|
+
# module Game
|
51
|
+
# class PhysicsEngine
|
52
|
+
#
|
53
|
+
# class Chipmunk < PhysicsEngine
|
54
|
+
# VERSION = '0.1.0'
|
55
|
+
#
|
56
|
+
# on_register do
|
57
|
+
# # in the scope of the Entity class this was registered..
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# Entity.physics_engine(Chipmunk) # Autosetup Chipmunk as the default physics engine
|
63
|
+
#
|
64
|
+
# end
|
65
|
+
# end
|
data/lib/game/window.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
module Game
|
2
|
+
class Window
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def fps
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
def delta
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class Window
|
17
|
+
include MetaTools
|
18
|
+
|
19
|
+
attr_reader :started_at
|
20
|
+
|
21
|
+
# Initialize the game window.
|
22
|
+
#
|
23
|
+
# @abstract Override and call `super` after you've setup the width, height, and title.
|
24
|
+
def initialize(options={})
|
25
|
+
# Complain if @title isn't set?
|
26
|
+
# Complain if @width isn't set?
|
27
|
+
# Complain if height isn't set?
|
28
|
+
init_window
|
29
|
+
@started_at = Time.now
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_writer :title
|
33
|
+
def title(value=nil)
|
34
|
+
@title = value unless value.nil?
|
35
|
+
@title
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_writer :width
|
39
|
+
def width(value=nil)
|
40
|
+
@width = value unless value.nil?
|
41
|
+
@width
|
42
|
+
end
|
43
|
+
|
44
|
+
attr_writer :height
|
45
|
+
def height(value=nil)
|
46
|
+
@height = value unless value.nil?
|
47
|
+
@height
|
48
|
+
end
|
49
|
+
|
50
|
+
attr_writer :fullscreen
|
51
|
+
def fullscreen(value=nil)
|
52
|
+
@fullscreen = value unless value.nil?
|
53
|
+
@fullscreen
|
54
|
+
end
|
55
|
+
|
56
|
+
def entities
|
57
|
+
@entities ||= []
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_entity(entity, *args, &blk)
|
61
|
+
entity_name, entity = entity, args.shift if entity.is_a?(Symbol)
|
62
|
+
entity_name ||= entity.to_s.split('::').last.gsub(/[A-Z]/, '_\0').gsub(/^_/, '').downcase
|
63
|
+
|
64
|
+
meta_def(entity_name) { entity }
|
65
|
+
|
66
|
+
entities << entity_instance = entity.new(@window, *args)
|
67
|
+
|
68
|
+
yield(entity_instance) if block_given?
|
69
|
+
|
70
|
+
entity
|
71
|
+
end
|
72
|
+
|
73
|
+
# Initialize the underlying adapter window.
|
74
|
+
#
|
75
|
+
# @abstract Must be overridden by an adapter.
|
76
|
+
def init_window
|
77
|
+
raise NotImplementedError
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def milliseconds_since_start
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
metadata
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: game
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan Scott Lewis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: version
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: guard-rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.1'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.1'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard-yard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rb-fsevent
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.9'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.9'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: fuubar
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.1'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.1'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: github-markup
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.7'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.7'
|
110
|
+
description: ! "# Game\n\nA Ruby-powered MVC game framework.\n\n## Install\n\n```sh\n$
|
111
|
+
gem install game\n```\n\n## Usage\n\n### Setup\n\n```sh\n$ game new my_cool_game\n```\n\nThis
|
112
|
+
will create a new directory named `my_cool_game` in the current working directory.
|
113
|
+
\ \nThe directory is laid out very much like a Rails application:\n\n my_cool_game\n
|
114
|
+
\ ├── Gemfile\n ├── Guardfile\n ├── README\n ├── app\n | ├── assets\n
|
115
|
+
\ │ │ ├── fonts\n │ │ ├── images\n │ │ ├── music\n │ │
|
116
|
+
\ └── sounds\n | ├── controllers\n │ │ └── game_controller.rb\n |
|
117
|
+
\ ├── helpers\n │ │ └── game_helpers.rb\n | ├── models\n | ├──
|
118
|
+
views\n | └── windows\n │ │ └── game_window.rb\n ├── config\n │
|
119
|
+
\ ├── environments\n │ │ ├── development.rb\n │ │ ├── production.rb\n
|
120
|
+
\ │ │ └── test.rb\n │ ├── initializers\n │ ├── locales\n │ │
|
121
|
+
\ └── en.yml\n │ ├── application.rb\n │ ├── boot.rb\n │ └── database.yml\n
|
122
|
+
\ │ ├── environment.rb\n │ └── routes.rb\n ├── log\n ├── spec\n |
|
123
|
+
\ └── spec_helper.rb\n └── tmp\n\n## Acknowledgements\n\n* [Rails][rails] for
|
124
|
+
making MVC very popular in the [Ruby][ruby] universe\n* [Gamebox][gamebox] for inspiration.\n\n##
|
125
|
+
Contributing\n\n* Check out the latest master to make sure the feature hasn't been
|
126
|
+
implemented or the bug hasn't been fixed yet\n* Check out the issue tracker to make
|
127
|
+
sure someone already hasn't requested it and/or contributed it\n* Fork the project\n*
|
128
|
+
Start or switch to a testing/unstable/feature/bugfix branch\n* Commit and push until
|
129
|
+
you are happy with your contribution\n* Make sure to add tests for it. This is important
|
130
|
+
so I don't break it in a future version unintentionally.\n* Please try not to mess
|
131
|
+
with the Rakefile, VERSION or gemspec.\n\n## Copyright\n\nCopyright © 2012 Ryan
|
132
|
+
Scott Lewis <ryan@rynet.us>.\n\nThe MIT License (MIT) - See LICENSE for further
|
133
|
+
details.\n\n[rails]: https://github.com/rails/rails\n[ruby]: https://github.com/ruby/ruby\n[gamebox]:
|
134
|
+
https://github.com/shawn42/gamebox\n"
|
135
|
+
email:
|
136
|
+
- ryan@rynet.us
|
137
|
+
executables: []
|
138
|
+
extensions: []
|
139
|
+
extra_rdoc_files: []
|
140
|
+
files:
|
141
|
+
- .gitignore
|
142
|
+
- Gemfile
|
143
|
+
- LICENSE
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- VERSION
|
147
|
+
- examples/super_ruby_bros/Gemfile
|
148
|
+
- examples/super_ruby_bros/app/controllers/game_controller.rb
|
149
|
+
- examples/super_ruby_bros/app/controllers/main_menu_controller.rb
|
150
|
+
- examples/super_ruby_bros/app/entities/logo.rb
|
151
|
+
- examples/super_ruby_bros/app/entities/main_menu_list_item.rb
|
152
|
+
- examples/super_ruby_bros/app/helpers/game_helpers.rb
|
153
|
+
- examples/super_ruby_bros/app/views/main_menu/show.rb
|
154
|
+
- examples/super_ruby_bros/app/windows/game_window.rb
|
155
|
+
- examples/super_ruby_bros/config/application.rb
|
156
|
+
- examples/super_ruby_bros/config/boot.rb
|
157
|
+
- examples/super_ruby_bros/config/environment.rb
|
158
|
+
- examples/super_ruby_bros/config/locales/en.yml
|
159
|
+
- examples/super_ruby_bros/config/routes.rb
|
160
|
+
- game.gemspec
|
161
|
+
- lib/core_ext/array.rb
|
162
|
+
- lib/core_ext/hash.rb
|
163
|
+
- lib/game.rb
|
164
|
+
- lib/game/application.rb
|
165
|
+
- lib/game/controller.rb
|
166
|
+
- lib/game/window.rb
|
167
|
+
homepage: http://github.com/RyanScottLewis/game
|
168
|
+
licenses: []
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
none: false
|
175
|
+
requirements:
|
176
|
+
- - ! '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
segments:
|
180
|
+
- 0
|
181
|
+
hash: 836299298492410699
|
182
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
|
+
none: false
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
requirements: []
|
189
|
+
rubyforge_project:
|
190
|
+
rubygems_version: 1.8.24
|
191
|
+
signing_key:
|
192
|
+
specification_version: 3
|
193
|
+
summary: Game is a cross-platform and cross-implementation MVC framework for creating
|
194
|
+
video games in Ruby.
|
195
|
+
test_files: []
|