gosu_android 0.0.2 → 0.0.4
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/README.md +17 -15
- data/Rakefile +26 -0
- data/examples/{arkanoid.rb → arkanoid_activity.rb} +2 -2
- data/examples/pong_activity.rb +2 -2
- data/examples/{test-game.rb → test_game_activity.rb} +1 -1
- data/lib/gosu.java.jar +0 -0
- data/lib/{gosu_android.rb → gosu.rb} +0 -0
- data/lib/gosu_android/commands/base.rb +22 -6
- data/lib/gosu_android/input/buttons.rb +1 -1
- data/lib/gosu_android/main-window.rb +2 -1
- data/lib/gosu_android/requires.rb +7 -3
- data/lib/gosu_android/version.rb +1 -1
- metadata +10 -25
data/README.md
CHANGED
@@ -4,14 +4,25 @@ A Gosu implementation for Adroid devices.
|
|
4
4
|
|
5
5
|
Installation
|
6
6
|
-----------
|
7
|
-
Sadly right now you need to manually copy every file to every ruboto proyect you want to use it.
|
8
7
|
|
9
|
-
|
10
|
-
- Copy the `lib` folder and the `gosu.rb` to the `proyect_name/src/` folder inside your [ruboto](http://github.com/ruboto/ruboto) proyect.
|
11
|
-
- Copy the `gosu.java.jar` in the `proyect_name/libs/` folder.
|
12
|
-
- Place the `res` files in the `proyect_name/res` folder.
|
13
|
-
- It is very important that you do not copy the `java` files in your proyect folder, they are included for developers only.
|
8
|
+
### Easy way
|
14
9
|
|
10
|
+
* Create a file named Gemfile.apk in your ruboto project and add the lines
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
source "http://rubygems.org"
|
14
|
+
gem 'gosu_android'
|
15
|
+
```
|
16
|
+
|
17
|
+
* Create a folder inside `res` folder call `drawable-nodpi` and copy this file https://github.com/neochuky/gosu-android/tree/master/res/drawable-nodpi/character_atlas8.png
|
18
|
+
in it.
|
19
|
+
|
20
|
+
### Not so easy way
|
21
|
+
`gem install gosu_android`
|
22
|
+
|
23
|
+
As with ruboto, place yourself in the root directory of your app, then execute
|
24
|
+
`gosu_android -a` or `gosu_android --add` to automatically copy every gosu_android file to your ruboto project.
|
25
|
+
It will also copy all the media files that are use in gosu_android examples.
|
15
26
|
|
16
27
|
General Information
|
17
28
|
-------------------
|
@@ -22,14 +33,5 @@ General Information
|
|
22
33
|
|
23
34
|
Troubleshooting
|
24
35
|
-------------------
|
25
|
-
* If you're using Ruboto 0.10.4 or earlier, you may get an error when trying to require the gosu libraries: `(SystemStackError) stack level too deep` in `require 'gosu'`. If this happens:
|
26
|
-
* Replace `require 'gosu'` with `with_large_stack { require 'gosu' }`. If it still doesn't work:
|
27
|
-
* Try `with_large_stack(256)
|
28
|
-
require 'gosu'
|
29
|
-
end`. If it still doesn't work, try again with `512` instead of `256`.
|
30
|
-
* Alternatively, update to the latest Ruboto (0.11 or better).
|
31
|
-
* Relevant Ruboto issues:
|
32
|
-
* https://github.com/ruboto/ruboto/issues/359
|
33
|
-
* https://github.com/ruboto/ruboto/issues/375
|
34
36
|
* When using several audio files double check that all have the same codification or you could get: `E/MediaPlayer(16127): Unable to to create media player`
|
35
37
|
* http://forums.pragprog.com/forums/152/topics/9144
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
CLASSES_DIR = 'pkg/classes'
|
2
|
+
JAVA_SOURCES = 'java/*'
|
3
|
+
|
4
|
+
unless ENV['ANDROID_HOME']
|
5
|
+
begin
|
6
|
+
adb_path = `which adb`
|
7
|
+
ENV['ANDROID_HOME'] = File.dirname(File.dirname(adb_path)) if $? == 0
|
8
|
+
rescue Errno::ENOENT
|
9
|
+
puts "Unable to detect adb location: #$!"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
(puts 'You need to set the ANDROID_HOME environment variable.'; exit 1) unless ENV['ANDROID_HOME']
|
13
|
+
|
14
|
+
directory CLASSES_DIR
|
15
|
+
|
16
|
+
desc 'Generate the gosu.java.jar'
|
17
|
+
task :jar => [CLASSES_DIR] + FileList[JAVA_SOURCES] do
|
18
|
+
sh "javac -source 1.6 -target 1.6 -bootclasspath #{ENV['ANDROID_HOME']}/platforms/android-10/android.jar -d #{CLASSES_DIR} #{JAVA_SOURCES}"
|
19
|
+
sh "jar cf lib/gosu.java.jar -C #{CLASSES_DIR} gosu"
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Build the gem'
|
23
|
+
task :gem => :jar do
|
24
|
+
sh 'gem build gosu_android.gemspec'
|
25
|
+
sh 'mv gosu_android-*.gem pkg/'
|
26
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'gosu'
|
2
2
|
|
3
3
|
class GameWindow < Gosu::Window
|
4
4
|
def initialize
|
@@ -88,7 +88,7 @@ class GameWindow < Gosu::Window
|
|
88
88
|
|
89
89
|
end
|
90
90
|
|
91
|
-
class
|
91
|
+
class ArkanoidActivity
|
92
92
|
def on_create(bundle)
|
93
93
|
super(bundle)
|
94
94
|
Gosu::AndroidInitializer.instance.start(self)
|
data/examples/pong_activity.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'gosu'
|
2
2
|
|
3
3
|
class GameWindow < Gosu::Window
|
4
4
|
def initialize
|
@@ -82,7 +82,7 @@ class GameWindow < Gosu::Window
|
|
82
82
|
|
83
83
|
end
|
84
84
|
|
85
|
-
class
|
85
|
+
class PongActivity
|
86
86
|
def on_create(bundle)
|
87
87
|
super(bundle)
|
88
88
|
Gosu::AndroidInitializer.instance.start(self)
|
data/lib/gosu.java.jar
CHANGED
Binary file
|
File without changes
|
@@ -1,4 +1,9 @@
|
|
1
1
|
require 'rake'
|
2
|
+
#gem root -> where the gem is located
|
3
|
+
gem_root = File.expand_path(File.dirname(__FILE__))
|
4
|
+
#Delete last occurence of /commands
|
5
|
+
gem_root = gem_root.reverse.sub( "commands".reverse, '' ).reverse
|
6
|
+
require gem_root + "version.rb"
|
2
7
|
|
3
8
|
module Gosu
|
4
9
|
module Commands
|
@@ -11,6 +16,7 @@ module Gosu
|
|
11
16
|
puts ""
|
12
17
|
puts " -a, --add adds the files to the project"
|
13
18
|
puts " -d, --delete deletes the files from the project"
|
19
|
+
puts " -v, --version shows current version"
|
14
20
|
puts " -h, --help display this help and exit"
|
15
21
|
puts ""
|
16
22
|
puts "The options -a and -d can not be given together."
|
@@ -60,8 +66,8 @@ module Gosu
|
|
60
66
|
#Delete last occurence of /gosu_android
|
61
67
|
gem_root = gem_root.reverse.sub( "/gosu_android".reverse, '' ).reverse
|
62
68
|
|
63
|
-
src = gem_root + "/
|
64
|
-
dst = root + "/src/
|
69
|
+
src = gem_root + "/gosu.rb"
|
70
|
+
dst = root + "/src/gosu.rb"
|
65
71
|
FileUtils.cp(src, dst)
|
66
72
|
src = gem_root + "/gosu.java.jar"
|
67
73
|
dst = root + "/libs/gosu.java.jar"
|
@@ -100,8 +106,8 @@ module Gosu
|
|
100
106
|
$stderr.puts e.message
|
101
107
|
end
|
102
108
|
|
103
|
-
#Deleting
|
104
|
-
to_delete = root + "/src/
|
109
|
+
#Deleting gosu.rb file
|
110
|
+
to_delete = root + "/src/gosu.rb"
|
105
111
|
begin
|
106
112
|
File.delete to_delete
|
107
113
|
rescue => e
|
@@ -148,6 +154,7 @@ module Gosu
|
|
148
154
|
add = false
|
149
155
|
delete = false
|
150
156
|
help = false
|
157
|
+
version = false
|
151
158
|
ARGV.each do|a|
|
152
159
|
case a
|
153
160
|
when "-a"
|
@@ -162,14 +169,23 @@ module Gosu
|
|
162
169
|
help = true
|
163
170
|
when "--help"
|
164
171
|
help = true
|
172
|
+
when "-v"
|
173
|
+
version = true
|
174
|
+
when "--version"
|
175
|
+
version = true
|
165
176
|
end
|
166
177
|
end
|
167
178
|
|
168
|
-
if help or not add and not delete
|
179
|
+
if help or not add and not delete and not version
|
169
180
|
show_help
|
170
181
|
exit 0
|
171
182
|
end
|
172
183
|
|
184
|
+
if version
|
185
|
+
puts Gosu::VERSION
|
186
|
+
exit 0
|
187
|
+
end
|
188
|
+
|
173
189
|
if add and delete
|
174
190
|
$stderr.puts "Add and delete can not be perform at the same time\n"
|
175
191
|
exit 1
|
@@ -189,4 +205,4 @@ module Gosu
|
|
189
205
|
end
|
190
206
|
end
|
191
207
|
end
|
192
|
-
|
208
|
+
|
@@ -107,7 +107,7 @@ module Gosu
|
|
107
107
|
|
108
108
|
#Load supported buttons on android above 4.0.0
|
109
109
|
if android.os.Build::VERSION::SDK_INT >= 15
|
110
|
-
Game pad
|
110
|
+
# Game pad
|
111
111
|
GpButton0 = JavaImports::KeyEvent::KEYCODE_BUTTON_1
|
112
112
|
GpButton1 = JavaImports::KeyEvent::KEYCODE_BUTTON_2
|
113
113
|
GpButton10 = JavaImports::KeyEvent::KEYCODE_BUTTON_11
|
@@ -11,6 +11,7 @@ require 'gosu_android/timing'
|
|
11
11
|
require 'singleton'
|
12
12
|
require 'ruboto/util/toast'
|
13
13
|
|
14
|
+
|
14
15
|
module Gosu
|
15
16
|
|
16
17
|
class AndroidInitializer
|
@@ -33,7 +34,7 @@ module Gosu
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
class GosuSurfaceView <
|
37
|
+
class GosuSurfaceView < JavaImports::GLSurfaceView
|
37
38
|
|
38
39
|
def atributes(window, input)
|
39
40
|
@window = window
|
@@ -2,8 +2,12 @@ require 'ruboto/activity'
|
|
2
2
|
|
3
3
|
module JavaImports
|
4
4
|
#Opengl classes
|
5
|
-
|
6
|
-
|
5
|
+
if android.os.Build::VERSION::SDK_INT <= 10
|
6
|
+
java_import "gosu.java.GLSurfaceView"
|
7
|
+
else
|
8
|
+
java_import "android.opengl.GLSurfaceView"
|
9
|
+
end
|
10
|
+
|
7
11
|
java_import "javax.microedition.khronos.egl.EGL10"
|
8
12
|
java_import "javax.microedition.khronos.egl.EGLConfig"
|
9
13
|
java_import "javax.microedition.khronos.opengles.GL10"
|
@@ -37,4 +41,4 @@ module JavaImports
|
|
37
41
|
java_import "android.media.SoundPool"
|
38
42
|
java_import "android.media.AudioManager"
|
39
43
|
java_import "android.media.MediaPlayer"
|
40
|
-
end
|
44
|
+
end
|
data/lib/gosu_android/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosu_android
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Garoe Dorta
|
@@ -15,24 +15,9 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
19
|
-
dependencies:
|
20
|
-
|
21
|
-
name: ruboto
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 63
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 8
|
32
|
-
- 0
|
33
|
-
version: 0.8.0
|
34
|
-
type: :runtime
|
35
|
-
version_requirements: *id001
|
18
|
+
date: 2013-04-06 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
36
21
|
description: |
|
37
22
|
Gosu-Android is an implementation for Android devices of the multiplatform Gosu library.
|
38
23
|
|
@@ -46,12 +31,13 @@ extra_rdoc_files: []
|
|
46
31
|
files:
|
47
32
|
- LICENSE
|
48
33
|
- README.md
|
49
|
-
-
|
34
|
+
- Rakefile
|
35
|
+
- examples/arkanoid_activity.rb
|
50
36
|
- examples/pong_activity.rb
|
51
|
-
- examples/
|
37
|
+
- examples/test_game_activity.rb
|
52
38
|
- bin/gosu_android
|
53
39
|
- lib/gosu.java.jar
|
54
|
-
- lib/
|
40
|
+
- lib/gosu.rb
|
55
41
|
- lib/gosu_android/audio/audio.rb
|
56
42
|
- lib/gosu_android/commands/base.rb
|
57
43
|
- lib/gosu_android/description.rb
|
@@ -124,4 +110,3 @@ specification_version: 3
|
|
124
110
|
summary: A Gosu implementation for Android.
|
125
111
|
test_files: []
|
126
112
|
|
127
|
-
has_rdoc:
|