or2d 0.0.1.pre.rc1 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf0597361e53518e19601f4e1a17341d5bcba4a55eb76541f6b7c228c32222ec
4
- data.tar.gz: 8e83ff4280a96860f70ad048b5f41d786ed80fd1d87bb480679d5fe51be00c03
3
+ metadata.gz: d549bc286d1ed32b29b3c09acb3490e373568eb8505895f6453287289a204261
4
+ data.tar.gz: 0a031f2fe7d9f0316388952ddff86c0adc4dfaf06d00368432e6c30b73a46468
5
5
  SHA512:
6
- metadata.gz: 839294376a8000552136d439f56f7043b0398cfe5a1c20a0fe19093bd8fc984ca105db82dd08437b28266690b507914a1fb65fdd1db025afe747efbafdd58661
7
- data.tar.gz: a648146556ab88b70f614bc6b6559cf292352b366d04ce2c7504f479d8699d378f1e04bd107a7e049100ac993d853df63c0039b13245b8279d3238fb3ddb5ede
6
+ metadata.gz: bb2eac9fbac591a5398821fda5dee6e94fb45f25cb8624999d2c0fe67feadee62efee3b1e02051655fc7d3a1c5ecdbf7ffd8a431ffbb38323bae81bc093ed1ce
7
+ data.tar.gz: 3a6166a5d9ccbb2359bb3026efced1e30696c40506354a0725db510057b76f32efcb0733c96b6935c29aae4b28083b776b3b1c6c509c643c4ca7baffec70b16c
@@ -39,6 +39,16 @@ module OR2D
39
39
  OR2D.game.remove_entity(id)
40
40
  end
41
41
 
42
+ def each_layer(&block)
43
+ @layers.each(&block)
44
+ end
45
+
46
+ def toggle_boundary
47
+ @layers.each_key do |key|
48
+ OR2D.game.entities[key].toggle_boundary
49
+ end
50
+ end
51
+
42
52
  # Show the Composite object.
43
53
  def show
44
54
  @layers.each do |id, properties|
data/lib/or2d/console.rb CHANGED
@@ -18,17 +18,16 @@ module OR2D
18
18
  height: (OR2D.game.window.get(:height) / 2),
19
19
  color: 'green', opacity: 0.25)
20
20
  OR2D.game.window.add(@boundary)
21
- @properties = { input_size: (8 * OR2D.scale), output_size: (4 * OR2D.scale), max_length: options[:max_length] || 24 }
22
- @properties[:max_lines] = (@boundary.height / (@properties[:output_size] * OR2D.scale)).to_i - @properties[:output_size]
23
-
21
+ @properties = { input_size: 8.scale, output_size: 4.scale, max_length: options[:max_length] || 24 }
22
+ @properties[:max_lines] = (@boundary.height / @properties[:output_size].scale).to_i - @properties[:output_size]
24
23
 
25
24
  @prompt = options[:prompt] || '>> '
26
25
  @buffer = String.new
27
26
  @display = OR2D::Composites::Text.new
28
27
  @display.add_line(text: 'OR2D Console', color: 'yellow', size: @properties[:output_size],
29
- x: @boundary.x + 16, y: @boundary.y + (16 * OR2D.scale), z: @boundary.z + 1)
28
+ x: @boundary.x + 16, y: @boundary.y + 16.scale, z: @boundary.z + 1)
30
29
  @input = OR2D::Entity.new(:text, { text: @prompt, color: 'white',
31
- x: @boundary.x + 16, y: (@boundary.y + @boundary.height) - (16 * OR2D.scale),
30
+ x: @boundary.x + 16, y: (@boundary.y + @boundary.height) - 16.scale,
32
31
  z: @boundary.z + 1, size: @properties[:input_size],
33
32
  show: true })
34
33
  @state = State.new(:RETRACTED, false, false)
@@ -62,7 +61,7 @@ module OR2D
62
61
  @state.drawn = false
63
62
  end
64
63
  when :PULL_DOWN
65
- if @boundary.y <= -16 * OR2D.scale
64
+ if @boundary.y <= -16.scale
66
65
  @boundary.y += 16
67
66
  @input.y += 16
68
67
  @display.y += 16 unless @display.empty?
@@ -157,8 +156,8 @@ module OR2D
157
156
  puts e.backtrace
158
157
  end
159
158
 
160
- @display.add_line(text: "#{@buffer} #=> #{output}",
161
- size: @properties[:output_size],
159
+ @display.add_line(text: "#{@buffer} #=> #{output}",
160
+ size: @properties[:output_size],
162
161
  color: 'white',
163
162
  show: true)
164
163
  @buffer.clear
data/lib/or2d/entity.rb CHANGED
@@ -20,8 +20,8 @@ module OR2D
20
20
  def initialize(type, options = {})
21
21
  super(x: options[:x] || 0,
22
22
  y: options[:y] || 0,
23
- width: options[:width].nil? ? 1 : options[:width] * OR2D.scale,
24
- height: options[:height].nil? ? 1 : options[:height] * OR2D.scale,
23
+ width: options[:width].nil? ? 1 : options[:width].scale,
24
+ height: options[:height].nil? ? 1 : options[:height].scale,
25
25
  opacity: options[:show_boundary] ? 0.55 : 0.0,
26
26
  color: 'green')
27
27
  @id = options[:id] || SecureRandom.uuid
@@ -56,6 +56,10 @@ module OR2D
56
56
  end
57
57
  end
58
58
 
59
+ def contains?(x, y)
60
+ (@x1..@x2).cover?(x) && (@y1..@y4).cover?(y)
61
+ end
62
+
59
63
  # Show the entity on the game instance window.
60
64
  def show
61
65
  OR2D.game.window.add(self)
data/lib/or2d/instance.rb CHANGED
@@ -181,6 +181,5 @@ module OR2D
181
181
  puts "An error occurred while processing the current scene: #{e.message}"
182
182
  puts e.backtrace if OR2D.debug?
183
183
  end
184
-
185
184
  end
186
185
  end
@@ -0,0 +1,5 @@
1
+ class Float
2
+ def scale
3
+ self * OR2D.scale.to_f
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class Integer
2
+
3
+ # Scale the integer by the game window's scale.
4
+ def scale
5
+ self * OR2D.scale
6
+ end
7
+ end
data/lib/or2d/resource.rb CHANGED
@@ -41,8 +41,8 @@ module OR2D::Resource
41
41
  def create_image(options)
42
42
  Ruby2D::Image.new(options[:path],
43
43
  atlas: options[:atlas],
44
- width: options[:width] * OR2D.scale || 4,
45
- height: options[:height] * OR2D.scale || 4,
44
+ width: options[:width].scale || 4,
45
+ height: options[:height].scale || 4,
46
46
  opacity: options[:opacity] || 1.0,
47
47
  rotate: options[:rotate] || 0,
48
48
  x: options[:x] || 0,
@@ -58,8 +58,8 @@ module OR2D::Resource
58
58
  y1: options[:y1],
59
59
  x2: options[:x2],
60
60
  y2: options[:y2],
61
- z: options[:z],
62
- width: options[:width] * OR2D.scale || 2,
61
+ z: options[:z] || 0,
62
+ width: options[:width].scale || 2,
63
63
  color: options[:color] || 'yellow',
64
64
  opacity: options[:opacity] || 1.0)
65
65
  end
@@ -71,8 +71,8 @@ module OR2D::Resource
71
71
  Ruby2D::Rectangle.new(x: options[:x] || 0,
72
72
  y: options[:y] || 0,
73
73
  z: options[:z] || 0,
74
- width: options[:width] * OR2D.scale,
75
- height: options[:height] * OR2D.scale,
74
+ width: options[:width].scale,
75
+ height: options[:height].scale,
76
76
  color: options[:color] || 'yellow',
77
77
  opacity: options[:opacity] || 1.0)
78
78
  end
@@ -83,8 +83,8 @@ module OR2D::Resource
83
83
  def create_sprite(options)
84
84
  Ruby2D::Sprite.new(options[:path],
85
85
  atlas: options[:atlas],
86
- width: options[:width] ? options[:width] * OR2D.scale : nil,
87
- height: options[:height] ? options[:height] * OR2D.scale : nil,
86
+ width: options[:width] ? options[:width].scale : nil,
87
+ height: options[:height] ? options[:height].scale : nil,
88
88
  rotate: options[:rotate] || 0,
89
89
  opacity: options[:opacity] || 1.0,
90
90
  loop: options[:loop] || false,
@@ -120,7 +120,7 @@ module OR2D::Resource
120
120
  x: options[:x] || 0,
121
121
  y: options[:y] || 0,
122
122
  z: options[:z] || 0,
123
- size: (options[:size] || 16) * OR2D.scale,
123
+ size: (options[:size] || 16).scale,
124
124
  style: options[:style],
125
125
  font: options[:font] || Ruby2D::Font.default,
126
126
  color: options[:color] || 'yellow',
data/lib/or2d/scene.rb CHANGED
@@ -96,6 +96,11 @@ module OR2D
96
96
  Fiber.yield
97
97
  end
98
98
 
99
+ def clear_descriptors
100
+ @descriptors.each_value { |descriptor| OR2D.game.window.off(descriptor) }
101
+ @descriptors.clear
102
+ end
103
+
99
104
  # Setup event descriptors.
100
105
  def setup_descriptor(label, event, &block)
101
106
  @descriptors[label] = OR2D.game.window.on(event, &block)
@@ -42,7 +42,7 @@ module OR2D::Scenes
42
42
  def setup_events
43
43
  setup_descriptor(:mouse_input, :mouse) do |event|
44
44
  @cursor_position.resource.text = "[x: #{event.x}, y: #{event.y}]"
45
- @cursor_position.width = @cursor_position.resource.text.length * (6 * OR2D.scale)
45
+ @cursor_position.width = @cursor_position.resource.text.length * 6.scale
46
46
  end
47
47
 
48
48
  setup_descriptor(:debug_input, :key_up) do |event|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: or2d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.rc1
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick W.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-18 00:00:00.000000000 Z
11
+ date: 2023-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.8.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '2.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: ruby2d
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +44,20 @@ dependencies:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: 0.12.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '5.18'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '5.18'
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: rake
43
63
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +100,20 @@ dependencies:
80
100
  - - "~>"
81
101
  - !ruby/object:Gem::Version
82
102
  version: '1.42'
103
+ - !ruby/object:Gem::Dependency
104
+ name: simplecov
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.22'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.22'
83
117
  - !ruby/object:Gem::Dependency
84
118
  name: yard
85
119
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +145,8 @@ files:
111
145
  - lib/or2d/console.rb
112
146
  - lib/or2d/entity.rb
113
147
  - lib/or2d/instance.rb
148
+ - lib/or2d/patches/float.rb
149
+ - lib/or2d/patches/integer.rb
114
150
  - lib/or2d/patches/music.rb
115
151
  - lib/or2d/patches/renderable.rb
116
152
  - lib/or2d/patches/sound.rb
@@ -134,9 +170,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
170
  version: 3.1.0
135
171
  required_rubygems_version: !ruby/object:Gem::Requirement
136
172
  requirements:
137
- - - ">"
173
+ - - ">="
138
174
  - !ruby/object:Gem::Version
139
- version: 1.3.1
175
+ version: '0'
140
176
  requirements: []
141
177
  rubygems_version: 3.4.10
142
178
  signing_key: