openrgss 0.1.4-x86-mingw32 → 0.1.5-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,57 +1,57 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
-
3
- Version 3, 29 June 2007
4
-
5
- Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
6
-
7
- Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
8
-
9
- This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
10
-
11
- 0. Additional Definitions.
12
- As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
13
-
14
- “The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
15
-
16
- An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
17
-
18
- A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
19
-
20
- The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
21
-
22
- The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
23
-
24
- 1. Exception to Section 3 of the GNU GPL.
25
- You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
26
-
27
- 2. Conveying Modified Versions.
28
- If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
29
-
30
- a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
31
- b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
32
- 3. Object Code Incorporating Material from Library Header Files.
33
- The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
34
-
35
- a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
36
- b) Accompany the object code with a copy of the GNU GPL and this license document.
37
- 4. Combined Works.
38
- You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
39
-
40
- a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
41
- b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
42
- c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
43
- d) Do one of the following:
44
- 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
45
- 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
46
- e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
47
- 5. Combined Libraries.
48
- You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
49
-
50
- a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
51
- b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
52
- 6. Revised Versions of the GNU Lesser General Public License.
53
- The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
54
-
55
- Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
56
-
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+ Version 3, 29 June 2007
4
+
5
+ Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
6
+
7
+ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
8
+
9
+ This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
10
+
11
+ 0. Additional Definitions.
12
+ As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
13
+
14
+ “The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
15
+
16
+ An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
17
+
18
+ A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
19
+
20
+ The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
21
+
22
+ The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
23
+
24
+ 1. Exception to Section 3 of the GNU GPL.
25
+ You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
26
+
27
+ 2. Conveying Modified Versions.
28
+ If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
29
+
30
+ a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
31
+ b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
32
+ 3. Object Code Incorporating Material from Library Header Files.
33
+ The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
34
+
35
+ a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
36
+ b) Accompany the object code with a copy of the GNU GPL and this license document.
37
+ 4. Combined Works.
38
+ You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
39
+
40
+ a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
41
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
42
+ c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
43
+ d) Do one of the following:
44
+ 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
45
+ 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
46
+ e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
47
+ 5. Combined Libraries.
48
+ You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
49
+
50
+ a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
51
+ b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
52
+ 6. Revised Versions of the GNU Lesser General Public License.
53
+ The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
54
+
55
+ Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
56
+
57
57
  If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
data/README.txt CHANGED
@@ -1,19 +1,19 @@
1
- = OpenRGSS
2
-
3
- Open-source implementation of the Ruby Game Script System.
4
-
5
- == Contributing to OpenRGSS
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == License
16
- GNU LGPL v3 or later
17
-
18
- == Copyright
1
+ = OpenRGSS
2
+
3
+ Open-source implementation of the Ruby Game Script System.
4
+
5
+ == Contributing to OpenRGSS
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == License
16
+ GNU LGPL v3 or later
17
+
18
+ == Copyright
19
19
  Copyright © 2012 zh99998. See LICENSE.txt for further details.
@@ -1,19 +1,19 @@
1
- require_relative 'openrgss/rgss'
2
-
3
- require_relative 'openrgss/bitmap'
4
- require_relative 'openrgss/color'
5
- require_relative 'openrgss/font'
6
- require_relative 'openrgss/plane'
7
- require_relative 'openrgss/rect'
8
- require_relative 'openrgss/sprite'
9
- require_relative 'openrgss/table'
10
- require_relative 'openrgss/tilemap'
11
- require_relative 'openrgss/tone'
12
- require_relative 'openrgss/viewport'
13
- require_relative 'openrgss/window'
14
- require_relative 'openrgss/rgsserror'
15
- require_relative 'openrgss/rgssreset'
16
-
17
- require_relative 'openrgss/audio'
18
- require_relative 'openrgss/graphics'
1
+ require_relative 'openrgss/rgss'
2
+
3
+ require_relative 'openrgss/bitmap'
4
+ require_relative 'openrgss/color'
5
+ require_relative 'openrgss/font'
6
+ require_relative 'openrgss/plane'
7
+ require_relative 'openrgss/rect'
8
+ require_relative 'openrgss/sprite'
9
+ require_relative 'openrgss/table'
10
+ require_relative 'openrgss/tilemap'
11
+ require_relative 'openrgss/tone'
12
+ require_relative 'openrgss/viewport'
13
+ require_relative 'openrgss/window'
14
+ require_relative 'openrgss/rgsserror'
15
+ require_relative 'openrgss/rgssreset'
16
+
17
+ require_relative 'openrgss/audio'
18
+ require_relative 'openrgss/graphics'
19
19
  require_relative 'openrgss/input'
@@ -1,109 +1,109 @@
1
- # The module that carries out music and sound processing.
2
- module Audio
3
- class <<self
4
-
5
- # Prepares MIDI playback by DirectMusic.
6
- #
7
- # A method of the processing at startup in RGSS2 for enabling execution at any time.
8
- #
9
- # MIDI playback is possible without calling this method, but in Windows Vista or later, a delay of 1 to 2 seconds will result at playback.
10
-
11
- def setup_mdi
12
-
13
- end
14
-
15
- # Starts BGM playback. Specifies the file name, volume, pitch, and playback starting position in that order.
16
- #
17
- # The playback starting position (RGSS3) is only valid for ogg or wav files.
18
- #
19
- # Also automatically searches files included in RGSS-RTP. File extensions may be omitted.
20
-
21
- def bgm_play(filename, volume=100, pitch=100, pos=0)
22
- SDL::Mixer.play_music SDL::Mixer::Music.load(RGSS.get_file(filename)), -1
23
- end
24
-
25
- # Stops BGM playback.
26
-
27
- def bgm_stop
28
- SDL::Mixer.halt_music
29
- end
30
-
31
- # Starts BGM fadeout. time is the length of the fadeout in milliseconds.
32
-
33
- def bgm_fade(time)
34
- SDL::Mixer.fade_out_music(time)
35
- end
36
-
37
- # Gets the playback position of the BGM. Only valid for ogg or wav files. Returns 0 when not valid.
38
-
39
- def bgm_pos
40
-
41
- end
42
-
43
- # Starts BGS playback. Specifies the file name, volume, pitch, and playback starting position in that order.
44
- #
45
- # The playback starting position (RGSS3) is only valid for ogg or wav files.
46
- #
47
- # Also automatically searches files included in RGSS-RTP. File extensions may be omitted.
48
-
49
- def bgs_play(filename, volume=100, pitch=100, pos=0)
50
- @bgs_channel = SDL::Mixer.play_channel(-1, SDL::Mixer::Wave.load(RGSS.get_file(filename)), -1)
51
- end
52
-
53
- # Stops BGS playback.
54
-
55
- def bgs_stop
56
- SDL::Mixer.halt(@bgs_channel) if @bgs_channel
57
- end
58
-
59
- # Starts BGS fadeout. time is the length of the fadeout in milliseconds.
60
-
61
- def bgs_fade(time)
62
- SDL::Mixer.fade_out(@bgs_channel, time) if @bgs_channel
63
- end
64
-
65
- # Gets the playback position of the BGS. Only valid for ogg or wav files. Returns 0 when not valid.
66
-
67
- def bgs_pos
68
-
69
- end
70
-
71
- # Starts ME playback. Sets the file name, volume, and pitch in turn.
72
- #
73
- # Also automatically searches files included in RGSS-RTP. File extensions may be omitted.
74
- #
75
- # When ME is playing, the BGM will temporarily stop. The timing of when the BGM restarts is slightly different from RGSS1.
76
-
77
- def me_play(filename, volume=100, pitch=100)
78
- @me_channel = SDL::Mixer.play_channel(-1, SDL::Mixer::Wave.load(RGSS.get_file(filename)), 0)
79
- end
80
-
81
- # Stops ME playback.
82
-
83
- def me_stop
84
- SDL::Mixer.halt(@me_channel) if @me_channel
85
- end
86
-
87
- # Starts ME fadeout. time is the length of the fadeout in milliseconds.
88
-
89
- def me_fade(time)
90
- SDL::Mixer.fade_out(@me_channel, time) if @me_channel
91
- end
92
-
93
- # Starts SE playback. Sets the file name, volume, and pitch in turn.
94
- #
95
- # Also automatically searches files included in RGSS-RTP. File extensions may be omitted.
96
- #
97
- # When attempting to play the same SE more than once in a very short period, they will automatically be filtered to prevent choppy playback
98
-
99
- def se_play(filename, volume=100, pitch=100)
100
- @se_channel = SDL::Mixer.play_channel(-1, SDL::Mixer::Wave.load(RGSS.get_file(filename)), 0)
101
- end
102
-
103
- # Stops all SE playback.
104
-
105
- def se_stop
106
- SDL::Mixer.halt(@se_channel) if @me_channel
107
- end
108
- end
1
+ # The module that carries out music and sound processing.
2
+ module Audio
3
+ class <<self
4
+
5
+ # Prepares MIDI playback by DirectMusic.
6
+ #
7
+ # A method of the processing at startup in RGSS2 for enabling execution at any time.
8
+ #
9
+ # MIDI playback is possible without calling this method, but in Windows Vista or later, a delay of 1 to 2 seconds will result at playback.
10
+
11
+ def setup_mdi
12
+
13
+ end
14
+
15
+ # Starts BGM playback. Specifies the file name, volume, pitch, and playback starting position in that order.
16
+ #
17
+ # The playback starting position (RGSS3) is only valid for ogg or wav files.
18
+ #
19
+ # Also automatically searches files included in RGSS-RTP. File extensions may be omitted.
20
+
21
+ def bgm_play(filename, volume=100, pitch=100, pos=0)
22
+ SDL::Mixer.play_music SDL::Mixer::Music.load(RGSS.get_file(filename)), -1 rescue puts($!)
23
+ end
24
+
25
+ # Stops BGM playback.
26
+
27
+ def bgm_stop
28
+ SDL::Mixer.halt_music
29
+ end
30
+
31
+ # Starts BGM fadeout. time is the length of the fadeout in milliseconds.
32
+
33
+ def bgm_fade(time)
34
+ SDL::Mixer.fade_out_music(time)
35
+ end
36
+
37
+ # Gets the playback position of the BGM. Only valid for ogg or wav files. Returns 0 when not valid.
38
+
39
+ def bgm_pos
40
+
41
+ end
42
+
43
+ # Starts BGS playback. Specifies the file name, volume, pitch, and playback starting position in that order.
44
+ #
45
+ # The playback starting position (RGSS3) is only valid for ogg or wav files.
46
+ #
47
+ # Also automatically searches files included in RGSS-RTP. File extensions may be omitted.
48
+
49
+ def bgs_play(filename, volume=100, pitch=100, pos=0)
50
+ @bgs_channel = SDL::Mixer.play_channel(-1, SDL::Mixer::Wave.load(RGSS.get_file(filename)), -1) rescue puts($!)
51
+ end
52
+
53
+ # Stops BGS playback.
54
+
55
+ def bgs_stop
56
+ SDL::Mixer.halt(@bgs_channel) if @bgs_channel
57
+ end
58
+
59
+ # Starts BGS fadeout. time is the length of the fadeout in milliseconds.
60
+
61
+ def bgs_fade(time)
62
+ SDL::Mixer.fade_out(@bgs_channel, time) if @bgs_channel
63
+ end
64
+
65
+ # Gets the playback position of the BGS. Only valid for ogg or wav files. Returns 0 when not valid.
66
+
67
+ def bgs_pos
68
+
69
+ end
70
+
71
+ # Starts ME playback. Sets the file name, volume, and pitch in turn.
72
+ #
73
+ # Also automatically searches files included in RGSS-RTP. File extensions may be omitted.
74
+ #
75
+ # When ME is playing, the BGM will temporarily stop. The timing of when the BGM restarts is slightly different from RGSS1.
76
+
77
+ def me_play(filename, volume=100, pitch=100)
78
+ @me_channel = SDL::Mixer.play_channel(-1, SDL::Mixer::Wave.load(RGSS.get_file(filename)), 0) rescue puts($!)
79
+ end
80
+
81
+ # Stops ME playback.
82
+
83
+ def me_stop
84
+ SDL::Mixer.halt(@me_channel) if @me_channel
85
+ end
86
+
87
+ # Starts ME fadeout. time is the length of the fadeout in milliseconds.
88
+
89
+ def me_fade(time)
90
+ SDL::Mixer.fade_out(@me_channel, time) if @me_channel
91
+ end
92
+
93
+ # Starts SE playback. Sets the file name, volume, and pitch in turn.
94
+ #
95
+ # Also automatically searches files included in RGSS-RTP. File extensions may be omitted.
96
+ #
97
+ # When attempting to play the same SE more than once in a very short period, they will automatically be filtered to prevent choppy playback
98
+
99
+ def se_play(filename, volume=100, pitch=100)
100
+ @se_channel = SDL::Mixer.play_channel(-1, SDL::Mixer::Wave.load(RGSS.get_file(filename)), 0) rescue puts($!)
101
+ end
102
+
103
+ # Stops all SE playback.
104
+
105
+ def se_stop
106
+ SDL::Mixer.halt(@se_channel) if @me_channel
107
+ end
108
+ end
109
109
  end
@@ -1,255 +1,255 @@
1
- # The bitmap class. Bitmaps represent images.
2
- #
3
- # Sprites (Sprite) and other objects must be used to display bitmaps onscreen.
4
-
5
- class Bitmap
6
- attr_accessor :font, :entity, :text
7
-
8
- # :call-seq:
9
- # Bitmap.new(filename)
10
- # Bitmap.new(width, height)
11
- #
12
- # Loads the graphic file specified in filename or size and creates a bitmap object.
13
- #
14
- # Also automatically searches files included in RGSS-RTP and encrypted archives. File extensions may be omitted.
15
-
16
- def initialize(width, height=nil)
17
- @entity = if width.is_a? String
18
- filename = width
19
- filepath = RGSS.get_file(filename)
20
- Log.debug('load bitmap') { filepath }
21
- SDL::Surface.load(filepath).display_format_alpha
22
- else
23
- big_endian = ([1].pack("N") == [1].pack("L"))
24
- if big_endian
25
- rmask = 0xff000000
26
- gmask = 0x00ff0000
27
- bmask = 0x0000ff00
28
- amask = 0x000000ff
29
- else
30
- rmask = 0x000000ff
31
- gmask = 0x0000ff00
32
- bmask = 0x00ff0000
33
- amask = 0xff000000
34
- end
35
- SDL::Surface.new(SDL::SWSURFACE|SDL::SRCALPHA, width, height, 32, rmask, gmask, bmask, amask)
36
- end
37
- @font = Font.new
38
- # @text = [] ~
39
- end
40
-
41
- # Frees the bitmap. If the bitmap has already been freed, does nothing.
42
-
43
- def dispose
44
- @entity.destroy
45
- end
46
-
47
- # Returns true if the bitmap has been freed.
48
-
49
- def disposed?
50
- @entity.destroyed?
51
- end
52
-
53
- # Gets the bitmap width.
54
-
55
- def width
56
- @entity.w
57
- end
58
-
59
- # Gets the bitmap height.
60
-
61
- def height
62
- @entity.h
63
- end
64
-
65
- # Gets the bitmap rectangle (Rect).
66
-
67
- def rect
68
- Rect.new(0, 0, width, height)
69
- end
70
-
71
- def clone
72
- b =Bitmap.new(width, height)
73
- b.entity = @entity.copyRect(0, 0, width, height)
74
- b.font =Font.clone
75
- return b
76
- end
77
-
78
- # Performs a block transfer from the src_bitmap box src_rect (Rect) to the specified bitmap coordinates (x, y).
79
- #
80
- # opacity can be set from 0 to 255.
81
-
82
- def blt(x, y, src_bitmap, src_rect, opacity=255)
83
- src_bitmap.entity.set_alpha(SDL::RLEACCEL, opacity)
84
- SDL::Surface.blit(src_bitmap.entity, src_rect.x, src_rect.y, src_rect.width, src_rect.height, @entity, x, y)
85
- src_bitmap.entity.set_alpha(SDL::SRCALPHA|SDL::RLEACCEL, 255)
86
- end
87
-
88
- # Performs a block transfer from the src_bitmap box src_rect (Rect) to the specified bitmap box dest_rect (Rect).
89
- #
90
- # opacity can be set from 0 to 255.
91
-
92
- def stretch_blt(dest_rect, src_bitmap, src_rect, opacity=255)
93
- src_bitmap.entity.set_alpha(SDL::RLEACCEL, opacity)
94
- SDL::Surface.transform_blit(src_bitmap.entity, @entity, 0, src_rect.width.to_f / dest_rect.width, src_rect.height.to_f / dest_rect.height, src_rect.x, src_rect.y, dest_rect.x, dest_rect.y, SDL::Surface::TRANSFORM_AA)
95
- src_bitmap.entity.set_alpha(SDL::SRCALPHA|SDL::RLEACCEL, 255)
96
- end
97
-
98
- # :call-seq:
99
- # fill_rect(x, y, width, height, color)
100
- # fill_rect(rect, color)
101
- #
102
- # Fills the bitmap box (x, y, width, height) or rect (Rect) with color (Color).
103
-
104
- def fill_rect(x, y, width=nil, height=nil, color=nil)
105
- if x.is_a? Rect
106
- rect = x
107
- color = y
108
- x = rect.x
109
- y = rect.y
110
- width = rect.width
111
- height = rect.height
112
- end
113
- @entity.fill_rect(x, y, width, height, @entity.map_rgba(color.red, color.green, color.blue, color.alpha))
114
- end
115
-
116
- # :call-seq:
117
- # gradient_fill_rect(x, y, width, height, color1, color2[, vertical])
118
- # gradient_fill_rect(rect, color1, color2[, vertical])
119
- #
120
- # Fills in this bitmap box (x, y, width, height) or rect (Rect) with a gradient from color1 (Color) to color2 (Color).
121
- #
122
- # Set vertical to true to create a vertical gradient. Horizontal gradient is the default.
123
-
124
- def gradient_fill_rect(x, y, width, height=false, color1=nil, color2=nil, vertical=false)
125
- if x.is_a? Rect
126
- rect = x
127
- color1 = y
128
- color2 = width
129
- vertical = height
130
- x = rect.x
131
- y = rect.y
132
- width = rect.width
133
- height = rect.height
134
- end
135
- if vertical
136
- height.times do |i|
137
- @entity.fill_rect(x, y+i, width, 1, @entity.map_rgba(
138
- color1.red + (color2.red - color1.red) * i / height,
139
- color1.green + (color2.green - color1.green) * i / height,
140
- color1.blue + (color2.blue - color1.blue) * i / height,
141
- color1.alpha + (color2.alpha - color1.alpha) * i / height
142
- ))
143
- end
144
- else
145
- width.times do |i|
146
- @entity.fill_rect(x+i, y, 1, height, @entity.map_rgba(
147
- color1.red + (color2.red - color1.red) * i / width,
148
- color1.green + (color2.green - color1.green) * i / width,
149
- color1.blue + (color2.blue - color1.blue) * i / width,
150
- color1.alpha + (color2.alpha - color1.alpha) * i / width
151
- ))
152
- end
153
- end
154
- end
155
-
156
- # Clears the entire bitmap.
157
-
158
- def clear
159
- @entity.fill_rect(0, 0, width, height, 0x00000000)
160
- end
161
-
162
- # Clears this bitmap box or (x, y, width, height) or rect (Rect).
163
-
164
- def clear_rect(x, y=nil, width=nil, height=nil)
165
- if x.is_a? Rect
166
- rect = x
167
- x = rect.x
168
- y = rect.y
169
- width = rect.width
170
- height = rect.height
171
- end
172
- @entity.fill_rect(x, y, width, height, 0x00000000)
173
- end
174
-
175
- # Gets the color (Color) at the specified pixel (x, y).
176
-
177
- def get_pixel(x, y)
178
-
179
- color = @entity.format.getRGBA(@entity.get_pixel(x, y))
180
- return Color.new(color[0], color[1], color[2], color[3])
181
- #Color.new((color & @entity.Rmask) >> @entity.Rshift, (color & @entity.Gmask) >> @entity.Gshift, (color & @entity.Bmask) >> @entity.Bshift, (color & @entity.Amask) >> @entity.Ashift)
182
- end
183
-
184
- # Sets the specified pixel (x, y) to color (Color).
185
-
186
- def set_pixel(x, y, color)
187
- @entity.put_pixel(x, y, @entity.map_rgba(color.red, color.green, color.blue, color.alpha))
188
- end
189
-
190
- # Changes the bitmap's hue within 360 degrees of displacement.
191
- #
192
- # This process is time-consuming. Furthermore, due to conversion errors, repeated hue changes may result in color loss.
193
-
194
- def hue_change(hue)
195
-
196
- end
197
-
198
- # Applies a blur effect to the bitmap. This process is time consuming.
199
-
200
- def blur
201
-
202
- end
203
-
204
- # Applies a radial blur to the bitmap. angle is used to specify an angle from 0 to 360. The larger the number, the greater the roundness.
205
- #
206
- # division is the division number (from 2 to 100). The larger the number, the smoother it will be. This process is very time consuming.
207
-
208
- def radial_blur(angle, division)
209
-
210
- end
211
-
212
- # Draws the string str in the bitmap box (x, y, width, height) or rect (Rect).
213
- #
214
- # If str is not a character string object, it will be converted to a character string using the to_s method before processing is performed.
215
- #
216
- # If the text length exceeds the box's width, the text width will automatically be reduced by up to 60 percent.
217
- #
218
- # Horizontal text is left-aligned by default. Set align to 1 to center the text and to 2 to right-align it. Vertical text is always centered.
219
- #
220
- # As this process is time-consuming, redrawing the text with every frame is not recommended.
221
-
222
- def draw_text(x, y, width=0, height=nil, str=nil, align=0 )
223
- if x.is_a? Rect
224
- rect = x
225
- str = y
226
- align = width
227
-
228
- x = rect.x
229
- y = rect.y
230
- width = rect.width
231
- height = rect.height
232
- end
233
-
234
- str = str.to_s
235
- if align == 2
236
- x += width - @font.entity.text_size(str)[0]
237
- elsif align == 1
238
- x += (width - @font.entity.text_size(str)[0]) / 2
239
- end
240
-
241
- # @text << [str, x, y, @font.color.red, @font.color.green, @font.color.blue] See you ~
242
- tmp = @font.entity.render_blended_utf8(str, @font.color.red, @font.color.green, @font.color.blue)
243
- tmp.set_alpha(SDL::RLEACCEL ,0)
244
- @entity.put tmp,x,y
245
- #SDL::Surface.transformBlit tmp,@entity,0,1,1,0,0,x, y,SDL::Surface::TRANSFORM_AA|SDL::Surface::TRANSFORM_SAFE|SDL::Surface::TRANSFORM_SAFE
246
- end
247
-
248
- # Gets the box (Rect) used when drawing the string str with the draw_text method. Does not include the outline portion (RGSS3) and the angled portions of italicized text.
249
- #
250
- # If str is not a character string object, it will be converted to a character string using the to_s method before processing is performed.
251
-
252
- def text_size(str)
253
- Rect.new 0, 0, *@font.entity.text_size(str)
254
- end
1
+ # The bitmap class. Bitmaps represent images.
2
+ #
3
+ # Sprites (Sprite) and other objects must be used to display bitmaps onscreen.
4
+
5
+ class Bitmap
6
+ attr_accessor :font, :entity, :text
7
+
8
+ # :call-seq:
9
+ # Bitmap.new(filename)
10
+ # Bitmap.new(width, height)
11
+ #
12
+ # Loads the graphic file specified in filename or size and creates a bitmap object.
13
+ #
14
+ # Also automatically searches files included in RGSS-RTP and encrypted archives. File extensions may be omitted.
15
+
16
+ def initialize(width, height=nil)
17
+ @entity = if width.is_a? String
18
+ filename = width
19
+ filepath = RGSS.get_file(filename)
20
+ Log.debug('load bitmap') { filepath }
21
+ SDL::Surface.load(filepath).display_format_alpha
22
+ else
23
+ big_endian = ([1].pack("N") == [1].pack("L"))
24
+ if big_endian
25
+ rmask = 0xff000000
26
+ gmask = 0x00ff0000
27
+ bmask = 0x0000ff00
28
+ amask = 0x000000ff
29
+ else
30
+ rmask = 0x000000ff
31
+ gmask = 0x0000ff00
32
+ bmask = 0x00ff0000
33
+ amask = 0xff000000
34
+ end
35
+ SDL::Surface.new(SDL::SWSURFACE|SDL::SRCALPHA, width, height, 32, rmask, gmask, bmask, amask)
36
+ end
37
+ @font = Font.new
38
+ # @text = [] ~
39
+ end
40
+
41
+ # Frees the bitmap. If the bitmap has already been freed, does nothing.
42
+
43
+ def dispose
44
+ @entity.destroy
45
+ end
46
+
47
+ # Returns true if the bitmap has been freed.
48
+
49
+ def disposed?
50
+ @entity.destroyed?
51
+ end
52
+
53
+ # Gets the bitmap width.
54
+
55
+ def width
56
+ @entity.w
57
+ end
58
+
59
+ # Gets the bitmap height.
60
+
61
+ def height
62
+ @entity.h
63
+ end
64
+
65
+ # Gets the bitmap rectangle (Rect).
66
+
67
+ def rect
68
+ Rect.new(0, 0, width, height)
69
+ end
70
+
71
+ def clone
72
+ b =Bitmap.new(width, height)
73
+ b.entity = @entity.copyRect(0, 0, width, height)
74
+ b.font =Font.clone
75
+ return b
76
+ end
77
+
78
+ # Performs a block transfer from the src_bitmap box src_rect (Rect) to the specified bitmap coordinates (x, y).
79
+ #
80
+ # opacity can be set from 0 to 255.
81
+
82
+ def blt(x, y, src_bitmap, src_rect, opacity=255)
83
+ src_bitmap.entity.set_alpha(SDL::RLEACCEL, opacity)
84
+ SDL::Surface.blit(src_bitmap.entity, src_rect.x, src_rect.y, src_rect.width, src_rect.height, @entity, x, y)
85
+ src_bitmap.entity.set_alpha(SDL::SRCALPHA|SDL::RLEACCEL, 255)
86
+ end
87
+
88
+ # Performs a block transfer from the src_bitmap box src_rect (Rect) to the specified bitmap box dest_rect (Rect).
89
+ #
90
+ # opacity can be set from 0 to 255.
91
+
92
+ def stretch_blt(dest_rect, src_bitmap, src_rect, opacity=255)
93
+ src_bitmap.entity.set_alpha(SDL::RLEACCEL, opacity)
94
+ SDL::Surface.transform_blit(src_bitmap.entity, @entity, 0, src_rect.width.to_f / dest_rect.width, src_rect.height.to_f / dest_rect.height, src_rect.x, src_rect.y, dest_rect.x, dest_rect.y, SDL::Surface::TRANSFORM_AA)
95
+ src_bitmap.entity.set_alpha(SDL::SRCALPHA|SDL::RLEACCEL, 255)
96
+ end
97
+
98
+ # :call-seq:
99
+ # fill_rect(x, y, width, height, color)
100
+ # fill_rect(rect, color)
101
+ #
102
+ # Fills the bitmap box (x, y, width, height) or rect (Rect) with color (Color).
103
+
104
+ def fill_rect(x, y, width=nil, height=nil, color=nil)
105
+ if x.is_a? Rect
106
+ rect = x
107
+ color = y
108
+ x = rect.x
109
+ y = rect.y
110
+ width = rect.width
111
+ height = rect.height
112
+ end
113
+ @entity.fill_rect(x, y, width, height, @entity.map_rgba(color.red, color.green, color.blue, color.alpha))
114
+ end
115
+
116
+ # :call-seq:
117
+ # gradient_fill_rect(x, y, width, height, color1, color2[, vertical])
118
+ # gradient_fill_rect(rect, color1, color2[, vertical])
119
+ #
120
+ # Fills in this bitmap box (x, y, width, height) or rect (Rect) with a gradient from color1 (Color) to color2 (Color).
121
+ #
122
+ # Set vertical to true to create a vertical gradient. Horizontal gradient is the default.
123
+
124
+ def gradient_fill_rect(x, y, width, height=false, color1=nil, color2=nil, vertical=false)
125
+ if x.is_a? Rect
126
+ rect = x
127
+ color1 = y
128
+ color2 = width
129
+ vertical = height
130
+ x = rect.x
131
+ y = rect.y
132
+ width = rect.width
133
+ height = rect.height
134
+ end
135
+ if vertical
136
+ height.times do |i|
137
+ @entity.fill_rect(x, y+i, width, 1, @entity.map_rgba(
138
+ color1.red + (color2.red - color1.red) * i / height,
139
+ color1.green + (color2.green - color1.green) * i / height,
140
+ color1.blue + (color2.blue - color1.blue) * i / height,
141
+ color1.alpha + (color2.alpha - color1.alpha) * i / height
142
+ ))
143
+ end
144
+ else
145
+ width.times do |i|
146
+ @entity.fill_rect(x+i, y, 1, height, @entity.map_rgba(
147
+ color1.red + (color2.red - color1.red) * i / width,
148
+ color1.green + (color2.green - color1.green) * i / width,
149
+ color1.blue + (color2.blue - color1.blue) * i / width,
150
+ color1.alpha + (color2.alpha - color1.alpha) * i / width
151
+ ))
152
+ end
153
+ end
154
+ end
155
+
156
+ # Clears the entire bitmap.
157
+
158
+ def clear
159
+ @entity.fill_rect(0, 0, width, height, 0x00000000)
160
+ end
161
+
162
+ # Clears this bitmap box or (x, y, width, height) or rect (Rect).
163
+
164
+ def clear_rect(x, y=nil, width=nil, height=nil)
165
+ if x.is_a? Rect
166
+ rect = x
167
+ x = rect.x
168
+ y = rect.y
169
+ width = rect.width
170
+ height = rect.height
171
+ end
172
+ @entity.fill_rect(x, y, width, height, 0x00000000)
173
+ end
174
+
175
+ # Gets the color (Color) at the specified pixel (x, y).
176
+
177
+ def get_pixel(x, y)
178
+
179
+ color = @entity.format.getRGBA(@entity.get_pixel(x, y))
180
+ return Color.new(color[0], color[1], color[2], color[3])
181
+ #Color.new((color & @entity.Rmask) >> @entity.Rshift, (color & @entity.Gmask) >> @entity.Gshift, (color & @entity.Bmask) >> @entity.Bshift, (color & @entity.Amask) >> @entity.Ashift)
182
+ end
183
+
184
+ # Sets the specified pixel (x, y) to color (Color).
185
+
186
+ def set_pixel(x, y, color)
187
+ @entity.put_pixel(x, y, @entity.map_rgba(color.red, color.green, color.blue, color.alpha))
188
+ end
189
+
190
+ # Changes the bitmap's hue within 360 degrees of displacement.
191
+ #
192
+ # This process is time-consuming. Furthermore, due to conversion errors, repeated hue changes may result in color loss.
193
+
194
+ def hue_change(hue)
195
+
196
+ end
197
+
198
+ # Applies a blur effect to the bitmap. This process is time consuming.
199
+
200
+ def blur
201
+
202
+ end
203
+
204
+ # Applies a radial blur to the bitmap. angle is used to specify an angle from 0 to 360. The larger the number, the greater the roundness.
205
+ #
206
+ # division is the division number (from 2 to 100). The larger the number, the smoother it will be. This process is very time consuming.
207
+
208
+ def radial_blur(angle, division)
209
+
210
+ end
211
+
212
+ # Draws the string str in the bitmap box (x, y, width, height) or rect (Rect).
213
+ #
214
+ # If str is not a character string object, it will be converted to a character string using the to_s method before processing is performed.
215
+ #
216
+ # If the text length exceeds the box's width, the text width will automatically be reduced by up to 60 percent.
217
+ #
218
+ # Horizontal text is left-aligned by default. Set align to 1 to center the text and to 2 to right-align it. Vertical text is always centered.
219
+ #
220
+ # As this process is time-consuming, redrawing the text with every frame is not recommended.
221
+
222
+ def draw_text(x, y, width=0, height=nil, str=nil, align=0 )
223
+ if x.is_a? Rect
224
+ rect = x
225
+ str = y
226
+ align = width
227
+
228
+ x = rect.x
229
+ y = rect.y
230
+ width = rect.width
231
+ height = rect.height
232
+ end
233
+
234
+ str = str.to_s
235
+ if align == 2
236
+ x += width - @font.entity.text_size(str)[0]
237
+ elsif align == 1
238
+ x += (width - @font.entity.text_size(str)[0]) / 2
239
+ end
240
+
241
+ # @text << [str, x, y, @font.color.red, @font.color.green, @font.color.blue] See you ~
242
+ tmp = @font.entity.render_blended_utf8(str, @font.color.red, @font.color.green, @font.color.blue)
243
+ tmp.set_alpha(SDL::RLEACCEL ,0)
244
+ @entity.put tmp,x,y
245
+ #SDL::Surface.transformBlit tmp,@entity,0,1,1,0,0,x, y,SDL::Surface::TRANSFORM_AA|SDL::Surface::TRANSFORM_SAFE|SDL::Surface::TRANSFORM_SAFE
246
+ end
247
+
248
+ # Gets the box (Rect) used when drawing the string str with the draw_text method. Does not include the outline portion (RGSS3) and the angled portions of italicized text.
249
+ #
250
+ # If str is not a character string object, it will be converted to a character string using the to_s method before processing is performed.
251
+
252
+ def text_size(str)
253
+ Rect.new 0, 0, *@font.entity.text_size(str)
254
+ end
255
255
  end