slickr 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.rspec +0 -1
- data/.travis.yml +4 -0
- data/Gemfile +0 -2
- data/README.md +58 -52
- data/Rakefile +4 -0
- data/lib/slickr.rb +18 -1
- data/lib/slickr/actions/generate.rb +51 -0
- data/lib/slickr/behavior.rb +68 -0
- data/lib/slickr/cli.rb +12 -3
- data/lib/slickr/entity.rb +64 -0
- data/lib/slickr/entity_manager.rb +105 -0
- data/lib/slickr/generators/base.rb +95 -0
- data/lib/slickr/generators/behavior.rb +9 -0
- data/lib/slickr/generators/entity.rb +10 -0
- data/{files → lib/slickr/generators/files}/Rakefile +0 -0
- data/{files → lib/slickr/generators/files}/jinput.jar +0 -0
- data/{files → lib/slickr/generators/files}/libjinput-osx.jnilib +0 -0
- data/{files → lib/slickr/generators/files}/liblwjgl.jnilib +0 -0
- data/{files → lib/slickr/generators/files}/lwjgl.jar +0 -0
- data/{files → lib/slickr/generators/files}/openal.dylib +0 -0
- data/{files → lib/slickr/generators/files}/slick.jar +0 -0
- data/lib/slickr/generators/project.rb +36 -0
- data/lib/slickr/generators/reactor.rb +9 -0
- data/lib/slickr/generators/renderer.rb +9 -0
- data/lib/slickr/generators/templates/behavior.erb +3 -0
- data/lib/slickr/generators/templates/behaviors.erb +1 -0
- data/{templates → lib/slickr/generators/templates}/engine.erb +13 -9
- data/lib/slickr/generators/templates/entities.erb +1 -0
- data/lib/slickr/generators/templates/entity.erb +2 -0
- data/lib/slickr/generators/templates/reactor.erb +4 -0
- data/lib/slickr/generators/templates/reactors.erb +1 -0
- data/lib/slickr/generators/templates/renderer.erb +4 -0
- data/lib/slickr/generators/templates/renderers.erb +1 -0
- data/lib/slickr/reactor.rb +86 -0
- data/lib/slickr/renderer.rb +37 -0
- data/lib/slickr/tasks.rb +1 -3
- data/lib/slickr/version.rb +1 -1
- data/slickr.gemspec +0 -2
- data/spec/build/.gitkeep +0 -0
- data/spec/slickr/actions/generate_spec.rb +38 -0
- data/spec/slickr/entity_manager_spec.rb +31 -0
- data/spec/slickr/entity_spec.rb +21 -0
- data/spec/slickr/generators/behavior_spec.rb +17 -0
- data/spec/slickr/generators/entity_spec.rb +21 -0
- data/spec/slickr/generators/project_spec.rb +120 -0
- data/spec/slickr/generators/reactor_spec.rb +17 -0
- data/spec/slickr/generators/renderer_spec.rb +17 -0
- data/spec/slickr/reactor_spec.rb +25 -0
- data/spec/spec_helper.rb +17 -4
- metadata +64 -57
- data/lib/slickr/actions/create.rb +0 -79
- data/spec/slickj/actions/create_spec.rb +0 -174
- data/templates/components.erb +0 -5
- data/templates/entities.erb +0 -5
- data/templates/renderers.erb +0 -5
- data/templates/systems.erb +0 -5
@@ -1,79 +0,0 @@
|
|
1
|
-
module Slickr
|
2
|
-
module Actions
|
3
|
-
class Create
|
4
|
-
def initialize(name)
|
5
|
-
@name = name
|
6
|
-
end
|
7
|
-
|
8
|
-
def start
|
9
|
-
empty_directory "java"
|
10
|
-
empty_directory "assets"
|
11
|
-
empty_directory "lib"
|
12
|
-
empty_directory "lib", "renderers"
|
13
|
-
empty_directory "lib", "components"
|
14
|
-
empty_directory "lib", "systems"
|
15
|
-
empty_directory "lib", "entities"
|
16
|
-
|
17
|
-
copy_file "jinput.jar", "java"
|
18
|
-
copy_file "lwjgl.jar", "java"
|
19
|
-
copy_file "slick.jar", "java"
|
20
|
-
|
21
|
-
copy_file "libjinput-osx.jnilib"
|
22
|
-
copy_file "liblwjgl.jnilib"
|
23
|
-
copy_file "openal.dylib"
|
24
|
-
|
25
|
-
copy_file "Rakefile"
|
26
|
-
|
27
|
-
template "engine.erb", "engine.rb"
|
28
|
-
template "components.erb", "components.rb"
|
29
|
-
template "renderers.erb", "renderers.rb"
|
30
|
-
template "systems.erb", "systems.rb"
|
31
|
-
template "entities.erb", "entities.rb"
|
32
|
-
end
|
33
|
-
|
34
|
-
def empty_directory(*path)
|
35
|
-
project_directory.join(*path).mkpath
|
36
|
-
end
|
37
|
-
|
38
|
-
def copy_file(filename, destination="")
|
39
|
-
FileUtils.cp(root.join("files", filename), project_directory.join(destination, filename))
|
40
|
-
end
|
41
|
-
|
42
|
-
def template(filename, destination)
|
43
|
-
file = lib_file(destination)
|
44
|
-
file.write(render(template_source(filename)))
|
45
|
-
file.close
|
46
|
-
end
|
47
|
-
|
48
|
-
protected
|
49
|
-
|
50
|
-
def lib_file(filename)
|
51
|
-
project_directory.join("lib", filename).open("w+")
|
52
|
-
end
|
53
|
-
|
54
|
-
def render(source)
|
55
|
-
ERB.new(source).result(binding)
|
56
|
-
end
|
57
|
-
|
58
|
-
def template_source(filename)
|
59
|
-
root.join("templates", filename).read
|
60
|
-
end
|
61
|
-
|
62
|
-
def module_name
|
63
|
-
name.gsub(" ", "_").camelize
|
64
|
-
end
|
65
|
-
|
66
|
-
def name
|
67
|
-
@name
|
68
|
-
end
|
69
|
-
|
70
|
-
def project_directory
|
71
|
-
@project_directory ||= Pathname.new(name)
|
72
|
-
end
|
73
|
-
|
74
|
-
def root
|
75
|
-
@root ||= Pathname.new(__FILE__).join("../../../../").expand_path
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,174 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Slickr::Actions::Create do
|
4
|
-
let!(:action) { described_class.new("A Game") }
|
5
|
-
let!(:rootdir) { Pathname.new(__FILE__).join("../../../../").expand_path }
|
6
|
-
let!(:gamedir) { Pathname.new("A Game") }
|
7
|
-
|
8
|
-
before do
|
9
|
-
# Need the actual template contents so we can compare the rendered output
|
10
|
-
engine = rootdir.join("templates", "engine.erb").read
|
11
|
-
renderers = rootdir.join("templates", "renderers.erb").read
|
12
|
-
components = rootdir.join("templates", "components.erb").read
|
13
|
-
systems = rootdir.join("templates", "systems.erb").read
|
14
|
-
|
15
|
-
FakeFS.activate!
|
16
|
-
|
17
|
-
rootdir.mkpath
|
18
|
-
rootdir.join("files").mkpath
|
19
|
-
|
20
|
-
# The contents of these don't matter, so just make empty files
|
21
|
-
FileUtils.touch(rootdir.join("files", "Rakefile"))
|
22
|
-
FileUtils.touch(rootdir.join("files", "jinput.jar"))
|
23
|
-
FileUtils.touch(rootdir.join("files", "lwjgl.jar"))
|
24
|
-
FileUtils.touch(rootdir.join("files", "slick.jar"))
|
25
|
-
FileUtils.touch(rootdir.join("files", "libjinput-osx.jnilib"))
|
26
|
-
FileUtils.touch(rootdir.join("files", "liblwjgl.jnilib"))
|
27
|
-
FileUtils.touch(rootdir.join("files", "openal.dylib"))
|
28
|
-
|
29
|
-
# Write templates to FakeFS
|
30
|
-
rootdir.join("templates").mkpath
|
31
|
-
rootdir.join("templates", "engine.erb").open("w+") { |f| f << engine }
|
32
|
-
rootdir.join("templates", "components.erb").open("w+") { |f| f << components }
|
33
|
-
rootdir.join("templates", "renderers.erb").open("w+") { |f| f << renderers }
|
34
|
-
rootdir.join("templates", "systems.erb").open("w+") { |f| f << systems }
|
35
|
-
|
36
|
-
# Finally
|
37
|
-
action.start
|
38
|
-
end
|
39
|
-
|
40
|
-
after do
|
41
|
-
FakeFS.deactivate!
|
42
|
-
end
|
43
|
-
|
44
|
-
it "creates the project directory" do
|
45
|
-
gamedir.should be_directory
|
46
|
-
end
|
47
|
-
|
48
|
-
it "creates a java directory" do
|
49
|
-
gamedir.join("java").should be_directory
|
50
|
-
end
|
51
|
-
|
52
|
-
it "creates a lib directory" do
|
53
|
-
gamedir.join("lib").should be_directory
|
54
|
-
end
|
55
|
-
|
56
|
-
it "creates a lib/renderers directory" do
|
57
|
-
gamedir.join("lib", "renderers").should be_directory
|
58
|
-
end
|
59
|
-
|
60
|
-
it "creates a lib/components directory" do
|
61
|
-
gamedir.join("lib", "components").should be_directory
|
62
|
-
end
|
63
|
-
|
64
|
-
it "creates a lib/systems directory" do
|
65
|
-
gamedir.join("lib", "systems").should be_directory
|
66
|
-
end
|
67
|
-
|
68
|
-
it "creates a lib/entities directory" do
|
69
|
-
gamedir.join("lib", "entities").should be_directory
|
70
|
-
end
|
71
|
-
|
72
|
-
it "creates an assets directory" do
|
73
|
-
gamedir.join("assets").should be_directory
|
74
|
-
end
|
75
|
-
|
76
|
-
it "copies jinput.jar into the java directory" do
|
77
|
-
gamedir.join("java", "jinput.jar").should exist
|
78
|
-
end
|
79
|
-
|
80
|
-
it "copies lwjgl.jar into the java directory" do
|
81
|
-
gamedir.join("java", "lwjgl.jar").should exist
|
82
|
-
end
|
83
|
-
|
84
|
-
it "copies slick.jar into the java directory" do
|
85
|
-
gamedir.join("java", "slick.jar").should exist
|
86
|
-
end
|
87
|
-
|
88
|
-
it "copies libjinput-osx.jnilib into the project directory" do
|
89
|
-
gamedir.join("libjinput-osx.jnilib").should exist
|
90
|
-
end
|
91
|
-
|
92
|
-
it "copies liblwjgl.jnilib into the project directory" do
|
93
|
-
gamedir.join("liblwjgl.jnilib").should exist
|
94
|
-
end
|
95
|
-
|
96
|
-
it "copies openal.dylib into the project directory" do
|
97
|
-
gamedir.join("openal.dylib").should exist
|
98
|
-
end
|
99
|
-
|
100
|
-
it "creates the engine file skeleton" do
|
101
|
-
File.read(gamedir.join("lib", "engine.rb")).should == <<-CODE
|
102
|
-
$LOAD_PATH << File.expand_path("../../java", __FILE__)
|
103
|
-
require "java"
|
104
|
-
require "lwjgl.jar"
|
105
|
-
require "slick.jar"
|
106
|
-
|
107
|
-
java_import org.newdawn.slick.AppGameContainer
|
108
|
-
java_import org.newdawn.slick.BasicGame
|
109
|
-
java_import org.newdawn.slick.Color
|
110
|
-
java_import org.newdawn.slick.GameContainer
|
111
|
-
java_import org.newdawn.slick.Graphics
|
112
|
-
java_import org.newdawn.slick.Image
|
113
|
-
java_import org.newdawn.slick.Input
|
114
|
-
|
115
|
-
module AGame
|
116
|
-
class Engine < BasicGame
|
117
|
-
def init(container)
|
118
|
-
end
|
119
|
-
|
120
|
-
def update(container, delta)
|
121
|
-
end
|
122
|
-
|
123
|
-
def render(container, graphics)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
game = AppGameContainer.new(AGame::Engine.new("A Game"))
|
129
|
-
game.set_display_mode(800, 600, false)
|
130
|
-
game.start
|
131
|
-
|
132
|
-
CODE
|
133
|
-
end
|
134
|
-
|
135
|
-
it "creates the components file" do
|
136
|
-
File.read(gamedir.join("lib", "components.rb")).should == <<-CODE
|
137
|
-
module AGame
|
138
|
-
module Components
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
CODE
|
143
|
-
end
|
144
|
-
|
145
|
-
it "creates the renderers file" do
|
146
|
-
File.read(gamedir.join("lib", "renderers.rb")).should == <<-CODE
|
147
|
-
module AGame
|
148
|
-
module Renderers
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
CODE
|
153
|
-
end
|
154
|
-
|
155
|
-
it "creates the systems file" do
|
156
|
-
File.read(gamedir.join("lib", "systems.rb")).should == <<-CODE
|
157
|
-
module AGame
|
158
|
-
module Systems
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
CODE
|
163
|
-
end
|
164
|
-
|
165
|
-
it "creates the systems file" do
|
166
|
-
File.read(gamedir.join("lib", "entities.rb")).should == <<-CODE
|
167
|
-
module AGame
|
168
|
-
module Entities
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
CODE
|
173
|
-
end
|
174
|
-
end
|
data/templates/components.erb
DELETED
data/templates/entities.erb
DELETED
data/templates/renderers.erb
DELETED