minigl 2.0.1 → 2.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 +5 -5
- data/lib/minigl/game_object.rb +24 -22
- data/lib/minigl/global.rb +3 -2
- data/test/game.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 683014cfbecd482d631925ec45ee1326021e024a
|
4
|
+
data.tar.gz: ee579a15c9f2eaf33e5ebffd6349553299b5fdbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3751ccd5c52458864578752a7f10a71db732e5ec0514a258e3cef6feece6e30df6d1563525a00ee4f2e4c1b017045eab0a9fb6818a48997c62a03f0b7ed914c
|
7
|
+
data.tar.gz: fda44bd25b989ffe54b2208f6883662c2baeeb8384d7453ecb6fa0edf8286d36020c81aa42bfd38d3998458617312b398fbe867147334041f0142026d3fcd162
|
data/README.md
CHANGED
@@ -32,9 +32,9 @@ examples provided with the gem.
|
|
32
32
|
* An auxiliary, tutorial-like documentation is under construction
|
33
33
|
[here](https://github.com/victords/minigl/wiki/How-To).
|
34
34
|
|
35
|
-
**Version 2.0.
|
35
|
+
**Version 2.0.2**
|
36
36
|
|
37
|
-
*
|
38
|
-
|
39
|
-
*
|
40
|
-
`
|
37
|
+
* Small adjustment in `GameWindow#clear`, changing the format of the color
|
38
|
+
parameter from AARRGGBB to RRGGBB (as the alpha would have no effect).
|
39
|
+
* Addition of the `flip` parameter to the `draw` method of `Sprite` and
|
40
|
+
`GameObject`.
|
data/lib/minigl/game_object.rb
CHANGED
@@ -83,20 +83,22 @@ module MiniGL
|
|
83
83
|
# will be darkened, for example.
|
84
84
|
# [angle] A rotation, in degrees, to be applied to the image, relative to
|
85
85
|
# its center.
|
86
|
+
# [flip] Specify +:horiz+ to draw the image horizontally flipped or +:vert+
|
87
|
+
# to draw it vertically flipped.
|
86
88
|
# [z_index] The z-order to draw the object. Objects with larger z-orders
|
87
89
|
# will be drawn on top of the ones with smaller z-orders.
|
88
|
-
def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, z_index = 0)
|
90
|
+
def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, flip = nil, z_index = 0)
|
89
91
|
color = (alpha << 24) | color
|
90
|
-
if
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
elsif angle
|
97
|
-
@img[@img_index].draw_rot @x.round, @y.round, z_index, angle, 0.5, 0.5, scale_x, scale_y, color
|
92
|
+
if angle
|
93
|
+
@img[@img_index].draw_rot @x.round - (map ? map.cam.x : 0) + (flip == :horiz ? scale_x * @img[0].width : 0),
|
94
|
+
@y.round - (map ? map.cam.y : 0) + (flip == :vert ? scale_y * @img[0].height : 0),
|
95
|
+
z_index, angle, 0.5, 0.5, (flip == :horiz ? -scale_x : scale_x),
|
96
|
+
(flip == :vert ? -scale_y : scale_y), color
|
98
97
|
else
|
99
|
-
@img[@img_index].draw @x.round
|
98
|
+
@img[@img_index].draw @x.round - (map ? map.cam.x : 0) + (flip == :horiz ? scale_x * @img[0].width : 0),
|
99
|
+
@y.round - (map ? map.cam.y : 0) + (flip == :vert ? scale_y * @img[0].height : 0),
|
100
|
+
z_index, (flip == :horiz ? -scale_x : scale_x),
|
101
|
+
(flip == :vert ? -scale_y : scale_y), color
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
@@ -180,22 +182,22 @@ module MiniGL
|
|
180
182
|
# will be darkened, for example.
|
181
183
|
# [angle] A rotation, in degrees, to be applied to the image, relative to
|
182
184
|
# its center.
|
185
|
+
# [flip] Specify +:horiz+ to draw the image horizontally flipped or +:vert+
|
186
|
+
# to draw it vertically flipped.
|
183
187
|
# [z_index] The z-order to draw the object. Objects with larger z-orders
|
184
188
|
# will be drawn on top of the ones with smaller z-orders.
|
185
|
-
def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, z_index = 0)
|
189
|
+
def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, flip = nil, z_index = 0)
|
186
190
|
color = (alpha << 24) | color
|
187
|
-
if
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
else
|
193
|
-
@img[@img_index].draw @x.round + @img_gap.x - map.cam.x, @y.round + @img_gap.y - map.cam.y, z_index, scale_x, scale_y, color
|
194
|
-
end
|
195
|
-
elsif angle
|
196
|
-
@img[@img_index].draw_rot @x.round + @img_gap.x, @y.round + @img_gap.y, z_index, angle, 0.5, 0.5, scale_x, scale_y, color
|
191
|
+
if angle
|
192
|
+
@img[@img_index].draw_rot @x.round + (flip == :horiz ? -1 : 1) * @img_gap.x - (map ? map.cam.x : 0) + (flip == :horiz ? scale_x * @w : 0),
|
193
|
+
@y.round + (flip == :vert ? -1 : 1) * @img_gap.y - (map ? map.cam.y : 0) + (flip == :vert ? scale_y * @h : 0),
|
194
|
+
z_index, angle, 0.5, 0.5, (flip == :horiz ? -scale_x : scale_x),
|
195
|
+
(flip == :vert ? -scale_y : scale_y), color
|
197
196
|
else
|
198
|
-
@img[@img_index].draw @x.round + @img_gap.x
|
197
|
+
@img[@img_index].draw @x.round + (flip == :horiz ? -1 : 1) * @img_gap.x - (map ? map.cam.x : 0) + (flip == :horiz ? scale_x * @w : 0),
|
198
|
+
@y.round + (flip == :vert ? -1 : 1) * @img_gap.y - (map ? map.cam.y : 0) + (flip == :vert ? scale_y * @h : 0),
|
199
|
+
z_index, (flip == :horiz ? -scale_x : scale_x),
|
200
|
+
(flip == :vert ? -scale_y : scale_y), color
|
199
201
|
end
|
200
202
|
end
|
201
203
|
|
data/lib/minigl/global.rb
CHANGED
@@ -215,8 +215,9 @@ module MiniGL
|
|
215
215
|
# Draws a rectangle with the size of the entire screen, in the given color.
|
216
216
|
#
|
217
217
|
# Parameters:
|
218
|
-
# [color] Color of the rectangle to be drawn.
|
218
|
+
# [color] Color of the rectangle to be drawn, in hexadecimal RRGGBB format.
|
219
219
|
def clear(color)
|
220
|
+
color |= 0xff000000
|
220
221
|
draw_quad 0, 0, color,
|
221
222
|
width, 0, color,
|
222
223
|
width, height, color,
|
@@ -375,7 +376,7 @@ module MiniGL
|
|
375
376
|
|
376
377
|
k1 = [Gosu::MsLeft, Gosu::MsMiddle, Gosu::MsRight]
|
377
378
|
k2 = [:left, :middle, :right]
|
378
|
-
|
379
|
+
(0..2).each do |i|
|
379
380
|
if G.window.button_down? k1[i]
|
380
381
|
@down[k2[i]] = true
|
381
382
|
@dbl_click[k2[i]] = true if @dbl_click_timer[k2[i]]
|
data/test/game.rb
CHANGED
@@ -7,6 +7,9 @@ class MyGame < GameWindow
|
|
7
7
|
|
8
8
|
@obj1 = GameObject.new 10, 10, 80, 80, :img1, Vector.new(-10, -10)
|
9
9
|
@obj2 = Sprite.new 400, 0, :img1
|
10
|
+
@obj3 = GameObject.new 4, 50, 24, 24, :check, Vector.new(-4, -4), 2, 4
|
11
|
+
@obj3.set_animation 1
|
12
|
+
@flip = nil
|
10
13
|
|
11
14
|
@font1 = Res.font :font1, 20
|
12
15
|
@font2 = Res.font :font1, 50
|
@@ -63,6 +66,10 @@ class MyGame < GameWindow
|
|
63
66
|
@obj1.x = Mouse.x + 10
|
64
67
|
@obj1.y = Mouse.y + 10
|
65
68
|
end
|
69
|
+
if Mouse.button_released? :right
|
70
|
+
if @flip.nil?; @flip = :horiz
|
71
|
+
else; @flip = nil; end
|
72
|
+
end
|
66
73
|
|
67
74
|
@btn.update
|
68
75
|
@chk.update
|
@@ -73,10 +80,11 @@ class MyGame < GameWindow
|
|
73
80
|
end
|
74
81
|
|
75
82
|
def draw
|
76
|
-
clear
|
83
|
+
clear 0xabcdef
|
77
84
|
|
78
85
|
@obj1.draw nil, 1, 1, 255, 0x33ff33, 30, 1
|
79
|
-
@obj2.draw nil, 0.6, 1.4, 0x99
|
86
|
+
@obj2.draw nil, 0.6, 1.4, 0x99, 0xffffff, nil, :vert
|
87
|
+
@obj3.draw nil, 1, 1, 255, 0xffffff, nil, @flip
|
80
88
|
@writer1.write_line 'Testing effect 1', 400, 260, :center, 0xffffff, :border
|
81
89
|
@writer2.write_line 'Second effect test', 400, 280, :center, 0xffffff, :border, 0xff0000, 2
|
82
90
|
@writer2.write_line 'Text with shadow!!', 400, 340, :center, 0xffff00, :shadow, 0, 2, 0x80
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minigl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor David Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|