minigl 2.5.1 → 2.5.3
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 +2 -6
- data/lib/minigl/movement.rb +2 -2
- data/lib/minigl/particles.rb +23 -10
- data/test/particles_game.rb +8 -10
- 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: 68211fceca8d7ae8aa416937945fad5b0bb38472921934a91043be0c9b1b9bae
|
|
4
|
+
data.tar.gz: d1bcd43819bac3ea5cd6350cb60dee47ea0061ca3e6c8630c8d6e38875c54b50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7649c55704a2313667656b52be2c07b51b40db3315bc56b8ece91917e866dec0c193becb3c4b9f6223d73f2ba9b4b33a43cfb77def99ccad06c8b78ab8602328
|
|
7
|
+
data.tar.gz: fa0e240e39c69abf95b450d2aa474f5520c8898df93c7539743e9f6da7a06964c827951f204d61d50f2a15ad7b9de133796458173ca7a80c326a9e94b39b29f9
|
data/README.md
CHANGED
|
@@ -43,13 +43,9 @@ After installing the Gosu dependencies, you can just `gem install minigl`.
|
|
|
43
43
|
* The [wiki](https://github.com/victords/minigl/wiki) is a work in progress with tutorials and examples.
|
|
44
44
|
* Test package and examples aren't complete!
|
|
45
45
|
|
|
46
|
-
## Version 2.5.
|
|
46
|
+
## Version 2.5.3
|
|
47
47
|
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
### Version 2.5.1
|
|
51
|
-
|
|
52
|
-
Patch fixing the required Ruby version (>= 3.1).
|
|
48
|
+
* Fixed small collision bug in `Movement#move`.
|
|
53
49
|
|
|
54
50
|
## Contributing
|
|
55
51
|
|
data/lib/minigl/movement.rb
CHANGED
|
@@ -526,7 +526,7 @@ module MiniGL
|
|
|
526
526
|
end
|
|
527
527
|
end
|
|
528
528
|
|
|
529
|
-
|
|
529
|
+
private
|
|
530
530
|
|
|
531
531
|
def check_contact(obst, ramps)
|
|
532
532
|
prev_bottom = @bottom
|
|
@@ -578,7 +578,7 @@ module MiniGL
|
|
|
578
578
|
def find_down_limit(coll_list)
|
|
579
579
|
limit = @y + @h + @speed.y
|
|
580
580
|
coll_list.each do |c|
|
|
581
|
-
limit = c.y if c.y < limit && c.y >= @y + @h
|
|
581
|
+
limit = c.y if c.y < limit && (!c.passable || c.y >= @y + @h)
|
|
582
582
|
end
|
|
583
583
|
limit
|
|
584
584
|
end
|
data/lib/minigl/particles.rb
CHANGED
|
@@ -3,13 +3,18 @@ module MiniGL
|
|
|
3
3
|
class Particles
|
|
4
4
|
# Create a new particle system.
|
|
5
5
|
# Options:
|
|
6
|
-
# - x: x-coordinate of the origin of the particle system. If
|
|
7
|
-
# set, it has precedence.
|
|
8
|
-
# - y: y-coordinate of the origin of the particle system. If
|
|
9
|
-
# set, it has precedence.
|
|
6
|
+
# - x (Numeric): x-coordinate of the origin of the particle system. If
|
|
7
|
+
# +source+ is set, it has precedence.
|
|
8
|
+
# - y (Numeric): y-coordinate of the origin of the particle system. If
|
|
9
|
+
# +source+ is set, it has precedence.
|
|
10
10
|
# - source: if set, must be an object that responds to +x+ and +y+. The
|
|
11
|
-
# position of the particle system will be updated to
|
|
12
|
-
#
|
|
11
|
+
# position of the particle system will be updated to <code>(source.x
|
|
12
|
+
# + source_offset_x, source.y + source_offset_y)</code> on initialization
|
|
13
|
+
# and every time +update+ is called.
|
|
14
|
+
# - source_offset_x (Numeric): horizontal offset relative to the +source+
|
|
15
|
+
# where the particle system will be positioned. Default: 0.
|
|
16
|
+
# - source_offset_y (Numeric): vertical offset relative to the +source+
|
|
17
|
+
# where the particle system will be positioned. Default: 0.
|
|
13
18
|
# - emission_interval (Integer|Range): interval in frames between each
|
|
14
19
|
# particle emission. It can be a fixed value or a range, in which case
|
|
15
20
|
# the interval will be a random value within that range (a new value
|
|
@@ -64,8 +69,8 @@ module MiniGL
|
|
|
64
69
|
raise "Particles must have either a shape or an image!" if options[:shape].nil? && options[:img].nil?
|
|
65
70
|
|
|
66
71
|
@options = DEFAULT_OPTIONS.merge(options)
|
|
67
|
-
@x = @options[:source]&.x || @options[:x]
|
|
68
|
-
@y = @options[:source]&.y || @options[:y]
|
|
72
|
+
@x = (@options[:source]&.x || @options[:x]) + @options[:source_offset_x]
|
|
73
|
+
@y = (@options[:source]&.y || @options[:y]) + @options[:source_offset_y]
|
|
69
74
|
|
|
70
75
|
@particles = []
|
|
71
76
|
@emitting = false
|
|
@@ -87,6 +92,12 @@ module MiniGL
|
|
|
87
92
|
@emitting = false
|
|
88
93
|
end
|
|
89
94
|
|
|
95
|
+
# Changes particle system origin to <code>(x, y)</code>.
|
|
96
|
+
def move_to(x, y)
|
|
97
|
+
@x = x
|
|
98
|
+
@y = y
|
|
99
|
+
end
|
|
100
|
+
|
|
90
101
|
# Returns a boolean indicating whether this particle system is currently
|
|
91
102
|
# emitting particles.
|
|
92
103
|
def emitting?
|
|
@@ -108,8 +119,8 @@ module MiniGL
|
|
|
108
119
|
return unless @emitting
|
|
109
120
|
|
|
110
121
|
if @options[:source]
|
|
111
|
-
@x = @options[:source].x
|
|
112
|
-
@y = @options[:source].y
|
|
122
|
+
@x = @options[:source].x + @options[:source_offset_x]
|
|
123
|
+
@y = @options[:source].y + @options[:source_offset_y]
|
|
113
124
|
end
|
|
114
125
|
|
|
115
126
|
@timer += 1
|
|
@@ -148,6 +159,8 @@ module MiniGL
|
|
|
148
159
|
x: 0,
|
|
149
160
|
y: 0,
|
|
150
161
|
source: nil,
|
|
162
|
+
source_offset_x: 0,
|
|
163
|
+
source_offset_y: 0,
|
|
151
164
|
emission_interval: 10,
|
|
152
165
|
emission_rate: 1,
|
|
153
166
|
duration: 30,
|
data/test/particles_game.rb
CHANGED
|
@@ -3,21 +3,14 @@ require_relative '../lib/minigl'
|
|
|
3
3
|
include MiniGL
|
|
4
4
|
|
|
5
5
|
class MyGame < GameWindow
|
|
6
|
-
class Source
|
|
7
|
-
attr_accessor :x, :y
|
|
8
|
-
|
|
9
|
-
def initialize(x, y)
|
|
10
|
-
@x = x
|
|
11
|
-
@y = y
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
6
|
def initialize
|
|
16
7
|
super(800, 600, false)
|
|
17
|
-
@source =
|
|
8
|
+
@source = Sprite.new(100, 100, :btn)
|
|
18
9
|
@particles_systems = [
|
|
19
10
|
Particles.new(
|
|
20
11
|
source: @source,
|
|
12
|
+
source_offset_x: 50,
|
|
13
|
+
source_offset_y: 120,
|
|
21
14
|
img: Res.img(:square),
|
|
22
15
|
duration: 30,
|
|
23
16
|
spread: 50,
|
|
@@ -59,10 +52,15 @@ class MyGame < GameWindow
|
|
|
59
52
|
end
|
|
60
53
|
end
|
|
61
54
|
|
|
55
|
+
if KB.key_pressed?(Gosu::KB_Q)
|
|
56
|
+
@particles_systems[1].move_to(50, 500)
|
|
57
|
+
end
|
|
58
|
+
|
|
62
59
|
@particles_systems.each(&:update)
|
|
63
60
|
end
|
|
64
61
|
|
|
65
62
|
def draw
|
|
63
|
+
@source.draw
|
|
66
64
|
@particles_systems.each(&:draw)
|
|
67
65
|
end
|
|
68
66
|
end
|
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.5.
|
|
4
|
+
version: 2.5.3
|
|
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: 2024-02-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gosu
|