igg 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 +4 -4
- data/README.md +44 -0
- data/lib/igg/builder/templates/project/level.js +8 -0
- data/lib/igg/cli.rb +137 -5
- metadata +20 -5
- data/README.rdoc +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a37017de5563deb7e0009d75bbd977b2b004a33f
|
4
|
+
data.tar.gz: ac0b445fa6b43b1cf2976c7c4e639c5a7af7998c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00b5187df165fd436bd96ed8a71fb64de7c830919ad937926b47bfb218040607e95bf895dbc5e6cc53996cafabe5dec7d036df9f459aee104363f7f1f46bf632
|
7
|
+
data.tar.gz: d84b59c628acb8c56559fae8bfa79bf54d2708c28290beb2a9f081455cf6388f3cfe3468c9fd690cb783d2811e0fb6602e5217a82f0628c8de3845ffdbb9d739
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
## ImpactJS Game Generator.
|
2
|
+
|
3
|
+
|
4
|
+
### Installation
|
5
|
+
|
6
|
+
$ gem install igg
|
7
|
+
|
8
|
+
### Help
|
9
|
+
|
10
|
+
$ igg
|
11
|
+
Commands:
|
12
|
+
igg entity [NAME] # generate an ImpactJS Game entity
|
13
|
+
igg help [COMMAND] # Describe available commands or one specific command
|
14
|
+
igg level [NAME] # generate an ImpactJS Game level
|
15
|
+
igg project [NAME] # generate an ImpactJS Game project
|
16
|
+
|
17
|
+
### Generate an ImpactJS Game project
|
18
|
+
|
19
|
+
$ cb project phone # default width=320 height=240
|
20
|
+
|
21
|
+
### Generate an ImpactJS Game Level
|
22
|
+
|
23
|
+
$ cb level shooting # default width=320 height=240
|
24
|
+
|
25
|
+
### Generate an ImpactJS Game Entity
|
26
|
+
|
27
|
+
$ cb entity player # default width=16 height=16
|
28
|
+
|
29
|
+
### Run Server mode to play the game
|
30
|
+
|
31
|
+
$ igg server
|
32
|
+
![igg server usage](https://raw.github.com/eiffelqiu/igg/master/doc/screen1.png)
|
33
|
+
|
34
|
+
open 'http://localhost:4567' in browser
|
35
|
+
![play impact game usage](https://raw.github.com/eiffelqiu/igg/master/doc/screen3.png)
|
36
|
+
|
37
|
+
### Run Server mode to run weltmeister level editor
|
38
|
+
|
39
|
+
$ igg server
|
40
|
+
|
41
|
+
open 'http://localhost:4567/weltmeister' in browser
|
42
|
+
|
43
|
+
![weltmeister usage](https://raw.github.com/eiffelqiu/igg/master/doc/screen2.png)
|
44
|
+
|
data/lib/igg/cli.rb
CHANGED
@@ -1,7 +1,110 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'pathname'
|
4
|
+
require 'json'
|
1
5
|
require 'thor'
|
6
|
+
|
2
7
|
require_relative 'ext/string_extention'
|
3
8
|
%w[project entity level].each { |task| require_relative "builder/#{task}_builder" }
|
4
9
|
|
10
|
+
class Server < Sinatra::Base
|
11
|
+
|
12
|
+
set :public_folder, Dir.pwd
|
13
|
+
|
14
|
+
# This is where you could serve different pages depending on the device accessing the page,
|
15
|
+
# such as for iPads and mobile devices.
|
16
|
+
|
17
|
+
# get '/', :agent => /iphone|android/i do
|
18
|
+
# File.read('mobile.html')
|
19
|
+
# end
|
20
|
+
|
21
|
+
get '/' do
|
22
|
+
File.read('./index.html')
|
23
|
+
end
|
24
|
+
|
25
|
+
get '/weltmeister' do
|
26
|
+
File.read('./weltmeister.html')
|
27
|
+
end
|
28
|
+
|
29
|
+
get /\/lib\/weltmeister\/api\/glob(.php)?/ do
|
30
|
+
@files = params[:glob].inject([]) do |memo, glob|
|
31
|
+
dir = from_impact_basedir(glob)
|
32
|
+
Pathname.glob(dir).each do |d|
|
33
|
+
memo << relative_pathname(d)
|
34
|
+
end
|
35
|
+
memo
|
36
|
+
end
|
37
|
+
|
38
|
+
content_type :json
|
39
|
+
@files.to_json
|
40
|
+
end
|
41
|
+
|
42
|
+
get /\/lib\/weltmeister\/api\/browse(.php)?/ do
|
43
|
+
@dir = from_impact_basedir(params[:dir])
|
44
|
+
@type = params[:type]
|
45
|
+
|
46
|
+
extensions = []
|
47
|
+
|
48
|
+
case @type
|
49
|
+
when 'images' then extensions += %w{png gif jpg jpeg bmp}
|
50
|
+
when 'scripts' then extensions += %w{js}
|
51
|
+
else extensions += "*".to_a
|
52
|
+
end
|
53
|
+
|
54
|
+
parent = @dir ? relative_pathname(Pathname.new(@dir).parent) : false
|
55
|
+
directories = Pathname.new(@dir).children.select { |c| c.directory? }.map { |d| relative_pathname d }
|
56
|
+
files = Pathname.glob(File.join(@dir, "*.{#{extensions.join(',')}}")).map { |f| relative_pathname f }
|
57
|
+
|
58
|
+
content_type :json
|
59
|
+
{
|
60
|
+
:parent => parent,
|
61
|
+
:dirs => directories,
|
62
|
+
:files => files
|
63
|
+
}.to_json
|
64
|
+
end
|
65
|
+
|
66
|
+
post /\/lib\/weltmeister\/api\/save(.php)?/ do
|
67
|
+
response = { :error => 0 }
|
68
|
+
|
69
|
+
if params[:path] && params[:data]
|
70
|
+
@dir = from_impact_basedir(params[:path])
|
71
|
+
|
72
|
+
if File.extname(@dir) == ".js"
|
73
|
+
begin
|
74
|
+
File.open(@dir, 'w') { |f| f.write(params[:data]) }
|
75
|
+
rescue => e
|
76
|
+
response[:error] = 2
|
77
|
+
response[:msg] = "Could not save the level file. " + e.message
|
78
|
+
end
|
79
|
+
else
|
80
|
+
response[:error] = 3
|
81
|
+
response[:msg] = "File must have a .js suffix"
|
82
|
+
end
|
83
|
+
else
|
84
|
+
response[:error] = 1
|
85
|
+
response[:msg] = "No Data or Path specified"
|
86
|
+
end
|
87
|
+
|
88
|
+
content_type :json
|
89
|
+
response.to_json
|
90
|
+
end
|
91
|
+
|
92
|
+
helpers do
|
93
|
+
def from_impact_basedir(dir)
|
94
|
+
@folder = dir.to_s.sub(%r{\.\./?},"")
|
95
|
+
# File.join(File.dirname(__FILE__), @folder)
|
96
|
+
File.join(Dir.pwd, @folder)
|
97
|
+
end
|
98
|
+
def relative_pathname(path)
|
99
|
+
# @asset_root ||= Pathname(File.dirname(__FILE__)).realpath
|
100
|
+
@asset_root ||= Pathname(Dir.pwd).realpath
|
101
|
+
path = Pathname(File.expand_path(path))
|
102
|
+
path.relative_path_from(@asset_root).cleanpath.to_s
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
5
108
|
class Igg::CLI < Thor
|
6
109
|
include Thor::Actions
|
7
110
|
Igg::Builder.constants.each { |b| include "Igg::Builder::#{b}".to_class }
|
@@ -10,12 +113,17 @@ class Igg::CLI < Thor
|
|
10
113
|
|
11
114
|
def self.source_root; File.dirname(__FILE__) end
|
12
115
|
|
13
|
-
class_option :width, :type => :numeric, :default => 320, :required => false, :aliases => "-w", :desc => "width"
|
14
|
-
class_option :height, :type => :numeric, :default => 240, :required => false, :aliases => "-h", :desc => "height"
|
15
|
-
|
16
116
|
%w[project entity level].each do |type|
|
117
|
+
if type == 'entity'
|
118
|
+
method_option :width, :type => :numeric, :default => 16, :required => false, :aliases => "-w", :desc => "width"
|
119
|
+
method_option :height, :type => :numeric, :default => 16, :required => false, :aliases => "-h", :desc => "height"
|
120
|
+
else
|
121
|
+
method_option :width, :type => :numeric, :default => 320, :required => false, :aliases => "-w", :desc => "width"
|
122
|
+
method_option :height, :type => :numeric, :default => 240, :required => false, :aliases => "-h", :desc => "height"
|
123
|
+
end
|
124
|
+
|
17
125
|
class_eval %{
|
18
|
-
desc "#{type} [
|
126
|
+
desc "#{type} [name]", "generate an ImpactJS Game #{type}"
|
19
127
|
def #{type}(name=nil) end
|
20
128
|
}
|
21
129
|
end
|
@@ -25,6 +133,30 @@ class Igg::CLI < Thor
|
|
25
133
|
method = args[2][:current_command][:name] # default project name is app type name
|
26
134
|
@name, @width, @height = args[0][0] || "#{method}", options[:width], options[:height]
|
27
135
|
@name = "#{@name}".downcase
|
28
|
-
|
136
|
+
if method == 'server' then
|
137
|
+
if File.exist?('lib/weltmeister/config.js')
|
138
|
+
File.write("lib/weltmeister/config.js",File.open("lib/weltmeister/config.js",&:read).gsub(".php",""))
|
139
|
+
puts
|
140
|
+
puts "*" * 80
|
141
|
+
puts "modified lib/weltmeister/config.js file, remove all '.php' suffix in api call "
|
142
|
+
puts "*" * 80
|
143
|
+
puts
|
144
|
+
Server.run!
|
145
|
+
else
|
146
|
+
puts "*" * 60
|
147
|
+
puts "Can't run without impact and weltmeister, you must do as follow"
|
148
|
+
puts
|
149
|
+
puts "1: Copy 'impact' folder to current 'lib' subdirectory. "
|
150
|
+
puts "2: Copy 'weltmeister' folder to current 'lib' subdirectory. "
|
151
|
+
puts "3: Copy 'weltmeister.html' folder to current directory. "
|
152
|
+
puts "*" * 60
|
153
|
+
exit
|
154
|
+
end
|
155
|
+
elsif method == 'help'
|
156
|
+
|
157
|
+
else
|
158
|
+
send "build_#{method}"
|
159
|
+
end
|
160
|
+
|
29
161
|
end
|
30
162
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: igg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- eiffel qiu
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.19'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '0.19'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sinatra
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.4'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,10 +101,10 @@ executables:
|
|
87
101
|
extensions: []
|
88
102
|
extra_rdoc_files:
|
89
103
|
- LICENSE
|
90
|
-
- README.
|
104
|
+
- README.md
|
91
105
|
files:
|
92
106
|
- LICENSE
|
93
|
-
- README.
|
107
|
+
- README.md
|
94
108
|
- bin/igg
|
95
109
|
- lib/igg.rb
|
96
110
|
- lib/igg/builder/entity_builder.rb
|
@@ -101,6 +115,7 @@ files:
|
|
101
115
|
- lib/igg/builder/templates/level/main.js
|
102
116
|
- lib/igg/builder/templates/project/04b03.font.png
|
103
117
|
- lib/igg/builder/templates/project/index.html
|
118
|
+
- lib/igg/builder/templates/project/level.js
|
104
119
|
- lib/igg/builder/templates/project/main.tt
|
105
120
|
- lib/igg/builder/templates/project/sounds/death.mp3
|
106
121
|
- lib/igg/builder/templates/project/sounds/death.ogg
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= igg
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to igg
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2015 eiffel qiu. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|