rgss3 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 823503b6d2d5eda418635f118dff31c22a704ec0
4
- data.tar.gz: cbb6b1f25914822ee084ca80ae2e808fa93ec97e
3
+ metadata.gz: 270c6dc805cba951ea8ba997927604c1f3750677
4
+ data.tar.gz: 94c70bf2f2f7cc6006fe1190d73ea5410826065f
5
5
  SHA512:
6
- metadata.gz: 5562562ffd51b8634689611588b551b76aea4c6a374f1a047facc666a5996a6368c2591571d7202408f98b10b533e7ecbb9bcb0c8775725eb522b9c110379af9
7
- data.tar.gz: e2d0b5925f05edac8c30c542cd019ff8d1ccb0151c93957b5549495c2e8b5cb1c86e2e6551ad41ba93af4bb2984f5f644d212b1219456021e37379903a14b6df
6
+ metadata.gz: a15e21a2a1916cfa00d67b72a6b21c69103d2d927519e5bbd9dc5389891860a26cb614cd177dd875ebe74dcd73aaf52d2fbe95213b3df838b90c593b7d45e461
7
+ data.tar.gz: 34b9e551db4ff2a53f01b19afeed541648fc3b2e8f7f56363adf449a911bfda20fb7419b561b2bdf2822452b4c02412403dc099fed84d8915d3d3f9f774c811f
data/README.md CHANGED
@@ -30,8 +30,7 @@ end
30
30
  Or with more options:
31
31
  ```ruby
32
32
  require 'rgss3'
33
- RGSS3::RTP.path = 'path/to/RTP'
34
- RGSS3.run(width: 544, height: 416, frame_rate: 60, title: 'Game', rtp: 'path/to/rtp') do
33
+ RGSS3.run(width: 544, height: 416, frame_rate: 60, fullscreen: false, title: 'Game', rtp: 'path/to/rtp') do
35
34
  # TODO: Add your code here
36
35
  # loop { Graphics.update }
37
36
  end
@@ -52,17 +52,33 @@ class Bitmap
52
52
  end
53
53
 
54
54
  def blt(x, y, src_bitmap, src_rect, opacity = 255)
55
- # opacity is not supported
56
- im2 = src_bitmap.gosu_image.subimage(*src_rect)
57
- gosu_image.insert(im2, x, y)
55
+ return if opacity == 0
56
+ src = src_bitmap.gosu_image.subimage(*src_rect)
57
+ if opacity != 255
58
+ src = Bitmap.gosu_to_rmagick(src)
59
+ ratio = opacity / 255.0
60
+ Bitmap.pixel_map!(src) do |pixel|
61
+ pixel.opacity *= ratio
62
+ pixel
63
+ end
64
+ end
65
+ gosu_image.insert(src, x, y)
58
66
  set_dirty
59
67
  end
60
68
 
61
69
  def stretch_blt(dest_rect, src_bitmap, src_rect, opacity = 255)
62
- im2 = src_bitmap.gosu_image.subimage(*src_rect)
63
- im2 = Bitmap.gosu_to_rmagick(gosu_to_rmagick)
64
- im2.resize!(dest_rect.width, dest_rect.height)
65
- gosu_image.insert(im2, dest_rect.x, dest_rect.y)
70
+ return if opacity == 0
71
+ src = src_bitmap.gosu_image.subimage(*src_rect)
72
+ src = Bitmap.gosu_to_rmagick(gosu_to_rmagick)
73
+ src.resize!(dest_rect.width, dest_rect.height)
74
+ if opacity != 255
75
+ ratio = opacity / 255.0
76
+ Bitmap.pixel_map!(src) do |pixel|
77
+ pixel.opacity *= ratio
78
+ pixel
79
+ end
80
+ end
81
+ gosu_image.insert(src, dest_rect.x, dest_rect.y)
66
82
  set_dirty
67
83
  end
68
84
 
@@ -112,7 +128,7 @@ class Bitmap
112
128
  end
113
129
 
114
130
  def clear
115
- self.rmagick_image = Magick::Image.new(width, height)
131
+ self.rmagick_image = Magick::Image.new(width, height) { self.background_color = 'none' }
116
132
  end
117
133
 
118
134
  def clear_rect(*args)
@@ -1,20 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
  module RGSS3
3
- # common methods for Plane, Sprite and Window
3
+ # common methods for Plane, Sprite
4
4
  module Container
5
5
 
6
- attr_reader :opacity
7
6
  attr_accessor :z, :ox, :oy
8
7
  attr_accessor :viewport, :visible
9
8
  attr_accessor :tone
9
+ attr_accessor :zoom_x, :zoom_y
10
+ attr_accessor :bitmap
11
+ attr_accessor :color, :blend_type
12
+ attr_reader :opacity
10
13
 
11
- def initialize
14
+ BLEND = {0 => :default, 1 => :additive, 2 => :subtractive}
15
+
16
+ def initialize(viewport = nil)
12
17
  @visible = true
13
18
  @z = 0
14
19
  @ox = 0
15
20
  @oy = 0
16
- @opacity = 255
17
21
  @tone = Tone.new
22
+ @viewport = viewport
23
+ @zoom_x = @zoom_y = 1.0
24
+ @blend_type = 0
25
+ @color = Color.new
26
+ @opacity = 255
18
27
  Graphics.add_container(self)
19
28
  end
20
29
 
@@ -26,6 +35,7 @@ module RGSS3
26
35
 
27
36
  def dispose
28
37
  @disposed = true
38
+ @bitmap = nil
29
39
  Graphics.remove_container(self)
30
40
  end
31
41
 
@@ -33,11 +43,18 @@ module RGSS3
33
43
  @disposed
34
44
  end
35
45
 
36
- def opacity=(int)
37
- @opacity = [[int, 255].min, 0].max
46
+ def opacity=(value)
47
+ @opacity = [[value, 0].max, 255].min
38
48
  end
39
49
 
50
+ # overwrite
40
51
  def draw
41
52
  end
53
+
54
+ # this method is used internally by Graphics
55
+ def do_draw
56
+ return if !@visible || @opacity == 0 || @bitmap.nil? || @bitmap.disposed?
57
+ draw
58
+ end
42
59
  end
43
60
  end
@@ -2,11 +2,11 @@
2
2
  require 'fiber'
3
3
  module RGSS3
4
4
  class GameWindow < Gosu::Window
5
- attr_reader :frame_rate, :title
6
- def initialize(width: 544, height: 416, full_screen: false, frame_rate: 60, title: "Game", rtp: nil)
5
+ attr_reader :frame_rate
6
+ def initialize(width: 544, height: 416, fullscreen: false, frame_rate: 60, title: "Game", rtp: nil)
7
7
  @frame_rate = frame_rate
8
8
  RTP.path = rtp if rtp
9
- super(width, height, full_screen, 1000.0 / frame_rate)
9
+ super(width, height, fullscreen, 1000.0 / frame_rate)
10
10
  self.caption = title
11
11
  end
12
12
 
@@ -1,139 +1,130 @@
1
- # frozen_string_literal: true
2
- require 'set'
3
- module Graphics
4
-
5
- class << self
6
-
7
- attr_accessor :frame_count
8
- attr_reader :gosu_window
9
- attr_reader :brightness, :frame_rate
10
- attr_reader :needs_redraw
11
-
12
- def gosu_window
13
- RGSS3.window
14
- end
15
-
16
- def frame_rate
17
- RGSS3.window.frame_rate
18
- end
19
-
20
- def brightness=(int)
21
- @brightness = [[255, int].min, 0].max
22
- @draw_color.alpha = 255 - @brightness
23
- end
24
-
25
- def frame_rate=(int)
26
- # @frame_rate = [[120, int].min, 10].max
27
- #reform_window(width, height, fullscreen?, 1.0 / @frame_rate * 1000)
28
- end
29
- end
30
-
31
- @brightness = 255
32
- @frame_count = 0
33
- @frozen = false
34
- @draw_color = Gosu::Color.rgba(255, 255, 255, 0)
35
- @containers = Set.new
36
-
37
- def self.update
38
- # window = RGSS3.window
39
- # @current = window.record(window.width, window.height) do
40
- # @containers.each(&:draw)
41
- # end
42
- @frame_count += 1
43
-
44
- unless @frozen
45
- @needs_redraw = true
46
- # @latest = @current
47
- end
48
-
49
- Fiber.yield
50
- end
51
-
52
- def self.wait(duration)
53
- duration.times { update }
54
- end
55
-
56
- def self.fadeout(duration)
57
- @brightness = 0
58
- # Thread.new {
59
- # rate = @brightness / duration.to_f
60
- # until @brightness <= 0
61
- # self.brightness -= rate
62
- # sleep 1.0 / frame_rate
63
- # end
64
- # self.brightness = 0
65
- # }
66
- end
67
-
68
- def self.fadein(duration)
69
- @brightness = 255
70
- # Thread.new {
71
- # rate = 255 / duration.to_f
72
- # until @brightness >= 255
73
- # self.brightness += rate
74
- # sleep 1.0 / frame_rate
75
- # end
76
- # self.brightness = 255
77
- # }
78
- end
79
-
80
- def self.freeze
81
- @frozen = true
82
- end
83
-
84
- def self.transition(duration = 10, filename = "", vague = 40)
85
- @frozen = false
86
- @brightness = 255
87
- end
88
-
89
- def self.snap_to_bitmap
90
- Bitmap.new(width, height)
91
- end
92
-
93
- def self.frame_reset
94
- Fiber.yield
95
- end
96
-
97
- def self.width
98
- RGSS3.window.width
99
- end
100
-
101
- def self.height
102
- RGSS3.window.height
103
- end
104
-
105
- def self.resize_screen(w, h)
106
- reform_window(w, h, RGSS3.window.fullscreen?, RGSS3.update_interval)
107
- end
108
-
109
- def self.play_movie(filename)
110
- end
111
-
112
- def self.add_container(container)
113
- @containers.add(container)
114
- end
115
-
116
- def self.remove_container(container)
117
- @containers.delete(container)
118
- end
119
-
120
- def self.draw
121
- @needs_redraw = false
122
- @containers.each(&:draw)
123
- if @brightness < 255
124
- c = @draw_color
125
- RGSS3.window.draw_quad(0, 0, c, 0, height, c, width, 0, c, width, height, c, 1)
126
- end
127
- end
128
-
129
- # def self.set_fullscreen(bool)
130
- # return if bool == fullscreen?
131
- # reform_window(width, height, bool, gosu_window.update_interval)
132
- # end
133
-
134
- def self.reform_window(w, h, f, update_interval)
135
- Graphics.gosu_window.close
136
- Graphics.gosu_window = GosuGame.new(w, h, f, update_interval)
137
- Graphics.gosu_window.show
138
- end
139
- end
1
+ # frozen_string_literal: true
2
+ require 'set'
3
+ module Graphics
4
+
5
+ class << self
6
+ attr_accessor :frame_count
7
+ attr_reader :brightness, :frame_rate
8
+ attr_reader :needs_redraw
9
+ end
10
+
11
+ @brightness = 255
12
+ @frame_count = 0
13
+ @frozen = false
14
+ @draw_color = Gosu::Color.rgba(0, 0, 0, 0)
15
+ @containers = Set.new
16
+
17
+ def self.update
18
+ @needs_redraw = true unless @frozen
19
+ @frame_count += 1
20
+ Fiber.yield
21
+ end
22
+
23
+ def self.wait(duration)
24
+ @needs_redraw = true unless @frozen
25
+ # no need to redraw during wait
26
+ duration.times do
27
+ @frame_count += 1
28
+ Fiber.yield
29
+ end
30
+ end
31
+
32
+ def self.fadeout(duration)
33
+ @brightness = 0
34
+ end
35
+
36
+ def self.fadein(duration)
37
+ @brightness = 255
38
+ end
39
+
40
+ def self.freeze
41
+ @frozen = true
42
+ end
43
+
44
+ def self.transition(duration = 10, filename = "", vague = 40)
45
+ @frozen = false
46
+ @brightness = 255
47
+ end
48
+
49
+ def self.snap_to_bitmap
50
+ Bitmap.new(width, height)
51
+ end
52
+
53
+ def self.frame_reset
54
+ Fiber.yield
55
+ end
56
+
57
+ def self.width
58
+ RGSS3.window.width
59
+ end
60
+
61
+ def self.height
62
+ RGSS3.window.height
63
+ end
64
+
65
+ def self.resize_screen(width, height)
66
+ reform_window(width: width, height: height)
67
+ end
68
+
69
+ def self.gosu_window
70
+ RGSS3.window
71
+ end
72
+
73
+ def self.frame_rate
74
+ RGSS3.window.frame_rate
75
+ end
76
+
77
+ def self.brightness=(value)
78
+ @brightness = [[255, value].min, 0].max
79
+ @draw_color.alpha = 255 - @brightness
80
+ end
81
+
82
+ def self.frame_rate=(value)
83
+ @frame_rate = [[120, value].min, 10].max
84
+ reform_window(
85
+ width: width,
86
+ height: height,
87
+ fullscreen: RGSS3.window.fullscreen?,
88
+ frame_rate: @frame_rate,
89
+ title: RGSS3.window.caption)
90
+ end
91
+
92
+ def self.play_movie(filename)
93
+ end
94
+
95
+ def self.add_container(container)
96
+ @containers.add(container)
97
+ end
98
+
99
+ def self.remove_container(container)
100
+ @containers.delete(container)
101
+ end
102
+
103
+ def self.draw
104
+ @needs_redraw = false
105
+ @containers.each(&:do_draw)
106
+ if @brightness < 255
107
+ c = @draw_color
108
+ RGSS3.window.draw_quad(0, 0, c, 0, height, c, width, 0, c, width, height, c, 1)
109
+ end
110
+ end
111
+
112
+ def self.reform_window(
113
+ width: RGSS3.window.width,
114
+ height: RGSS3.window.height,
115
+ full_screen: RGSS3.window.fullscreen?,
116
+ frame_rate: @frame_rate,
117
+ title: RGSS3.window.caption,
118
+ rtp: nil)
119
+
120
+ RGSS3.window.close
121
+ RGSS3.window = RGSS3::GameWindow.new(
122
+ width: width,
123
+ height: height,
124
+ fullscreen: fullscreen,
125
+ frame_rate: frame_rate,
126
+ title: title,
127
+ rtp: rtp)
128
+ RGSS3.window.show
129
+ end
130
+ end
@@ -10,7 +10,8 @@ module ::Kernel
10
10
  end
11
11
 
12
12
  def rgss_stop
13
- loop { Graphics.update }
13
+ Graphics.update
14
+ loop { Fiber.yield }
14
15
  end
15
16
 
16
17
  def load_data(filename)
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
- require_relative 'sprite_container'
2
+ require_relative 'container'
3
3
  class Plane
4
- include RGSS3::SpriteContainer
4
+ include RGSS3::Container
5
5
  def draw
6
- return if !@visible || @opacity == 0 || @bitmap.nil? && @bitmap.disposed?
7
- @bitmap.gosu_image.draw(-@ox, -@oy, @z, 1, 1, 0xff_ffffff, BLEND[@blend_type])
6
+ bitmap.gosu_image.draw(-@ox, -@oy, @z, 1, 1, 0xff_ffffff, BLEND[@blend_type])
8
7
  end
9
8
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
- require_relative 'sprite_container'
2
+ require_relative 'container'
3
3
  class Sprite
4
4
 
5
- include RGSS3::SpriteContainer
5
+ include RGSS3::Container
6
6
 
7
7
  attr_reader :bush_opacity
8
8
  attr_accessor :x, :y
@@ -19,8 +19,8 @@ class Sprite
19
19
  @bush_depth = 0
20
20
  @bush_opacity = 128
21
21
  @wave_speed = 360
22
- @src_rect = Rect.new(0, 0, 0, 0)
23
- super()
22
+ @src_rect = Rect.new
23
+ super
24
24
  end
25
25
 
26
26
  def flash(color, duration)
@@ -47,8 +47,33 @@ class Sprite
47
47
  end
48
48
 
49
49
  def draw
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])
50
+ if viewport
51
+ x = @x + viewport.rect.x
52
+ y = @y + viewport.rect.y
53
+ w = [width - viewport.ox, viewport.rect.x + viewport.rect.width - x].min
54
+ h = [height - viewport.oy, viewport.rect.y + viewport.rect.height - y].min
55
+ return if w <= 0 || h <= 0
56
+ z = @z + (viewport.z << 12)
57
+ src_x = @src_rect.x + viewport.ox
58
+ src_y = @src_rect.y + viewport.oy
59
+ else
60
+ x = @x
61
+ y = @y
62
+ z = @z
63
+ src_x, src_y, w, h = *@src_rect
64
+ end
65
+ image = bitmap.gosu_image.subimage(src_x, src_y, w, h)
66
+ return unless image
67
+ image.draw_rot(
68
+ x,
69
+ y,
70
+ z,
71
+ @angle,
72
+ ox.fdiv(width),
73
+ oy.fdiv(height),
74
+ @zoom_x * (@mirror ? -1 : 1),
75
+ @zoom_y,
76
+ 0xff_ffffff,
77
+ BLEND[@blend_type])
53
78
  end
54
79
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module RGSS3
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
@@ -1,46 +1,46 @@
1
- # frozen_string_literal: true
2
- class Viewport
3
-
4
- attr_accessor :color, :tone, :rect, :visible, :z, :ox, :oy
5
-
6
- def initialize(*args)
7
- case args.size
8
- when 0
9
- @rect = Rect.new(0, 0, Graphics.width, Graphics.height)
10
- when 1
11
- if args[0].is_a?(Rect)
12
- @rect = args[0]
13
- else
14
- raise ArgumentError
15
- end
16
- when 4
17
- @rect = Rect.new(*args)
18
- else
19
- raise ArgumentError
20
- end
21
- @visible = true
22
- @z = 0
23
- @ox = 0
24
- @oy = 0
25
- @color = Color.new
26
- @tone = Tone.new
27
- end
28
-
29
- def dispose
30
- @disposed = true
31
- end
32
-
33
- def disposed?
34
- @disposed
35
- end
36
-
37
- def flash(color, duration)
38
- # @flash_color = color || Color.new(0, 0, 0, 0)
39
- # @flash_duration = duration
40
- end
41
-
42
- def update
43
- # @flash_duration = [@flash_duration - 1, 0].max
44
- # @flash_color = nil if @flash_duration == 0
45
- end
46
- end
1
+ # frozen_string_literal: true
2
+ class Viewport
3
+
4
+ attr_accessor :color, :tone, :rect, :visible, :z, :ox, :oy
5
+
6
+ def initialize(*args)
7
+ case args.size
8
+ when 0
9
+ @rect = Rect.new(0, 0, Graphics.width, Graphics.height)
10
+ when 1
11
+ if args[0].is_a?(Rect)
12
+ @rect = args[0]
13
+ else
14
+ raise ArgumentError
15
+ end
16
+ when 4
17
+ @rect = Rect.new(*args)
18
+ else
19
+ raise ArgumentError
20
+ end
21
+ @visible = true
22
+ @z = 0
23
+ @ox = 0
24
+ @oy = 0
25
+ @color = Color.new
26
+ @tone = Tone.new
27
+ end
28
+
29
+ def dispose
30
+ @disposed = true
31
+ end
32
+
33
+ def disposed?
34
+ @disposed
35
+ end
36
+
37
+ def flash(color, duration)
38
+ # @flash_color = color || Color.new(0, 0, 0, 0)
39
+ # @flash_duration = duration
40
+ end
41
+
42
+ def update
43
+ # @flash_duration = [@flash_duration - 1, 0].max
44
+ # @flash_color = nil if @flash_duration == 0
45
+ end
46
+ end
@@ -1,58 +1,71 @@
1
1
  # frozen_string_literal: true
2
- require_relative 'container'
3
2
  class Window
4
3
 
5
- include RGSS3::Container
6
-
4
+ attr_reader :z, :ox, :oy
5
+ attr_reader :viewport
6
+ attr_accessor :visible
7
+ attr_accessor :tone
7
8
  attr_accessor :windowskin
8
- attr_accessor :contents
9
+ attr_reader :contents
9
10
  attr_accessor :cursor_rect
10
11
  attr_accessor :active
11
- attr_accessor :visible
12
+ attr_reader :visible
12
13
  attr_accessor :arrows_visible
13
14
  attr_accessor :pause
14
- attr_accessor :x
15
- attr_accessor :y
15
+ attr_reader :x
16
+ attr_reader :y
16
17
  attr_accessor :width
17
18
  attr_accessor :height
18
- attr_accessor :padding
19
+ attr_reader :padding
19
20
  attr_accessor :padding_bottom
20
- attr_accessor :opacity
21
- attr_accessor :back_opacity
22
- attr_accessor :contents_opacity
21
+ attr_reader :back_opacity
22
+ attr_reader :contents_opacity
23
23
  attr_reader :openness
24
+ attr_reader :opacity
24
25
 
25
26
  def initialize(*args)
26
- case args.size
27
- when 0
28
- @x = 0
29
- @y = 0
30
- @width = 0
31
- @height = 0
32
- when 4
33
- @x, @y, @width, @height = args
34
- end
35
- @contents = Bitmap.new(1, 1)
27
+ @contents_sprite = Sprite.new
28
+ self.contents = Bitmap.new(1, 1)
29
+ @opacity = 255
36
30
  @cursor_rect = Rect.new
37
- @padding = 12
31
+ @padding = 8
38
32
  @padding_bottom = 8
39
33
  @pause = false
40
34
  @arrows_visible = true
41
35
  @active = true
42
36
  @openness = 255
43
- super()
37
+ @visible = true
38
+ @z = 100
39
+ @ox = 0
40
+ @oy = 0
41
+ @tone = Tone.new
42
+ @back_opacity = 192
43
+ @contents_opacity = 255
44
+ case args.size
45
+ when 0
46
+ self.x = 0
47
+ self.y = 0
48
+ @width = 0
49
+ @height = 0
50
+ when 4
51
+ self.x, self.y, @width, @height = args
52
+ end
44
53
  end
45
54
 
46
55
  def update
47
56
  end
48
57
 
49
58
  def move(x, y, width, height)
50
- @x = x
51
- @y = y
59
+ self.x = x
60
+ self.y = y
52
61
  @width = width
53
62
  @height = height
54
63
  end
55
64
 
65
+ def padding=(value)
66
+ @padding = @padding_bottom = value
67
+ end
68
+
56
69
  def open?
57
70
  @openness == 255
58
71
  end
@@ -63,9 +76,79 @@ class Window
63
76
 
64
77
  def openness=(value)
65
78
  @openness = [[value, 0].max, 255].min
79
+ update_contents_opacity
80
+ end
81
+
82
+ def opacity=(value)
83
+ @opacity = [[value, 0].max, 255].min
84
+ update_contents_opacity
85
+ end
86
+
87
+ def x=(value)
88
+ @contents_sprite.x = @padding + value
89
+ @x = value
90
+ end
91
+
92
+ def y=(value)
93
+ @contents_sprite.y = @padding + value
94
+ @y = value
95
+ end
96
+
97
+ def z=(value)
98
+ each_internal_sprite { |s| s.z = value }
99
+ @z = value
100
+ end
101
+
102
+ def ox=(value)
103
+ each_internal_sprite { |s| s.ox = value }
104
+ @ox = value
105
+ end
106
+
107
+ def oy=(value)
108
+ each_internal_sprite { |s| s.oy = value }
109
+ @oy = value
110
+ end
111
+
112
+ def visible=(value)
113
+ each_internal_sprite { |s| s.visible = value }
114
+ @visible = value
115
+ end
116
+
117
+ def back_opacity=(value)
118
+ @back_opacity = [[value, 0].max, 255].min
119
+ end
120
+
121
+ def contents_opacity=(value)
122
+ @contents_opacity = [[value, 0].max, 255].min
123
+ update_contents_opacity
124
+ end
125
+
126
+ def viewport=(value)
127
+ each_internal_sprite { |s| s.viewport = value }
128
+ @viewport = value
129
+ end
130
+
131
+ def contents=(value)
132
+ @contents = value
133
+ @contents_sprite.bitmap = value
134
+ end
135
+
136
+ def dispose
137
+ each_internal_sprite(&:dispose)
138
+ @disposed = true
139
+ end
140
+
141
+ def disposed?
142
+ @disposed
143
+ end
144
+
145
+ private
146
+
147
+ def update_contents_opacity
148
+ @contents_sprite.opacity = @contents_opacity * @opacity * @openness / 255 / 255
66
149
  end
67
150
 
68
- def draw
69
- # TODO
151
+ def each_internal_sprite
152
+ yield @contents_sprite
70
153
  end
71
154
  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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - taroxd
@@ -98,7 +98,6 @@ files:
98
98
  - lib/rgss3/rpg.rb
99
99
  - lib/rgss3/rtp.rb
100
100
  - lib/rgss3/sprite.rb
101
- - lib/rgss3/sprite_container.rb
102
101
  - lib/rgss3/table.rb
103
102
  - lib/rgss3/tilemap.rb
104
103
  - lib/rgss3/tone.rb
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative 'container'
3
- module RGSS3
4
- # common methods for Plane and Sprite
5
- module SpriteContainer
6
- include Container
7
-
8
- attr_accessor :zoom_x, :zoom_y
9
- attr_accessor :bitmap
10
- attr_accessor :color, :blend_type
11
-
12
- BLEND = {0 => :default, 1 => :additive, 2 => :subtractive}
13
-
14
- def initialize(viewport = nil)
15
- @viewport = viewport
16
- @zoom_x = @zoom_y = 1.0
17
- @blend_type = 0
18
- @color = Color.new
19
- super()
20
- end
21
-
22
- def dispose
23
- @bitmap = nil
24
- super
25
- end
26
- end
27
- end