rgss3 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 139cb21454b86af111586ecdef898ccf17598221
4
- data.tar.gz: 8abad362c2b9f1e5ed257f6111aff593dd54c2c0
3
+ metadata.gz: 823503b6d2d5eda418635f118dff31c22a704ec0
4
+ data.tar.gz: cbb6b1f25914822ee084ca80ae2e808fa93ec97e
5
5
  SHA512:
6
- metadata.gz: 48467765ea9118bd6acb7a6cb8ebdc71d349d523963d572a606cbe4535dc364240988f584cb1188a0e5a8afb696a5acdf49b8a50c57f7cf72c79529560d631ff
7
- data.tar.gz: 290e1826984ae211019d9f268007b372cbc822a0efb7f7918abc86c33392ec4af7013e786eb6316a326ece35988133f2be0989dab888652151f95e7119fd8714
6
+ metadata.gz: 5562562ffd51b8634689611588b551b76aea4c6a374f1a047facc666a5996a6368c2591571d7202408f98b10b533e7ecbb9bcb0c8775725eb522b9c110379af9
7
+ data.tar.gz: e2d0b5925f05edac8c30c542cd019ff8d1ccb0151c93957b5549495c2e8b5cb1c86e2e6551ad41ba93af4bb2984f5f644d212b1219456021e37379903a14b6df
data/lib/rgss3/bitmap.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  class Bitmap
3
3
 
4
- attr_reader :rect, :gosu_image
4
+ attr_reader :rect
5
5
  attr_accessor :font
6
6
 
7
7
  def initialize(*args)
@@ -29,11 +29,13 @@ class Bitmap
29
29
  end
30
30
 
31
31
  def init_other_attr
32
- @rect = Rect.new(0, 0, @gosu_image.width, @gosu_image.height)
32
+ @rect = Rect.new(0, 0, gosu_image.width, gosu_image.height)
33
33
  @font = Font.new
34
34
  end
35
35
 
36
36
  def dispose
37
+ @gosu_image = nil
38
+ @rmagick_image = nil
37
39
  @disposed = true
38
40
  end
39
41
 
@@ -42,27 +44,25 @@ class Bitmap
42
44
  end
43
45
 
44
46
  def width
45
- @gosu_image.width
47
+ gosu_image.width
46
48
  end
47
49
 
48
50
  def height
49
- @gosu_image.height
51
+ gosu_image.height
50
52
  end
51
53
 
52
- # untested
53
54
  def blt(x, y, src_bitmap, src_rect, opacity = 255)
54
55
  # opacity is not supported
55
56
  im2 = src_bitmap.gosu_image.subimage(*src_rect)
56
- @gosu_image.insert(im2, x, y)
57
+ gosu_image.insert(im2, x, y)
57
58
  set_dirty
58
59
  end
59
60
 
60
- # untested
61
61
  def stretch_blt(dest_rect, src_bitmap, src_rect, opacity = 255)
62
62
  im2 = src_bitmap.gosu_image.subimage(*src_rect)
63
63
  im2 = Bitmap.gosu_to_rmagick(gosu_to_rmagick)
64
64
  im2.resize!(dest_rect.width, dest_rect.height)
65
- @gosu_image.insert(im2, dest_rect.x, dest_rect.y)
65
+ gosu_image.insert(im2, dest_rect.x, dest_rect.y)
66
66
  set_dirty
67
67
  end
68
68
 
@@ -79,7 +79,7 @@ class Bitmap
79
79
  raise ArgumentError
80
80
  end
81
81
  img = Magick::Image.new(width, height) { self.background_color = color.to_rmagick_color }
82
- @gosu_image.insert(img, x, y)
82
+ gosu_image.insert(img, x, y)
83
83
  set_dirty
84
84
  end
85
85
 
@@ -107,7 +107,7 @@ class Bitmap
107
107
  fill = Magick::GradientFill.new(0, 0, x2, y2, start_color, end_color)
108
108
 
109
109
  img = Magick::Image.new(width, height, fill)
110
- @gosu_image.insert(img, x, y)
110
+ gosu_image.insert(img, x, y)
111
111
  set_dirty
112
112
  end
113
113
 
@@ -116,19 +116,7 @@ class Bitmap
116
116
  end
117
117
 
118
118
  def clear_rect(*args)
119
- case args.size
120
- when 1, 4
121
- if args[0].is_a?(Rect)
122
- x, y, width, height = *args[0].to_a
123
- else
124
- x, y, width, height = *args
125
- end
126
- else
127
- raise ArgumentError
128
- end
129
- f = Magick::Image.new(width, height) { self.background_color = 'none' }
130
- @gosu_image.insert(f, x, y)
131
- set_dirty
119
+ fill_rect(*args, Color.new)
132
120
  end
133
121
 
134
122
  def get_pixel(x, y)
@@ -139,7 +127,6 @@ class Bitmap
139
127
  fill_rect(x, y, 1, 1, color)
140
128
  end
141
129
 
142
- # Untested
143
130
  def hue_change(hue)
144
131
  image = rmagick_image
145
132
  Bitmap.pixel_map!(rmagick_image) do |pixel|
@@ -151,7 +138,6 @@ class Bitmap
151
138
  end
152
139
 
153
140
  def blur
154
- # self.rmagick_image = rmagick_image.blur_image
155
141
  end
156
142
 
157
143
  def radial_blur(angle, division)
@@ -180,7 +166,7 @@ class Bitmap
180
166
  end
181
167
  text_image = Gosu::Image.from_text(string, @font.size, font: @font.first_existant_name)
182
168
  x += (width - text_image.width) * (align || 0) / 2
183
- y += (height - text_image.height) / 2
169
+ y += (height - text_image.height) / 2
184
170
  text_image = Bitmap.gosu_to_rmagick(text_image)
185
171
  image = text_image.dup
186
172
  font_pixel = @font.color.to_pixel
@@ -214,12 +200,10 @@ class Bitmap
214
200
  end
215
201
 
216
202
  def text_size(string)
217
- f = Gosu::Font.new(@font.size, font: @font.first_existant_name)
218
- Rect.new(0, 0, f.text_width(string.to_s, f.height))
203
+ f = Gosu::Font.new(@font.size, name: @font.first_existant_name)
204
+ Rect.new(0, 0, f.text_width(string.to_s), f.height)
219
205
  end
220
206
 
221
- # NEW
222
-
223
207
  def self.from_gosu(img)
224
208
  bitmap = allocate
225
209
  bitmap.initialize_with_gosu_image(img)
@@ -228,7 +212,7 @@ class Bitmap
228
212
 
229
213
  def self.from_rmagick(img)
230
214
  bitmap = allocate
231
- bitmap.rmagick_image = img
215
+ bitmap.initialize_with_rmagick_image(img)
232
216
  bitmap
233
217
  end
234
218
 
@@ -253,6 +237,7 @@ class Bitmap
253
237
  # If you want to change it, call set_dirty or bitmap.rmagick_image = image
254
238
  # after the change.
255
239
  def rmagick_image
240
+ check_disposed
256
241
  if @dirty
257
242
  @dirty = false
258
243
  @rmagick_image = Bitmap.gosu_to_rmagick(@gosu_image)
@@ -261,26 +246,24 @@ class Bitmap
261
246
  end
262
247
  end
263
248
 
264
- def change_image
265
- @dirty = true
266
- end
267
-
268
- def check_disposed
269
- raise RGSSError, "Disposed Bitmap" if @disposed
270
- end
271
-
272
- def dispose!
273
- @gosu_image = nil
274
- @rmagick_image = nil
275
- @disposed = true
276
- end
277
-
278
249
  def rmagick_image=(image)
250
+ check_disposed
279
251
  @rmagick_image = image
280
252
  @gosu_image = Gosu::Image.new(@rmagick_image)
281
253
  end
282
254
 
255
+ def gosu_image
256
+ check_disposed
257
+ @gosu_image
258
+ end
259
+
283
260
  def set_dirty
284
261
  @dirty = true
285
262
  end
263
+
264
+ private
265
+
266
+ def check_disposed
267
+ raise RGSSError, "Disposed Bitmap" if @disposed
268
+ end
286
269
  end
@@ -2,7 +2,7 @@
2
2
  require 'fiber'
3
3
  module RGSS3
4
4
  class GameWindow < Gosu::Window
5
- attr_reader :frame_rate
5
+ attr_reader :frame_rate, :title
6
6
  def initialize(width: 544, height: 416, full_screen: false, frame_rate: 60, title: "Game", rtp: nil)
7
7
  @frame_rate = frame_rate
8
8
  RTP.path = rtp if rtp
@@ -20,5 +20,9 @@ module RGSS3
20
20
  def draw
21
21
  Graphics.draw
22
22
  end
23
+
24
+ def needs_redraw?
25
+ Graphics.needs_redraw
26
+ end
23
27
  end
24
28
  end
@@ -7,6 +7,7 @@ module Graphics
7
7
  attr_accessor :frame_count
8
8
  attr_reader :gosu_window
9
9
  attr_reader :brightness, :frame_rate
10
+ attr_reader :needs_redraw
10
11
 
11
12
  def gosu_window
12
13
  RGSS3.window
@@ -31,17 +32,20 @@ module Graphics
31
32
  @frame_count = 0
32
33
  @frozen = false
33
34
  @draw_color = Gosu::Color.rgba(255, 255, 255, 0)
34
- # @draw_color.saturation = 0
35
- # @draw_color.alpha = 0
36
35
  @containers = Set.new
37
36
 
38
37
  def self.update
39
- window = RGSS3.window
40
- @current = window.record(window.width, window.height) do
41
- @containers.each(&:draw)
42
- end
38
+ # window = RGSS3.window
39
+ # @current = window.record(window.width, window.height) do
40
+ # @containers.each(&:draw)
41
+ # end
43
42
  @frame_count += 1
44
- @latest = @current unless @frozen
43
+
44
+ unless @frozen
45
+ @needs_redraw = true
46
+ # @latest = @current
47
+ end
48
+
45
49
  Fiber.yield
46
50
  end
47
51
 
@@ -50,6 +54,7 @@ module Graphics
50
54
  end
51
55
 
52
56
  def self.fadeout(duration)
57
+ @brightness = 0
53
58
  # Thread.new {
54
59
  # rate = @brightness / duration.to_f
55
60
  # until @brightness <= 0
@@ -61,6 +66,7 @@ module Graphics
61
66
  end
62
67
 
63
68
  def self.fadein(duration)
69
+ @brightness = 255
64
70
  # Thread.new {
65
71
  # rate = 255 / duration.to_f
66
72
  # until @brightness >= 255
@@ -77,15 +83,15 @@ module Graphics
77
83
 
78
84
  def self.transition(duration = 10, filename = "", vague = 40)
79
85
  @frozen = false
80
- # VAGUE ELUDES ME AS TO HOW TO INTEGRATE
86
+ @brightness = 255
81
87
  end
82
88
 
83
89
  def self.snap_to_bitmap
84
- Bitmap.from_gosu(@current)
90
+ Bitmap.new(width, height)
85
91
  end
86
92
 
87
93
  def self.frame_reset
88
- # AT A LOSS ON HOW TO INTEGRATE
94
+ Fiber.yield
89
95
  end
90
96
 
91
97
  def self.width
@@ -97,11 +103,10 @@ module Graphics
97
103
  end
98
104
 
99
105
  def self.resize_screen(w, h)
100
- reform_window(w, h, fullscreen?, RGSS3.update_interval)
106
+ reform_window(w, h, RGSS3.window.fullscreen?, RGSS3.update_interval)
101
107
  end
102
108
 
103
109
  def self.play_movie(filename)
104
- # LIKELY TO REMAIN UNINTEGRATED
105
110
  end
106
111
 
107
112
  def self.add_container(container)
@@ -112,13 +117,10 @@ module Graphics
112
117
  @containers.delete(container)
113
118
  end
114
119
 
115
- def self.fullscreen?
116
- RGSS3.window.fullscreen?
117
- end
118
-
119
120
  def self.draw
120
- if @latest
121
- @latest.draw(0, 0, 0)
121
+ @needs_redraw = false
122
+ @containers.each(&:draw)
123
+ if @brightness < 255
122
124
  c = @draw_color
123
125
  RGSS3.window.draw_quad(0, 0, c, 0, height, c, width, 0, c, width, height, c, 1)
124
126
  end
@@ -130,8 +132,8 @@ module Graphics
130
132
  # end
131
133
 
132
134
  def self.reform_window(w, h, f, update_interval)
133
- # Graphics.gosu_window.close
134
- # Graphics.gosu_window = GosuGame.new(w, h, f, update_interval)
135
- # Graphics.gosu_window.show
135
+ Graphics.gosu_window.close
136
+ Graphics.gosu_window = GosuGame.new(w, h, f, update_interval)
137
+ Graphics.gosu_window.show
136
138
  end
137
139
  end
data/lib/rgss3/input.rb CHANGED
@@ -153,7 +153,8 @@ module Input
153
153
  dir
154
154
  end
155
155
  end
156
- return dir8, dir8 if [2, 4, 5, 6, 8].include?(dir8)
156
+ return 0, 0 if dir8 == 5
157
+ return dir8, dir8 if [2, 4, 6, 8].include?(dir8)
157
158
  return dir4, dir8
158
159
  end
159
160
  end
data/lib/rgss3/plane.rb CHANGED
@@ -3,7 +3,7 @@ require_relative 'sprite_container'
3
3
  class Plane
4
4
  include RGSS3::SpriteContainer
5
5
  def draw
6
- return if !@visible || @opacity == 0 || @bitmap == nil
6
+ return if !@visible || @opacity == 0 || @bitmap.nil? && @bitmap.disposed?
7
7
  @bitmap.gosu_image.draw(-@ox, -@oy, @z, 1, 1, 0xff_ffffff, BLEND[@blend_type])
8
8
  end
9
9
  end
data/lib/rgss3/sprite.rb CHANGED
@@ -24,13 +24,9 @@ class Sprite
24
24
  end
25
25
 
26
26
  def flash(color, duration)
27
- @flash_color = color || Color.new(0, 0, 0, 0)
28
- @duration = duration
29
27
  end
30
28
 
31
29
  def update
32
- @duration = [@duration - 1, 0].max
33
- @flash_color = nil if @duration == 0
34
30
  end
35
31
 
36
32
  def width
@@ -51,7 +47,8 @@ class Sprite
51
47
  end
52
48
 
53
49
  def draw
54
- return if !@visible || @opacity == 0 || @bitmap == nil
55
- @bitmap.gosu_image.draw_rot(@x, @y, @z, @angle, ox.fdiv(width), oy.fdiv(height), @zoom_x * (@mirror ? -1 : 1), @zoom_y, 0xffffffff, BLEND[@blend_type])
50
+ return if !@visible || @opacity == 0 || @bitmap.nil? || @bitmap.disposed?
51
+ image = @bitmap.gosu_image.subimage(*@src_rect) || @bitmap.gosu_image
52
+ image.draw_rot(@x, @y, @z, @angle, ox.fdiv(width), oy.fdiv(height), @zoom_x * (@mirror ? -1 : 1), @zoom_y, 0xffffffff, BLEND[@blend_type])
56
53
  end
57
54
  end
@@ -18,5 +18,10 @@ module RGSS3
18
18
  @color = Color.new
19
19
  super()
20
20
  end
21
+
22
+ def dispose
23
+ @bitmap = nil
24
+ super
25
+ end
21
26
  end
22
27
  end
data/lib/rgss3/tilemap.rb CHANGED
@@ -30,6 +30,31 @@ class Tilemap
30
30
  @layers[2].viewport = @viewport
31
31
  end
32
32
 
33
+ def map_data=(data)
34
+ return if @map_data == data
35
+ @map_data = data
36
+ refresh
37
+ end
38
+
39
+ def flags=(data)
40
+ @flags = data
41
+ refresh
42
+ end
43
+
44
+ def ox=(value)
45
+ @ox = value
46
+ for layer in @layers
47
+ layer.ox = @ox
48
+ end
49
+ end
50
+
51
+ def oy=(value)
52
+ @oy = value
53
+ for layer in @layers
54
+ layer.oy = @oy
55
+ end
56
+ end
57
+
33
58
  def dispose
34
59
  for layer in @layers
35
60
  layer.bitmap.dispose
@@ -50,6 +75,8 @@ class Tilemap
50
75
  @layers[0].bitmap = @animated_layer[@anim_count/30]
51
76
  end
52
77
 
78
+ private
79
+
53
80
  def refresh
54
81
  return if @map_data.nil? || @flags.nil?
55
82
  for layer in @layers
@@ -283,29 +310,4 @@ class Tilemap
283
310
  end
284
311
  end
285
312
  end
286
-
287
- def map_data=(data)
288
- return if @map_data == data
289
- @map_data = data
290
- refresh
291
- end
292
-
293
- def flags=(data)
294
- @flags = data
295
- refresh
296
- end
297
-
298
- def ox=(value)
299
- @ox = value
300
- for layer in @layers
301
- layer.ox = @ox
302
- end
303
- end
304
-
305
- def oy=(value)
306
- @oy = value
307
- for layer in @layers
308
- layer.oy = @oy
309
- end
310
- end
311
313
  end
data/lib/rgss3/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module RGSS3
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
@@ -22,6 +22,8 @@ class Viewport
22
22
  @z = 0
23
23
  @ox = 0
24
24
  @oy = 0
25
+ @color = Color.new
26
+ @tone = Tone.new
25
27
  end
26
28
 
27
29
  def dispose
@@ -33,12 +35,12 @@ class Viewport
33
35
  end
34
36
 
35
37
  def flash(color, duration)
36
- @flash_color = color || Color.new(0, 0, 0, 0)
37
- @flash_duration = duration
38
+ # @flash_color = color || Color.new(0, 0, 0, 0)
39
+ # @flash_duration = duration
38
40
  end
39
41
 
40
42
  def update
41
- @flash_duration = [@flash_duration - 1, 0].max
42
- @flash_color = nil if @flash_duration == 0
43
+ # @flash_duration = [@flash_duration - 1, 0].max
44
+ # @flash_color = nil if @flash_duration == 0
43
45
  end
44
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgss3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - taroxd