gosu_android 0.0.4 → 0.0.5
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 +21 -12
- data/examples/arkanoid_activity.rb +189 -62
- data/examples/load_image_activity.rb +29 -0
- data/examples/pong_activity.rb +109 -41
- data/examples/tutorial_activity.rb +144 -0
- data/examples/tutorial_common_activity.rb +166 -0
- data/examples/{test_game_activity.rb → tutorial_touch_activity.rb} +10 -10
- data/examples/use_keyboard_activity.rb +34 -0
- data/lib/gosu.java.jar +0 -0
- data/lib/gosu_android/audio/audio.rb +45 -6
- data/lib/gosu_android/graphics/blockAllocator.rb +12 -0
- data/lib/gosu_android/graphics/drawOpQueue.rb +1 -1
- data/lib/gosu_android/graphics/font.rb +1 -1
- data/lib/gosu_android/graphics/graphicsBase.rb +1 -2
- data/lib/gosu_android/graphics/image.rb +6 -5
- data/lib/gosu_android/graphics/texChunk.rb +3 -4
- data/lib/gosu_android/graphics/texture.rb +7 -5
- data/lib/gosu_android/input/input.rb +43 -5
- data/lib/gosu_android/main-window.rb +105 -42
- data/lib/gosu_android/requires.rb +6 -1
- data/lib/gosu_android/version.rb +1 -1
- data/res/drawable-nodpi/{ship.png → star_fighter.png} +0 -0
- data/res/drawable-nodpi/yellow_square.png +0 -0
- metadata +12 -8
- data/lib/gosu_android/physics/physicsManager.rb +0 -57
- data/lib/gosu_android/physics/physicsObject.rb +0 -113
@@ -8,6 +8,7 @@ module JavaImports
|
|
8
8
|
java_import "android.opengl.GLSurfaceView"
|
9
9
|
end
|
10
10
|
|
11
|
+
#Opengl dependencies
|
11
12
|
java_import "javax.microedition.khronos.egl.EGL10"
|
12
13
|
java_import "javax.microedition.khronos.egl.EGLConfig"
|
13
14
|
java_import "javax.microedition.khronos.opengles.GL10"
|
@@ -31,6 +32,9 @@ module JavaImports
|
|
31
32
|
java_import "android.view.WindowManager"
|
32
33
|
java_import "android.view.KeyEvent"
|
33
34
|
|
35
|
+
#Handles the keyboard
|
36
|
+
java_import "android.view.inputmethod.InputMethodManager"
|
37
|
+
|
34
38
|
#Fonts
|
35
39
|
java_import "android.graphics.Canvas"
|
36
40
|
java_import "android.graphics.Paint"
|
@@ -40,5 +44,6 @@ module JavaImports
|
|
40
44
|
#Audio
|
41
45
|
java_import "android.media.SoundPool"
|
42
46
|
java_import "android.media.AudioManager"
|
43
|
-
java_import "android.media.MediaPlayer"
|
47
|
+
java_import "android.media.MediaPlayer"
|
48
|
+
java_import "android.app.Service"
|
44
49
|
end
|
data/lib/gosu_android/version.rb
CHANGED
File without changes
|
Binary file
|
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: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Garoe Dorta
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-04-
|
18
|
+
date: 2013-04-23 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: |
|
@@ -33,8 +33,12 @@ files:
|
|
33
33
|
- README.md
|
34
34
|
- Rakefile
|
35
35
|
- examples/arkanoid_activity.rb
|
36
|
+
- examples/load_image_activity.rb
|
36
37
|
- examples/pong_activity.rb
|
37
|
-
- examples/
|
38
|
+
- examples/tutorial_activity.rb
|
39
|
+
- examples/tutorial_common_activity.rb
|
40
|
+
- examples/tutorial_touch_activity.rb
|
41
|
+
- examples/use_keyboard_activity.rb
|
38
42
|
- bin/gosu_android
|
39
43
|
- lib/gosu.java.jar
|
40
44
|
- lib/gosu.rb
|
@@ -61,8 +65,6 @@ files:
|
|
61
65
|
- lib/gosu_android/input/input.rb
|
62
66
|
- lib/gosu_android/main-window.rb
|
63
67
|
- lib/gosu_android/math.rb
|
64
|
-
- lib/gosu_android/physics/physicsManager.rb
|
65
|
-
- lib/gosu_android/physics/physicsObject.rb
|
66
68
|
- lib/gosu_android/requires.rb
|
67
69
|
- lib/gosu_android/timing.rb
|
68
70
|
- lib/gosu_android/version.rb
|
@@ -70,9 +72,10 @@ files:
|
|
70
72
|
- res/drawable-nodpi/bar.png
|
71
73
|
- res/drawable-nodpi/bar_hor.png
|
72
74
|
- res/drawable-nodpi/character_atlas8.png
|
73
|
-
- res/drawable-nodpi/ship.png
|
74
75
|
- res/drawable-nodpi/space.png
|
75
76
|
- res/drawable-nodpi/star.png
|
77
|
+
- res/drawable-nodpi/star_fighter.png
|
78
|
+
- res/drawable-nodpi/yellow_square.png
|
76
79
|
- res/raw/beep.wav
|
77
80
|
- res/raw/chriss_onac_tempo_red.mp3
|
78
81
|
homepage: https://github.com/neochuky/gosu-android/
|
@@ -110,3 +113,4 @@ specification_version: 3
|
|
110
113
|
summary: A Gosu implementation for Android.
|
111
114
|
test_files: []
|
112
115
|
|
116
|
+
has_rdoc:
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'gosu_android/physics/physicsObject'
|
2
|
-
|
3
|
-
module Gosu
|
4
|
-
|
5
|
-
class PhysicsManager
|
6
|
-
attr_accessor :gravity_x, :gravity_y
|
7
|
-
def initialize(window)
|
8
|
-
@window = window
|
9
|
-
@dt = @window.update_interval
|
10
|
-
@squares = []
|
11
|
-
@planes = []
|
12
|
-
@gravity_x = 0
|
13
|
-
@gravity_y = 98 #10 pixels are 1 meter
|
14
|
-
end
|
15
|
-
|
16
|
-
def register_new_object object
|
17
|
-
if object.class == Square
|
18
|
-
@squares.push object unless @squares.include? object
|
19
|
-
elsif object.class == Plane
|
20
|
-
@planes.push object unless @planes.include? object
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def delete_object object
|
25
|
-
if object.class == Square
|
26
|
-
@squares.delete object
|
27
|
-
elsif object.class == Plane
|
28
|
-
@planes.delete object
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def update
|
33
|
-
#Gravity
|
34
|
-
@squares.each do |square|
|
35
|
-
if square.mass_inverted > 0
|
36
|
-
square.velocity[0] += @dt*@gravity_x
|
37
|
-
square.velocity[1] += @dt*@gravity_y
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
#Collision detection
|
42
|
-
@squares.each do |square|
|
43
|
-
@planes.each do |plane|
|
44
|
-
square.generate_contact plane
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
#Integrate
|
49
|
-
@squares.each do |square|
|
50
|
-
if square.mass_inverted > 0
|
51
|
-
square.integrate
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'gosu_android/graphics/image'
|
2
|
-
|
3
|
-
module Gosu
|
4
|
-
|
5
|
-
def self.dot_product(l1, l2)
|
6
|
-
sum = 0
|
7
|
-
for i in 0...l1.size
|
8
|
-
sum += l1[i] * l2[i]
|
9
|
-
end
|
10
|
-
sum
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.cross_product(l1,l2)
|
14
|
-
res = []
|
15
|
-
res.push( l1[1]*l2[2] - l1[2]*l2[1] );
|
16
|
-
res.push( l1[2]*l2[0] - l1[0]*l2[2] );
|
17
|
-
res.push( l1[0]*l2[1] - l1[1]*l2[0] );
|
18
|
-
d = res.max
|
19
|
-
if(d == 0)
|
20
|
-
d = res.min
|
21
|
-
res[0] = res[0]/-d
|
22
|
-
res[1] = res[1]/-d
|
23
|
-
else
|
24
|
-
res[0] = res[0]/d
|
25
|
-
res[1] = res[1]/d
|
26
|
-
end
|
27
|
-
res
|
28
|
-
end
|
29
|
-
|
30
|
-
class Square
|
31
|
-
attr_accessor :velocity
|
32
|
-
attr_reader :position, :center
|
33
|
-
attr_reader :mass_inverted, :restitution
|
34
|
-
def initialize(window, file_name, x, y, z, size, mass_inverted,
|
35
|
-
velocity_x = 0, velocity_y = 0, restitution = 1, tileable = false)
|
36
|
-
@window = window
|
37
|
-
@position = [x,y]
|
38
|
-
@size = size / 2
|
39
|
-
@center = [@position[0] + @size, @position[1] + @size]
|
40
|
-
@z = z
|
41
|
-
@restitution = restitution
|
42
|
-
@velocity = [velocity_x, velocity_y]
|
43
|
-
@mass_inverted = mass_inverted
|
44
|
-
@image = Gosu::Image.new(@window, file_name , tileable)
|
45
|
-
@dt = @window.update_interval
|
46
|
-
end
|
47
|
-
|
48
|
-
def integrate
|
49
|
-
@position[0] += @velocity[0]*@dt
|
50
|
-
@position[1] += @velocity[1]*@dt
|
51
|
-
@center = [@position[0] + @size, @position[1] + @size]
|
52
|
-
end
|
53
|
-
|
54
|
-
def generate_contact other_object
|
55
|
-
if other_object.class == Square
|
56
|
-
elsif other_object.class == Plane
|
57
|
-
if @center[0] - @size < other_object.top_limit[0] and other_object.bottom_limit[0] < @center[0] + @size and
|
58
|
-
@center[1] - @size < other_object.bottom_limit[1] and other_object.top_limit[1] < @center[1] + @size
|
59
|
-
#Calculate new velocity, after the hit
|
60
|
-
if other_object.type == :vertical
|
61
|
-
@velocity[0] -= (1 + @restitution) * @velocity[0]
|
62
|
-
else
|
63
|
-
@velocity[1] -= (1 + @restitution) * @velocity[1]
|
64
|
-
end
|
65
|
-
#Call window event
|
66
|
-
@window.object_collided( @position[0], @position[1], other_object )
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def draw
|
72
|
-
@image.draw(@position[0], @position[1], @z)
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
# Bottom ----- Top
|
78
|
-
#
|
79
|
-
# Top
|
80
|
-
# |
|
81
|
-
# |
|
82
|
-
# |
|
83
|
-
# Bottom
|
84
|
-
class Plane
|
85
|
-
attr_accessor :bottom_limit, :top_limit
|
86
|
-
attr_reader :type
|
87
|
-
def initialize(window, file_name, p0, p1, z)
|
88
|
-
@window = window
|
89
|
-
@image = Gosu::Image.new(@window, file_name)
|
90
|
-
@z = z
|
91
|
-
@top_limit = Array.new p0
|
92
|
-
@bottom_limit = Array.new p1
|
93
|
-
|
94
|
-
if(@bottom_limit[0] > @top_limit[0] or @bottom_limit[1] < @top_limit[1])
|
95
|
-
@top_limit, @bottom_limit = @bottom_limit, @top_limit
|
96
|
-
end
|
97
|
-
|
98
|
-
if @bottom_limit[0] == @top_limit[0]
|
99
|
-
@type = :vertical
|
100
|
-
elsif @bottom_limit[1] == @top_limit[1]
|
101
|
-
@type = :horizontal
|
102
|
-
else
|
103
|
-
raise "Planes can only be horizontal or vertical"
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
def draw(x,y,z = @z)
|
109
|
-
@image.draw(x,y,z)
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|