minigl 2.3.7 → 2.3.8
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.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/minigl/game_object.rb +20 -6
- data/lib/minigl/text.rb +25 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a080b868fab24c01aaa591dcb2c5b087cc2b1bd4a86b1a649691a5e53aaa27e4
|
4
|
+
data.tar.gz: 117867b84b262cbc6d30adb68e0756d9d3e62246ae9fb57cd03377cc564339ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c1ee1a615f081b4c6b36b547c7a187553cdf91aa5f7026c35b9d6e2087d9c9b461f2b60f37f56ce20739080be5277ee99f6b4f01bc50578c6887fc18c2cbbe8
|
7
|
+
data.tar.gz: c000b6516264435786de8bc90858d644cbb1938128d984fd4c75938593514b07585651a5b8363e65ebbda415c151b028c934284f65e1b14cae7b3435a5bb92b5
|
data/README.md
CHANGED
@@ -17,10 +17,10 @@ to victordavidsantos@gmail.com.
|
|
17
17
|
## Made with MiniGL
|
18
18
|
|
19
19
|
Below are two full games built with MiniGL, both available for free download and also open source.
|
20
|
-
* [Super Bombinhas](https://
|
21
|
-
* [ConnecMan](https://
|
20
|
+
* [Super Bombinhas](https://github.com/victords/super-bombinhas)
|
21
|
+
* [ConnecMan](https://github.com/victords/connecman)
|
22
22
|
|
23
|
-
|
23
|
+
If you create a project using MiniGL, feel free to open a PR to include it in this list.
|
24
24
|
|
25
25
|
## Installing
|
26
26
|
|
@@ -37,10 +37,10 @@ After installing the Gosu dependencies, you can just `gem install minigl`.
|
|
37
37
|
* The [wiki](https://github.com/victords/minigl/wiki) is a work in progress with tutorials and examples.
|
38
38
|
* Test package and examples aren't complete!
|
39
39
|
|
40
|
-
## Version 2.3.
|
40
|
+
## Version 2.3.8
|
41
41
|
|
42
|
-
* Exposed
|
43
|
-
*
|
42
|
+
* Exposed `Effect`'s `lifetime`, `elapsed_time` and `time_left` properties.
|
43
|
+
* Added the `char_spacing` parameter to the `ImageFont` class and exposed some existing properties.
|
44
44
|
|
45
45
|
## Contributing
|
46
46
|
|
data/lib/minigl/game_object.rb
CHANGED
@@ -304,6 +304,14 @@ module MiniGL
|
|
304
304
|
# This is +true+ when the effect's lifetime has already passed.
|
305
305
|
attr_reader :dead
|
306
306
|
|
307
|
+
# The lifetime of the effect, in updates, i.e., how many calls to +update+
|
308
|
+
# must happen before the effect is marked as +dead+, since its creation.
|
309
|
+
attr_reader :lifetime
|
310
|
+
|
311
|
+
# The number of times +update+ has been called for this effect, while it
|
312
|
+
# was still active (not +dead+).
|
313
|
+
attr_reader :elapsed_time
|
314
|
+
|
307
315
|
# Creates a new Effect.
|
308
316
|
#
|
309
317
|
# Parameters:
|
@@ -352,7 +360,7 @@ module MiniGL
|
|
352
360
|
end
|
353
361
|
|
354
362
|
super x, y, img, sprite_cols, sprite_rows
|
355
|
-
@
|
363
|
+
@elapsed_time = 0
|
356
364
|
if indices
|
357
365
|
@indices = indices
|
358
366
|
else
|
@@ -369,15 +377,21 @@ module MiniGL
|
|
369
377
|
|
370
378
|
# Updates the effect, animating and counting its remaining lifetime.
|
371
379
|
def update
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
380
|
+
return if @dead
|
381
|
+
|
382
|
+
animate(@indices, @interval)
|
383
|
+
@elapsed_time += 1
|
384
|
+
@dead = true if @elapsed_time == @lifetime
|
377
385
|
end
|
378
386
|
|
379
387
|
def draw(map = nil, scale_x = 1, scale_y = 1, alpha = 0xff, color = 0xffffff, angle = nil, z_index = 0)
|
380
388
|
super unless @dead
|
381
389
|
end
|
390
|
+
|
391
|
+
# The remaining number of calls to +update+ until the effect is marked
|
392
|
+
# +dead+.
|
393
|
+
def time_left
|
394
|
+
@lifetime - @elapsed_time
|
395
|
+
end
|
382
396
|
end
|
383
397
|
end
|
data/lib/minigl/text.rb
CHANGED
@@ -11,9 +11,18 @@ module MiniGL
|
|
11
11
|
# if a character fits in the current line it must not be placed in the next
|
12
12
|
# one. In the last line there can be any amount of free space at the end.
|
13
13
|
class ImageFont
|
14
|
+
# A string containing the characters supported by this font.
|
15
|
+
attr_reader :chars
|
16
|
+
|
14
17
|
# The height of this font in pixels.
|
15
18
|
attr_reader :height
|
16
19
|
|
20
|
+
# The width of the white space character in this font, in pixels.
|
21
|
+
attr_reader :space_width
|
22
|
+
|
23
|
+
# The spacing between characters, in pixels (can be a decimal number).
|
24
|
+
attr_reader :char_spacing
|
25
|
+
|
17
26
|
# Creates an +ImageFont+.
|
18
27
|
#
|
19
28
|
# Parameters:
|
@@ -26,16 +35,19 @@ module MiniGL
|
|
26
35
|
# as they appear in the +chars+ string.
|
27
36
|
# [height] The height of the lines in the image (see description above).
|
28
37
|
# [space_width] The width of the white space character in this font.
|
38
|
+
# [char_spacing] The spacing between non-white-space characters when writing text with
|
39
|
+
# this font. It can be a decimal number, useful when scaling the text up.
|
29
40
|
# [global] Parameter that will be passed to +Res.img+ when loading the image.
|
30
41
|
# [ext] Parameter that will be passed to +Res.img+ when loading the image.
|
31
42
|
# [retro] Parameter that will be passed to +Res.img+ when loading the image.
|
32
|
-
def initialize(img_path, chars, widths, height, space_width, global = true, ext = '.png', retro = nil)
|
43
|
+
def initialize(img_path, chars, widths, height, space_width, char_spacing = 0, global = true, ext = '.png', retro = nil)
|
33
44
|
retro = Res.retro_images if retro.nil?
|
34
45
|
img = Res.img(img_path, global, false, ext, retro)
|
35
46
|
@chars = chars
|
36
47
|
@images = []
|
37
48
|
@height = height
|
38
49
|
@space_width = space_width
|
50
|
+
@char_spacing = char_spacing
|
39
51
|
wa = widths.is_a?(Array)
|
40
52
|
if wa && widths.length != chars.length
|
41
53
|
raise 'Wrong widths array size!'
|
@@ -60,7 +72,17 @@ module MiniGL
|
|
60
72
|
# Parameters:
|
61
73
|
# [text] The string to be measured
|
62
74
|
def markup_width(text)
|
63
|
-
|
75
|
+
w = 0
|
76
|
+
text.chars.each_with_index do |c, i|
|
77
|
+
if c == ' '
|
78
|
+
w += @space_width
|
79
|
+
else
|
80
|
+
idx = @chars.index(c)
|
81
|
+
w += idx ? @images[idx].width : 0
|
82
|
+
w += @char_spacing if i < text.chars.size - 1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
w
|
64
86
|
end
|
65
87
|
|
66
88
|
# See <code>Gosu::Font#draw_markup_rel</code> for details.
|
@@ -82,7 +104,7 @@ module MiniGL
|
|
82
104
|
i = @chars.index(c)
|
83
105
|
next if i.nil?
|
84
106
|
@images[i].draw(x, y, z, scale_x, scale_y, color)
|
85
|
-
x += scale_x * @images[i].width
|
107
|
+
x += (scale_x * (@images[i].width + @char_spacing)).round
|
86
108
|
end
|
87
109
|
end
|
88
110
|
|
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.3.
|
4
|
+
version: 2.3.8
|
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:
|
11
|
+
date: 2022-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|