onsengame 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.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +7 -0
- data/bin/onsengame +9 -0
- data/data/fonts/PressStart2P.ttf +0 -0
- data/lib/onsengame.rb +5 -0
- data/lib/onsengame/command.rb +41 -0
- data/lib/onsengame/object.rb +1 -0
- data/lib/onsengame/object/base.rb +38 -0
- data/lib/onsengame/scene.rb +3 -0
- data/lib/onsengame/scene/base.rb +24 -0
- data/lib/onsengame/scene/main.rb +31 -0
- data/lib/onsengame/scene/title.rb +54 -0
- data/lib/onsengame/version.rb +3 -0
- data/lib/onsengame/window.rb +43 -0
- data/lib/onsengame/z_order.rb +11 -0
- data/onsengame.gemspec +28 -0
- data/test/run-test.rb +12 -0
- data/test/test-scene.rb +23 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87d971e66ba7517942e0d7e352d384dd12726748
|
4
|
+
data.tar.gz: bd4e1dd1b6932a9bfcfc6f02c4978ea10230261d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01ab779e8fa296ba9f52be6e57e3db58cc9fbb7fccba5f1f47d45abc6b3fcbd053d15d3a7afb64cb4b88ecacc8cb9a15c6f9b17ef8eed154da0e5d3ae50e636e
|
7
|
+
data.tar.gz: 72aa17d6974dab138fb69dafc9e4ea94670ce0e212297370ff291c64b5060a631138098a8aaf059dd0571000c7cb6f949a3de3448986da938ceb9d027eae6772
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Masafumi Yokoyama <myokoym@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Onsengame [](http://badge.fury.io/rb/onsengame)
|
2
|
+
|
3
|
+
A 2D game framework using Gosu with Ruby.
|
4
|
+
|
5
|
+
## Dependencies
|
6
|
+
|
7
|
+
* [Gosu](https://www.libgosu.org/)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
$ gem install onsengame
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
$ onsengame generate PROJECT_NAME
|
16
|
+
$ cd PROJECT_NAME
|
17
|
+
$ bin/PROJECT_NAME
|
18
|
+
|
19
|
+
## License
|
20
|
+
|
21
|
+
MIT License. See LICENSE.txt for details.
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/onsengame
ADDED
Binary file
|
data/lib/onsengame.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "thor"
|
3
|
+
require "onsengame/version"
|
4
|
+
require "onsengame/window"
|
5
|
+
|
6
|
+
module Onsengame
|
7
|
+
class Command < Thor
|
8
|
+
desc "version", "Show version"
|
9
|
+
def version
|
10
|
+
puts(VERSION)
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "demo [OPTIONS]", "Run demo"
|
14
|
+
option :fullscreen, type: :boolean
|
15
|
+
def demo
|
16
|
+
@window = Window.new(options.dup)
|
17
|
+
@window.show
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "generate NAME", "Generate project"
|
21
|
+
def generate(name)
|
22
|
+
raise "Error: File exists." if File.exist?(name)
|
23
|
+
|
24
|
+
onsengame_dir = File.expand_path("../../..", __FILE__)
|
25
|
+
paths = Dir.glob("#{onsengame_dir}/*")
|
26
|
+
paths << File.join(onsengame_dir, ".gitignore")
|
27
|
+
paths.each do |path_from|
|
28
|
+
FileUtils.mkdir_p(name)
|
29
|
+
path_to = File.join(name, File.basename(path_from))
|
30
|
+
FileUtils.cp_r(path_from, path_to)
|
31
|
+
end
|
32
|
+
|
33
|
+
FileUtils.cd(name) do
|
34
|
+
system("git", "init")
|
35
|
+
system("git", "add", ".")
|
36
|
+
system("git", "commit -m 'Initial commit'")
|
37
|
+
system("rename_project", "onsengame", name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "onsengame/object/base"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "gosu"
|
2
|
+
require "onsengame/z_order"
|
3
|
+
|
4
|
+
module Onsengame
|
5
|
+
module Object
|
6
|
+
module Base
|
7
|
+
attr_reader :x, :y
|
8
|
+
def initialize(window, x, y, options={})
|
9
|
+
@window = window
|
10
|
+
@x = x
|
11
|
+
@y = y
|
12
|
+
@color = options[:color] || Gosu::Color::WHITE
|
13
|
+
@z_order = options[:z_order] || ZOrder::OBJECT
|
14
|
+
@font_name = options[:font_name] || "PressStart2P"
|
15
|
+
@font_path = File.join(@window.options[:font_dir],
|
16
|
+
"#{@font_name}.ttf")
|
17
|
+
@font_size = options[:font_size] || 24
|
18
|
+
@font = Gosu::Font.new(@window,
|
19
|
+
@font_path,
|
20
|
+
@font_size)
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
end
|
25
|
+
|
26
|
+
def draw
|
27
|
+
end
|
28
|
+
|
29
|
+
def draw_rectangle(x1, y1, x2, y2, color, z_order)
|
30
|
+
@window.draw_quad(x1, y1, color,
|
31
|
+
x2, y1, color,
|
32
|
+
x2, y2, color,
|
33
|
+
x1, y2, color,
|
34
|
+
z_order)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Onsengame
|
2
|
+
module Scene
|
3
|
+
module Base
|
4
|
+
def initialize(window)
|
5
|
+
@window = window
|
6
|
+
@font_path = File.join(@window.options[:font_dir],
|
7
|
+
"PressStart2P.ttf")
|
8
|
+
@objects = []
|
9
|
+
@figures = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def update
|
13
|
+
@objects.each {|object| object.update }
|
14
|
+
end
|
15
|
+
|
16
|
+
def draw
|
17
|
+
@objects.each {|object| object.draw }
|
18
|
+
end
|
19
|
+
|
20
|
+
def button_down(id)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "gosu"
|
2
|
+
require "onsengame/object"
|
3
|
+
require "onsengame/z_order"
|
4
|
+
require "onsengame/scene/base"
|
5
|
+
|
6
|
+
module Onsengame
|
7
|
+
module Scene
|
8
|
+
class Main
|
9
|
+
include Base
|
10
|
+
|
11
|
+
def initialize(window)
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def draw
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def button_down(id)
|
24
|
+
case id
|
25
|
+
when Gosu::KbQ
|
26
|
+
@window.scenes.shift
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "gosu"
|
2
|
+
require "onsengame/z_order"
|
3
|
+
require "onsengame/scene/base"
|
4
|
+
require "onsengame/scene/main"
|
5
|
+
|
6
|
+
module Onsengame
|
7
|
+
module Scene
|
8
|
+
class Title
|
9
|
+
include Base
|
10
|
+
|
11
|
+
def initialize(window)
|
12
|
+
super
|
13
|
+
@title = Gosu::Image.from_text(@window,
|
14
|
+
@window.caption,
|
15
|
+
@font_path,
|
16
|
+
64,
|
17
|
+
4,
|
18
|
+
@window.width,
|
19
|
+
:center)
|
20
|
+
@guide = Gosu::Image.from_text(@window,
|
21
|
+
"press enter",
|
22
|
+
@font_path,
|
23
|
+
36,
|
24
|
+
4,
|
25
|
+
@window.width,
|
26
|
+
:center)
|
27
|
+
@guide_color = Gosu::Color::WHITE
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
super
|
32
|
+
if Time.now.sec % 2 == 0
|
33
|
+
@guide_color = Gosu::Color::WHITE
|
34
|
+
else
|
35
|
+
@guide_color = Gosu::Color::GRAY
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def draw
|
40
|
+
super
|
41
|
+
@title.draw(0, @window.height * 0.2, ZOrder::TEXT)
|
42
|
+
@guide.draw(0, @window.height * 0.6, ZOrder::TEXT,
|
43
|
+
1, 1, @guide_color)
|
44
|
+
end
|
45
|
+
|
46
|
+
def button_down(id)
|
47
|
+
case id
|
48
|
+
when Gosu::KbReturn
|
49
|
+
@window.scenes.unshift(Main.new(@window))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "gosu"
|
2
|
+
require "gosu/swig_patches"
|
3
|
+
require "gosu/patches"
|
4
|
+
require "onsengame/scene"
|
5
|
+
|
6
|
+
module Onsengame
|
7
|
+
class Window < Gosu::Window
|
8
|
+
attr_reader :options, :scenes
|
9
|
+
def initialize(options={})
|
10
|
+
width = options[:width] || 640
|
11
|
+
height = options[:height] || 480
|
12
|
+
fullscreen = options[:fullscreen] || false
|
13
|
+
super(width, height, fullscreen)
|
14
|
+
self.caption = "Onsengame"
|
15
|
+
@options = options
|
16
|
+
@options[:font_dir] ||= File.expand_path("../../../data/fonts", __FILE__)
|
17
|
+
@scenes = []
|
18
|
+
@scenes << Scene::Title.new(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update
|
22
|
+
current_scene.update
|
23
|
+
end
|
24
|
+
|
25
|
+
def draw
|
26
|
+
current_scene.draw
|
27
|
+
end
|
28
|
+
|
29
|
+
def button_down(id)
|
30
|
+
case id
|
31
|
+
when Gosu::KbEscape
|
32
|
+
close
|
33
|
+
else
|
34
|
+
current_scene.button_down(id)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def current_scene
|
40
|
+
@scenes[0]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/onsengame.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'onsengame/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "onsengame"
|
8
|
+
spec.version = Onsengame::VERSION
|
9
|
+
spec.authors = ["Masafumi Yokoyama"]
|
10
|
+
spec.email = ["myokoym@gmail.com"]
|
11
|
+
spec.description = %q{A 2D game framework using Gosu with Ruby.}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/myokoym/onsengame"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency("gosu")
|
22
|
+
spec.add_runtime_dependency("thor")
|
23
|
+
spec.add_runtime_dependency("inplace")
|
24
|
+
|
25
|
+
spec.add_development_dependency("test-unit")
|
26
|
+
spec.add_development_dependency("bundler")
|
27
|
+
spec.add_development_dependency("rake")
|
28
|
+
end
|
data/test/run-test.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
base_dir = File.expand_path("..", File.dirname(__FILE__))
|
4
|
+
lib_dir = File.join(base_dir, "lib")
|
5
|
+
test_dir = File.join(base_dir, "test")
|
6
|
+
$LOAD_PATH.unshift(lib_dir)
|
7
|
+
$LOAD_PATH.unshift(test_dir)
|
8
|
+
|
9
|
+
require 'test-unit'
|
10
|
+
require 'test/unit/notify'
|
11
|
+
|
12
|
+
exit Test::Unit::AutoRunner.run(true, test_dir)
|
data/test/test-scene.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "onsengame"
|
2
|
+
|
3
|
+
class TestScene < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
options = {
|
6
|
+
width: 1,
|
7
|
+
height: 1,
|
8
|
+
}
|
9
|
+
@window = Onsengame::Window.new(options)
|
10
|
+
end
|
11
|
+
|
12
|
+
class TitleTest < self
|
13
|
+
def test_new
|
14
|
+
assert_not_nil(Onsengame::Scene::Title.new(@window))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class MainTest < self
|
19
|
+
def test_main
|
20
|
+
assert_not_nil(Onsengame::Scene::Main.new(@window))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: onsengame
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masafumi Yokoyama
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gosu
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: inplace
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A 2D game framework using Gosu with Ruby.
|
98
|
+
email:
|
99
|
+
- myokoym@gmail.com
|
100
|
+
executables:
|
101
|
+
- onsengame
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/onsengame
|
111
|
+
- data/fonts/PressStart2P.ttf
|
112
|
+
- lib/onsengame.rb
|
113
|
+
- lib/onsengame/command.rb
|
114
|
+
- lib/onsengame/object.rb
|
115
|
+
- lib/onsengame/object/base.rb
|
116
|
+
- lib/onsengame/scene.rb
|
117
|
+
- lib/onsengame/scene/base.rb
|
118
|
+
- lib/onsengame/scene/main.rb
|
119
|
+
- lib/onsengame/scene/title.rb
|
120
|
+
- lib/onsengame/version.rb
|
121
|
+
- lib/onsengame/window.rb
|
122
|
+
- lib/onsengame/z_order.rb
|
123
|
+
- onsengame.gemspec
|
124
|
+
- test/run-test.rb
|
125
|
+
- test/test-scene.rb
|
126
|
+
homepage: https://github.com/myokoym/onsengame
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.4.5
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: A 2D game framework using Gosu with Ruby.
|
150
|
+
test_files:
|
151
|
+
- test/run-test.rb
|
152
|
+
- test/test-scene.rb
|
153
|
+
has_rdoc:
|