Project1
标题:
zh99998的脚本仓库
[打印本页]
作者:
zh99998
时间:
2009-2-15 19:30
标题:
zh99998的脚本仓库
1楼VX
loading窗口
class Loading < Window_Base
def initialize(num, text = "Loading...")
super(64,192,418,80)
rect = contents.text_size(text)
rect.width = self.contents.width
self.contents.draw_text(rect,text,1)
@num = num
@nth = 0
end
def next(nth = 1)
@nth += nth
self.contents.fill_rect(Rect.new(0, 24, self.contents.width * @nth / @num, 24), Color.new(255,255,255))
Graphics.update
end
end
复制代码
#loading窗口 by zh99998 2008-11-1
class Loading < Window_Base
attr_accessor :num
attr_accessor :nth
def initialize(num, text = "Loading...", color = Color.new(255,255,255))
super(64,192,418,80)
if text.is_a?(Bitmap)
self.contents.blt((self.contents.width - text.width) / 2, 0, text, text.rect)
elsif text.is_a?(Array)
text[1].is_a?(Color) ? self.contents.font.color = text[1] : self.contents.font = text[1]
text = text[0]
end
if text.is_a?(String)
rect = contents.text_size(text)
rect.width = self.contents.width
self.contents.draw_text(rect,text,1)
end
@num = num
@nth = 0
@color = color
Graphics.update
end
def next(nth = 1)
@nth += nth
rect = Rect.new(0, 24, self.contents.width * @nth / @num, 24)
if @color.is_a?(Color)
self.contents.fill_rect(rect, @color)
elsif @color.is_a?(Array)
self.contents.gradient_fill_rect(rect, @color[0], @color[1])
else
rect.y = 0
self.contents.blt(0, 24, @color, rect)
end
Graphics.update
end
end
复制代码
简易图块扩张
#简易图块扩张 by zh99998 2008-11-1
#通行度无法更改
class Spriteset_Map
#在这里添加需要更改图块的地图ID等信息,每行一个地图
#格式: id => {"原文件名" => "新文件名"}
#或: id => {数字 => "新文件名"}
#或: id => [A1,A2,A3,A4,A5,B,C,D,E]
#数字与图块的对应关系:
# 0 => A1, 1 => A2, 2 => A3,
# 3 => A4, 4 => A5, 5 => B,
# 6 => C , 7 => D , 8 => E
#可以省略"Tile"和扩展名
#除了最后一行,其余的行尾加上逗号【,】
EXP = {
1 => {"A1" => "new_A1", 8 => "new_E"},
#示例:001号地图中,用new_A1文件代替TileA1,用new_E文件代替TileE
2 => ["new_A1", "A2", "A3", "A4", "A5", "new_B", "C", "new_D", "new_E"]
#示例:002号地图中,用new_A1文件代替TileA1,用new_B文件代替TileB,new_D代替TileD,new_E代替TileE
#在这里添加
}
def create_tilemap
@tilemap = Tilemap.new(@viewport1)
exp = EXP[$game_map.map_id]
if exp.is_a?(Hash)
bitmaps = ["TileA1", "TileA2", "TileA3", "TileA4", "TileA5", "TileB", "TileC", "TileD", "TileE"]
exp.each do |old, new|
case old
when 0, "A1", "TileA1"
bitmaps[0] = new
when 1, "A2", "TileA2"
bitmaps[1] = new
when 2, "A3", "TileA3"
bitmaps[2] = new
when 3, "A4", "TileA4"
bitmaps[3] = new
when 4, "A5", "TileA5"
bitmaps[4] = new
when 5, "B", "TileB"
bitmaps[5] = new
when 6, "C", "TileC"
bitmaps[6] = new
when 7, "D", "TileD"
bitmaps[7] = new
when 8, "E", "TileE"
bitmaps[8] = new
end
end
elsif exp.is_a?(Array)
bitmaps = exp
end
bitmaps.each_index do |index|
@tilemap.bitmaps[index] = Cache.system(bitmaps[index]) rescue Cache.system("Tile" + bitmaps[index])
end
@tilemap.map_data = $game_map.data
@tilemap.passages = $game_map.passages
end
end
复制代码
对话显名
# このサイトのスクリプトの名前空間。
module QuietLab
end
# このスクリプトの名前空間。
module QuietLab::Script_37
# このスクリプトのバージョンの日付表記。
Version = 2008_02_26
end
# 名前を表示するクラス。
class QuietLab::Script_37::Window_Name < Window_Base
# ウィンドウに表示する文字列。
attr_reader :text
# オブジェクトを初期化します。
def initialize(x = 0, y = 0)
super(x, y, 160, WLH + 32)
@text = ""
refresh
end
# 内容を再描画します。
def refresh
self.contents.clear
self.contents.draw_text(4, 0, self.width - 32 - 8, WLH, @text)
self.open if @text != ""
end
# 表示する文字列を設定します。位置は [ 0:左, 2:右 ] です。
def set_text(pos, val)
@text = val
self.x = (pos == 2 ? 544 - self.width : 0)
refresh
end
end
# メッセージウィンドウのクラス。
class Window_Message
#-- alias 定義
# 判別のため、メソッド名末尾に _by_QuietLab37 を付加します。
#++
alias :initialize_by_QuietLab37 :initialize
alias :dispose_by_QuietLab37 :dispose
alias :update_by_QuietLab37 :update
alias :create_gold_window_by_QuietLab37 :create_gold_window
alias :start_message_by_QuietLab37 :start_message
alias :reset_window_by_QuietLab37 :reset_window
alias :terminate_message_by_QuietLab37 :terminate_message
alias :update_message_by_QuietLab37 :update_message
# オブジェクトを初期化します。
def initialize
initialize_by_QuietLab37
create_name_window
end
# 使用しているウィンドウ・スプライトを解放します。
def dispose
dispose_by_QuietLab37
dispose_name_window
end
# ウィンドウを更新します。
def update
update_name_window
update_by_QuietLab37
end
# ゴールドウィンドウを作成します。
def create_gold_window
create_gold_window_by_QuietLab37
@gold_window.z = self.z + 1
end
# メッセージの表示処理を開始します。
def start_message
@name_window.close
start_message_by_QuietLab37
end
# ウィンドウの状態をリセットします。
def reset_window
reset_window_by_QuietLab37
if @position == 0
self.y = 24
@gold_window.y = -16
end
reset_name_window
end
# 発言者ウィンドウの位置をリセットします。
def reset_name_window
@name_window.opacity = self.opacity
@name_window.y = self.y - 40
end
# メッセージの表示処理を終了します。
def terminate_message
terminate_message_by_QuietLab37
@name_window.close
end
# メッセージの内容を更新します。
def update_message
loop do
case @text.slice(/./m)
when "\x0a"
@text.sub!(/\x0a\[(.*?)\]/, "")
n = $1
if $1 =~ /\d/ then
name = $game_actors[n.to_i].name
@name_window.set_text(0, name)
else
@name_window.set_text(0, n)
end
when "\x0b"
@text.sub!(/\x0b\[(.*?)\]/, "")
n = $1
if $1 =~ /\d/ then
name = $game_actors[n.to_i].name
@name_window.set_text(2, name)
else
@name_window.set_text(2, n)
end
else
break
end
break unless @show_fast or @line_show_fast
end
update_message_by_QuietLab37
end
# 表示する内容に含まれる特殊文字を変換します。
def convert_special_characters
# \ を変換(エスケープ処理のため)
@text.gsub!(/\\\\/) { "\x7f" }
# システム定義
@text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
@text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
@text.gsub!(/\\G/i) { "\x02" }
@text.gsub!(/\\\./) { "\x03" }
@text.gsub!(/\\\|/) { "\x04" }
@text.gsub!(/\\!/) { "\x05" }
@text.gsub!(/\\>/) { "\x06" }
@text.gsub!(/\\</) { "\x07" }
@text.gsub!(/\\\^/) { "\x08" }
#金钱单位
@text.gsub!(/\\I/i) { Vocab.gold }
# スクリプト定義
@text.gsub!(/\\WR\[(.*?)\]/i) { "\x0b[#{$1}]" }
@text.gsub!(/\\WR\[(.*?)\]/i) { "\x0b[#{$1}]" }
@text.gsub!(/\\WL?\[(.*?)\]/i) { "\x0a[#{$1}]" }
# \ を元の文字に戻す
@text.gsub!(/\x7f/) { "\\" }
end
# 発言者ウィンドウを作成します。
def create_name_window
@name_window = QuietLab::Script_37::Window_Name.new
@name_window.openness = 0
@name_window.z = self.z + 1
end
# 発言者ウィンドウを解放します。
def dispose_name_window
@name_window.dispose
end
# 発言者ウィンドウを更新します。
def update_name_window
@name_window.update
end
end
# 戦闘中に使用されるメッセージウィンドウのクラス。
class Window_BattleMessage
#-- alias 定義
# 判別のため、メソッド名末尾に _by_QuietLab37 を付加します。
#++
alias :reset_window_by_QuietLab37 :reset_window
# ウィンドウの状態をリセットします。
def reset_window
reset_window_by_QuietLab37
reset_name_window
end
end
# QuietLab ScriptFormat v1.12
复制代码
作者:
zh99998
时间:
2009-2-15 19:30
2楼XP
loading
#--------------------------------------------------------------------------
# ● Loading窗口·改
#--------------------------------------------------------------------------
class Loading < Window
attr_accessor :num
attr_accessor :nth
def initialize(num, texts = "Loading...", color = Color.new(255,255,255))
super()
self.x = 96
self.y = 192
self.width = 448
self.height = 80
self.contents = Bitmap.new(self.width-32, self.height-32)
@num = num
@nth = 0
@color = color
text = (texts)
end
def text=(text,nth=1)
self.contents.clear
if text.is_a?(Bitmap)
self.contents.blt((self.contents.width - text.width) / 2, 0, text, text.rect)
elsif text.is_a?(Array)
text[1].is_a?(Color) ? self.contents.font.color = text[1] : self.contents.font = text[1]
text = text[0]
end
if text.is_a?(String)
rect = contents.text_size(text)
rect.width = self.contents.width
self.contents.draw_text(rect,text,1)
end
run(nth)
end
def run(nth = 1)
@nth += nth
rect = Rect.new(0, 24, self.contents.width * @nth / @num, 24)
if @color.is_a?(Color)
self.contents.fill_rect(rect, @color)
elsif @color.is_a?(Array)
self.contents.gradient_fill_rect(rect, @color[0], @color[1])
else
rect.y = 0
self.contents.blt(0, 24, @color, rect)
end
Graphics.update
end
end
复制代码
作者:
zh99998
时间:
2009-2-15 19:30
数据相关
Tilemap by kissye
class Tilemap
FBLX = 544#x方向分辨率
FBLY = 416#y方向分辨率
SIZEX = 32
SIZEY = 32
ANI = 25#动画等待桢数
#以下画元件用
RECT1 = [Rect.new(0, 32, 16, 16), Rect.new(16, 32, 16, 16),
Rect.new(32, 32, 16, 16), Rect.new(48, 32, 16, 16),
Rect.new(0, 48, 16, 16), Rect.new(16, 48, 16, 16),
Rect.new(32, 48, 16, 16), Rect.new(48, 48, 16, 16),
Rect.new(0, 64, 16, 16), Rect.new(16, 64, 16, 16),
Rect.new(32, 64, 16, 16), Rect.new(48, 64, 16, 16),
Rect.new(0, 80, 16, 16), Rect.new(16, 80, 16, 16),
Rect.new(32, 80, 16, 16), Rect.new(48, 80, 16, 16),
Rect.new(32, 0, 16, 16), Rect.new(48, 0, 16, 16),
Rect.new(32, 16, 16, 16), Rect.new(48, 16, 16, 16)]
LIST1 = [[10, 9, 6, 5], [16, 9, 6, 5], [10, 17, 6, 5], [16, 17, 6, 5],
[10, 9, 6, 19], [16, 9, 6, 19], [10, 17, 6, 19], [16, 17, 6, 19],
[10, 9, 18, 5], [16, 9, 18, 5], [10, 17, 18, 5], [16, 17, 18, 5],
[10, 9, 18, 19], [16, 9, 18, 19], [10, 17, 18, 19], [16, 17, 18, 19],
[8, 9, 4, 5], [8, 17, 4, 5], [8, 9, 4, 19], [8, 17, 4, 19],
[2, 1, 6, 5], [2, 1, 6, 19], [2, 1, 18, 5], [2, 1, 18, 19],
[10, 11, 6, 7], [10, 11, 18, 7], [16, 11, 6, 7], [16, 11, 18, 7],
[10, 9, 14, 13], [16, 9, 14, 13], [10, 17, 14, 13], [16, 17, 14, 13],
[8, 11, 4, 7], [2, 1, 14, 13], [0, 1, 4, 5], [0, 1, 4, 19],
[2, 3, 6, 7], [2, 3, 18, 7], [10, 11, 14, 15], [16, 11, 14, 15],
[8, 9, 12, 13], [8, 17, 12, 13], [0, 3, 8, 11], [0, 1, 12, 13],
[4, 7, 12, 15], [2, 3, 14, 15], [0, 3, 12, 15]]
RECT2 = [Rect.new(0, 0, 16, 16), Rect.new(16, 0, 16, 16),
Rect.new(32, 0, 16, 16), Rect.new(48, 0, 16, 16),
Rect.new(0, 16, 16, 16), Rect.new(16, 16, 16, 16),
Rect.new(32, 16, 16, 16), Rect.new(48, 16, 16, 16),
Rect.new(0, 32, 16, 16), Rect.new(16, 32, 16, 16),
Rect.new(32, 32, 16, 16), Rect.new(48, 32, 16, 16),
Rect.new(0, 48, 16, 16), Rect.new(16, 48, 16, 16),
Rect.new(32, 48, 16, 16), Rect.new(48, 48, 16, 16)]
LIST2 = [[10, 9, 6, 5], [8, 9, 4, 5], [2, 1, 6, 5], [0, 1, 4, 5],
[10, 11, 6, 7], [8, 11, 4, 7], [2, 3, 6, 7], [0, 3, 8, 11],
[10, 9, 14, 13], [8, 9, 12, 13], [2, 1, 14, 13], [0, 1, 12, 13],
[10, 11, 14, 15], [4, 7, 12, 15], [2, 3, 14, 15], [0, 3, 12, 15]]
LIST3 = [[2, 1, 6, 5], [0, 1, 4, 5], [2, 3, 6, 7], [0, 3, 4, 7]]
#----------------------------------------------------------------------------
attr_accessor :bitmaps
attr_accessor :viewport
attr_reader :ox
attr_reader :oy
attr_reader :visible
attr_reader :passages
attr_reader :count
attr_reader :flash_data#不知道这个做什么用的
#----------------------------------------------------------------------------
def initialize(viewport = nil)
@shadow = Bitmap.new(SIZEX, SIZEY)
@shadow.fill_rect(0, 0, 17, SIZEY, Color.new(0, 0, 0, 120))#阴影
@viewport = viewport
@bitmaps = []
@backs = {}#元件精灵
@backbitmap = {}#元件图块
@switches = {}#动画开关
@count = 0#当前显示动画
@count1 = 0#等待桢数
@visible = true
@ox = 0
@oy = 0
@lastox = 0
@lastoy = 0
end
#----------------------------------------------------------------------------
def dispose
for i in @backbitmap.values
i.dispose
end
for i in @backs.values
i.dispose
end
@shadow.dispose
end
#---------------------------------------------------------------------------
def disposed?
return @shadow.disposed?
end
#---------------------------------------------------------------------------
def map_data=(value)
@map_data = value
#如果地图太大,按ESC打开菜单后返回地图太慢,下面这段循环可以不要
for i in 0...value.xsize
for j in 0...value.ysize
for k in 0..2
cachebitmap(value[i, j, k])
end
end
end
#如果地图太大,按ESC打开菜单后返回地图太慢,上面这段循环可以不要
#需要重新描绘的图快
if @map_data.xsize * SIZEX <= FBLX
rangei = (@ox / SIZEX - 1)..[((@ox + FBLX) / SIZEX), FBLX / SIZEX - 1].min
else
rangei = (@ox / SIZEX - 1)..((@ox + FBLX) / SIZEX)
end
if @map_data.xsize * SIZEX <= FBLX
rangej = (@oy / SIZEY - 1)..[((@oy + FBLY) / SIZEY), FBLY / SIZEY - 1].min
else
rangej = (@oy / SIZEY - 1)..((@oy + FBLY) / SIZEY)
end
for i in rangei
for j in rangej
for k in 0..2
draw(i, j, k)
end
end
end
end
#--------------------------------------------------------------------------
def refreshox
#需要释放掉的图块
rangej = (@lastoy / SIZEY - 1)..((@lastoy + FBLY) / SIZEY)
if @ox > @lastox
rangei = ((@lastox / SIZEX - 1)...(@ox / SIZEX - 1))
elsif @ox < @lastox
rangei = (((@ox + FBLX) / SIZEX + 1)..((@lastox + FBLX) / SIZEX))
end
for i in rangei
for j in rangej
for k in 0..3
next if @backs[[i, j, k]].nil?
@backs[[i, j, k]].dispose
@backs.delete([i, j, k])
@switches.delete([i, j, k])
end
end
end
#恢复走路时候的偏移
if @ox >= (@map_data.xsize * SIZEX - FBLX)
for i in @backs.keys
@backs[i].ox = 0
@backs[i].x = i[0] * SIZEX - @ox
if i[0] < (@ox / 32 - 1)
@backs[i].x += @map_data.xsize * SIZEX
elsif i[0] == -1
@backs[i].x = 0
end
end
else
for i in @backs.keys
@backs[i].ox = 0
@backs[i].x = i[0] * SIZEX - @ox
end
end
#需要重新描绘的图快
rangej = (@oy / SIZEY - 1)..((@oy + FBLY) / SIZEY)
if @ox > @lastox
rangei = ([((@lastox + FBLX) / SIZEX + 1), (@ox / SIZEX - 1)].max..((@ox + FBLX) / SIZEX))
elsif @ox < @lastox
rangei = ((@ox / SIZEX - 1)...[(@lastox / SIZEX - 1), (@ox + FBLX) / SIZEX + 1].min)
end
for i in rangei
for j in rangej
for k in 0..2
draw(i, j, k)
end
end
end
end
#--------------------------------------------------------------------------
def refreshoy
#需要释放掉的图块
rangei = (@lastox / SIZEX - 1)..((@lastox + FBLX) / SIZEX)
if @oy > @lastoy
rangej = ((@lastoy / SIZEY - 1)...(@oy / SIZEY - 1))
elsif @oy < @lastoy
rangej = (((@oy + FBLY) / SIZEY + 1)..((@lastoy + FBLY) / SIZEY))
end
for i in rangei
for j in rangej
for k in 0..3
next if @backs[[i, j, k]].nil?
@backs[[i, j, k]].dispose
@backs.delete([i, j, k])
@switches.delete([i, j, k])
end
end
end
#恢复走路时候的偏移
if @oy >= (@map_data.ysize * SIZEY - FBLY)
for i in @backs.keys
@backs[i].oy = 0
@backs[i].y = i[1] * SIZEY - @oy
if i[1] < (@oy / 32 - 1)
@backs[i].y += @map_data.ysize * SIZEY
elsif i[1] == -1
@backs[i].y = 0
end
end
else
for i in @backs.keys
@backs[i].oy = 0
@backs[i].y = i[1] * SIZEY - @oy
end
end
#需要重新描绘的图快
rangei = (@ox / SIZEX - 1)..((@ox + FBLX) / SIZEX)
if @oy > @lastoy
rangej = ([((@lastoy + FBLY) / SIZEY + 1), @oy / SIZEY - 1].max..((@oy + FBLY) / SIZEY))
elsif @oy < @lastoy
rangej = ((@oy / SIZEY - 1)...[(@lastoy / SIZEY - 1), ((@oy + FBLY) / SIZEY + 1)].min)
end
for i in rangei
for j in rangej
for k in 0..2
draw(i, j, k)
end
end
end
end
#--------------------------------------------------------------------------
#i为x坐标,j为y坐标,k为图层
def draw(i, j, k)
i0 = i
j0 = j
i -= @map_data.xsize if i >= @map_data.xsize
i += @map_data.xsize if i < 0
j -= @map_data.ysize if j >= @map_data.ysize
j += @map_data.ysize if j < 0
id = @map_data[i, j, k]
return if id == 0
unless @backs[[i, j, k]].nil?
unless @backs[[i, j, 3]].nil?
@backs[[i, j, 3]].x = i0 * SIZEX - @ox
@backs[[i, j, 3]].y = j0 * SIZEY - @oy
end
@backs[[i, j, k]].x = i0 * SIZEX - @ox
@backs[[i, j, k]].y = j0 * SIZEY - @oy
return
end
@backs[[i, j, k]] = Sprite.new(@viewport)
@backs[[i, j, k]].x = i0 * SIZEX - @ox
@backs[[i, j, k]].y = j0 * SIZEY - @oy
@backs[[i, j, k]].z = k * 2
@backs[[i, j, k]].bitmap = cachebitmap(id)
if id < 1024
elsif id < 1664
draw_shadow(i, j, k) if id >= 1552#阴影
elsif id < 2816
id1 = (id - 2048) / 48
unless [2, 3].include?(id1)#动画
@switches[[i, j, k]] = true
@backs[[i, j, k]].bitmap = @backbitmap[id + @count * 10000]
end
elsif id < 4352
id0 = (id - 2816) / 48 % 8
draw_shadow(i, j, k) #unless id0 == 6#阴影
#帮助手册中写A2每行第七个是不会被绘上阴影的,但实际有阴影,这里按照实际
@backs[[i, j, k]].z += 1 if id0 == 7#柜台
end
return if @passages.nil?
return unless @passages[id] == 22
@backs[[i, j, k]].z = 200
end
#---------------------------------------------------------------------------
def cachebitmap(id)
if @backbitmap[id].nil?
if id < 1024#B/C/D/E的情况
@backbitmap[id] = Bitmap.new(SIZEX, SIZEY)
bitmapid = id / 256 + 5
x = id % 256 / 128 * 8 * SIZEX + id % 256 % 128 % 8 * SIZEX
y = id % 256 % 128 / 8 * SIZEY
rect = Rect.new(x, y, SIZEX, SIZEY)
@backbitmap[id].blt(0, 0, @bitmaps[bitmapid], rect)
elsif id < 1664#A5的情况
@backbitmap[id] = Bitmap.new(SIZEX, SIZEY)
id0 = id - 1536
bitmapid = 4
x = id0 % 8 * SIZEX
y = id0 / 8 * SIZEY
rect = Rect.new(x, y, SIZEX, SIZEY)
@backbitmap[id].blt(0, 0, @bitmaps[bitmapid], rect)
elsif id < 2816#A1的情况
id0 = id - 2048
id1 = id0 / 48#编号,含义见附录
id2 = id0 % 48#含义见附录
bitmapid = 0
if id1 == 0#前四张排列比较特殊,浅海水域-深海水域-浅海装饰-深海装饰
x = 0
y = 0
@backbitmap[id] = drawbitmap1(x, y, id2, bitmapid)
x += 64
@backbitmap[id + 10000] = drawbitmap1(x, y, id2, bitmapid)
x += 64
@backbitmap[id + 20000] = drawbitmap1(x, y, id2, bitmapid)
elsif id1 == 1
x = 0
y = 96
@backbitmap[id] = drawbitmap1(x, y, id2, bitmapid)
x += 64
@backbitmap[id + 10000] = drawbitmap1(x, y, id2, bitmapid)
x += 64
@backbitmap[id + 20000] = drawbitmap1(x, y, id2, bitmapid)
elsif id1 == 2
x = 192
y = 0
@backbitmap[id] = drawbitmap1(x, y, id2, bitmapid)
elsif id1 == 3
x = 192
y = 96
@backbitmap[id] = drawbitmap1(x, y, id2, bitmapid)
elsif id1 % 2 == 0#从第五张开始就是水域-瀑布-水域-瀑布的顺序了
x = id1 / 4 % 2 * 256
y = id1 / 4 / 2 * 192 + id1 / 2 % 2 * 96
@backbitmap[id] = drawbitmap1(x, y, id2, bitmapid)
x += 64
@backbitmap[id + 10000] = drawbitmap1(x, y, id2, bitmapid)
x += 64
@backbitmap[id + 20000] = drawbitmap1(x, y, id2, bitmapid)
else
x = id1 / 4 % 2 * 256 + 192
y = id1 / 4 / 2 * 192 + id1 / 2 % 2 * 96
@backbitmap[id] = drawbitmap3(x, y, id2, bitmapid)
y += 32
@backbitmap[id + 10000] = drawbitmap3(x, y, id2, bitmapid)
y += 32
@backbitmap[id + 20000] = drawbitmap3(x, y, id2, bitmapid)
end
elsif id < 4352#A2的情况
id0 = id - 2816
id1 = id0 / 48#编号,含义见附录
id2 = id0 % 48#含义见附录
bitmapid = 1
x = id1 % 8 * 64
y = id1 / 8 * 96
if id1 % 8 == 7
@backbitmap[id] = drawbitmap4(x, y, id2, bitmapid)
else
@backbitmap[id] = drawbitmap1(x, y, id2, bitmapid)
end
elsif id < 5888#A3的情况
id0 = id - 4352
id1 = id0 / 48#编号,含义见附录
id2 = id0 % 48#含义见附录
bitmapid = 2
x = id1 % 8 * 64
y = id1 / 8 * 64
@backbitmap[id] = drawbitmap2(x, y, id2, bitmapid)
else#A4的情况
id0 = id - 5888
id1 = id0 / 48#编号,含义见附录
id2 = id0 % 48#含义见附录
bitmapid = 3
x = id1 % 8 * 64
if id1 % 16 < 8
y = id1 / 16 * 160
@backbitmap[id] = drawbitmap1(x, y, id2, bitmapid)
else
y = id1 / 16 * 160 + 96
@backbitmap[id] = drawbitmap2(x, y, id2, bitmapid)
end
end
end
return @backbitmap[id]
end
#---------------------------------------------------------------------------
#A1,A2
#此处的x,y指图片上的xy位置,id范围为0-48,id含义见附录
#i,j为地图上的xy位置,k为层数,bitmapid为源图片编号
def drawbitmap1(x, y, id, bitmapid)
bitmap = Bitmap.new(SIZEX, SIZEY)
rect = RECT1[LIST1[id][0]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 0, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][1]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 0, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][2]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 16, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][3]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 16, @bitmaps[bitmapid], rect)
return bitmap
end
#---------------------------------------------------------------------------
#A3
#此处的x,y指图片上的xy位置,id范围为0-48,id含义见附录
#i,j为地图上的xy位置,k为层数,bitmapid为源图片编号
def drawbitmap2(x, y, id, bitmapid)
bitmap = Bitmap.new(SIZEX, SIZEY)
rect = RECT2[LIST2[id][0]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 0, @bitmaps[bitmapid], rect)
rect = RECT2[LIST2[id][1]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 0, @bitmaps[bitmapid], rect)
rect = RECT2[LIST2[id][2]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 16, @bitmaps[bitmapid], rect)
rect = RECT2[LIST2[id][3]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 16, @bitmaps[bitmapid], rect)
return bitmap
end
#---------------------------------------------------------------------------
#瀑布
#此处的x,y指图片上的xy位置,id范围为0-48,id含义见附录
#i,j为地图上的xy位置,k为层数,bitmapid为源图片编号
def drawbitmap3(x, y, id, bitmapid)
bitmap = Bitmap.new(SIZEX, SIZEY)
rect = RECT2[LIST3[id][0]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 0, @bitmaps[bitmapid], rect)
rect = RECT2[LIST3[id][1]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 0, @bitmaps[bitmapid], rect)
rect = RECT2[LIST3[id][2]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 16, @bitmaps[bitmapid], rect)
rect = RECT2[LIST3[id][3]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 16, @bitmaps[bitmapid], rect)
return bitmap
end
#---------------------------------------------------------------------------
#柜台
#此处的x,y指图片上的xy位置,id范围为0-48,id含义见附录
#i,j为地图上的xy位置,k为层数,bitmapid为源图片编号
def drawbitmap4(x, y, id, bitmapid)
if [28, 29, 30, 31, 33].include?(id)#下
bitmap = Bitmap.new(SIZEX, 40)
rect = Rect.new(32, 48, 16, 16)
rect.x += x
rect.y += y
bitmap.blt(0, 16, @bitmaps[bitmapid], rect)
rect = Rect.new(16, 48, 16, 16)
rect.x += x
rect.y += y
bitmap.blt(16, 16, @bitmaps[bitmapid], rect)
elsif [38, 39, 45].include?(id)#右+下
bitmap = Bitmap.new(SIZEX, 40)
rect = Rect.new(32, 48, 16, 8)
rect.x += x
rect.y += y
bitmap.blt(0, 16, @bitmaps[bitmapid], rect)
rect = Rect.new(48, 48, 16, 8)
rect.x += x
rect.y += y
bitmap.blt(16, 16, @bitmaps[bitmapid], rect)
elsif [40, 41, 43].include?(id)#左+下
bitmap = Bitmap.new(SIZEX, 40)
rect = Rect.new(0, 48, 16, 8)
rect.x += x
rect.y += y
bitmap.blt(0, 16, @bitmaps[bitmapid], rect)
rect = Rect.new(16, 48, 16, 8)
rect.x += x
rect.y += y
bitmap.blt(16, 16, @bitmaps[bitmapid], rect)
elsif [44, 46].include?(id)#左+下+右
bitmap = Bitmap.new(SIZEX, 40)
rect = Rect.new(0, 48, 16, 8)
rect.x += x
rect.y += y
bitmap.blt(0, 16, @bitmaps[bitmapid], rect)
rect = Rect.new(48, 48, 16, 8)
rect.x += x
rect.y += y
bitmap.blt(16, 16, @bitmaps[bitmapid], rect)
else
bitmap = Bitmap.new(SIZEX, SIZEY)
rect = RECT1[LIST1[id][0]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 0, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][1]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 0, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][2]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 16, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][3]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 16, @bitmaps[bitmapid], rect)
return bitmap
end
rect = RECT1[LIST1[id][0]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 0, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][1]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 0, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][2]].clone
rect.x += x
rect.y += y
bitmap.blt(0, 24, @bitmaps[bitmapid], rect)
rect = RECT1[LIST1[id][3]].clone
rect.x += x
rect.y += y
bitmap.blt(16, 24, @bitmaps[bitmapid], rect)
return bitmap
end
#--------------------------------------------------------------------------
def draw_shadow(i, j, k)
return if k != 0
return if i == 0
i -= 1
id = @map_data[i, j, 0]
return if id < 4352
if id < 5888#A3的情况
id0 = id - 4352
id1 = id0 / 48#编号,含义见附录
id2 = id0 % 48#含义见附录
if [4, 5, 12].include?(id2)
nexts = true
elsif j == 0
elsif @map_data[i, j - 1, 0].between?(4352, 5888)
nexts = true
end
else#A4的情况
id0 = id - 5888
id1 = id0 / 48#编号,含义见附录
id2 = id0 % 48#含义见附录
if id1 % 16 < 8
if [24, 25, 26, 27, 32, 38, 39].include?(id2)
nexts = true
elsif j == 0
elsif @map_data[i, j - 1, 0] >= 5888
nexts = true
end
else
if [4, 5, 12].include?(id2)
nexts = true
elsif j == 0
elsif @map_data[i, j - 1, 0] >= 5888
nexts = true
end
end
end
return unless nexts
i += 1
@backs[[i, j, 3]] = Sprite.new(@viewport)
@backs[[i, j, 3]].bitmap = @shadow
@backs[[i, j, 3]].x = @backs[[i, j, 0]].x
@backs[[i, j, 3]].y = @backs[[i, j, 0]].y
@backs[[i, j, 3]].z = 0
end
#---------------------------------------------------------------------------
def passages=(value)
@passages = value
for i in ([@ox / SIZEX - 1, 0].max)..((@ox + FBLX) / SIZEX)
for j in ([@oy / SIZEY - 1, 0].max)..((@oy + FBLY) / SIZEY)
id = @map_data[i, j, 2]
next if id.nil?
next unless value[id] == 22
@backs[[i, j, 2]].z = 200
end
end
end
#---------------------------------------------------------------------------
#不知道这个做什么用的
def flash_data=(value)
@flash_data = value
end
#---------------------------------------------------------------------------
def update
if @count1 == ANI
@count1 = 0
self.count += 1
else
@count1 += 1
end
end
#---------------------------------------------------------------------------
def count=(value)
value = 0 if value >= 3
@count = value
for i in @switches.keys
id = @map_data[i[0], i[1], i[2]]
@backs[i].bitmap = @backbitmap[id + value * 10000]
end
end
#--------------------------------------------------------------------------
def visible=(value)
@visible = value
for i in @backs.values
i.visible = value
end
end
#--------------------------------------------------------------------------
def ox=(value)
if @ox != value
@ox = value
if value >= (@map_data.xsize * SIZEX - FBLX)
@lastox += @map_data.xsize * SIZEX if @lastox < (@ox - FBLX)
end
#人物走路时候
if @ox % SIZEX != 0
for i in @backs.values
i.ox = @ox - @lastox
end
else
refreshox
@lastox = @ox
end
end
end
#--------------------------------------------------------------------------
def oy=(value)
if @oy != value
@oy = value
if value >= (@map_data.ysize * SIZEY - FBLY)
@lastoy += @map_data.ysize * SIZEY if @lastoy < (@oy - FBLY)
end
#人物走路时候
if @oy % SIZEY != 0
for i in @backs.values
i.oy = @oy - @lastoy
end
else
refreshoy
@lastoy = @oy
end
end
end
end
复制代码
http://rpg.blue/viewthread.php?tid=105726
作者:
zh99998
时间:
2009-2-15 19:31
文件、RTP相关
API法复制文件 by 柳柳
Copy = Win32API.new('kernel32', 'CopyFileA',%(p p l), 'l')
复制代码
Copy.call(源文件,目标文件,0)
获取完整路径
#--------------------------------------------------------------------------
# ● 获取完整路径 by zh99998
#--------------------------------------------------------------------------
module GetPath
Readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')
def self.rtp(id=[])
dll = self.readini('.//Game.ini','Game', 'Library')
rgssgetatppath = Win32API.new(dll, "RGSSGetRTPPath", "l", "l")
rgssgetpathwithrtp = Win32API.new(dll, "RGSSGetPathWithRTP", "l", "p")
id.to_a
if id.empty?
id.push 1 unless self.readini('.//Game.ini','Game', 'RTP1').empty?
id.push 2 unless self.readini('.//Game.ini','Game', 'RTP2').empty?
id.push 3 unless self.readini('.//Game.ini','Game', 'RTP3').empty?
end
@result = []
id.each {|index|@result.push rgssgetpathwithrtp.call(rgssgetatppath.call(index)) + "/"}
return @result
end
def self.readini(filename,a,b='',c='')
temp = "\0" * 255
Readini.call(a, b, '', temp, 255, filename)
return temp.delete("\0")
end
Graphicskind = ["animations","autotiles","battlebacks","battlers","characters","fogs","gameovers","icons","panoramas","pictures","tilesets","titles","transitions"]
Audiokind = ["bgm","bgs","me","se"]
GraphicsExt = ["png","jpg",""]
AudioExt = ["mid","ogg","wma","mp3","wav",""]
Path = self.rtp.unshift("")
def self.get(filename, kind)
filename.downcase!
kind.downcase!
kind += s if Graphicskind.include?(kind + "s")
if Graphicskind.include?(kind)
filename.insert(0, "Graphics/" + kind + "/")
exts = GraphicsExt
else
filename.insert(0, "Audio/" + kind + "/")
exts = AudioExt
end
Path.each do |path|
exts.each do |ext|
file = path + filename
file += "." + ext unless ext.empty?
return file if FileTest.exist?(file)
end
end
end
end
复制代码
GetPath.rtp([RTP编号]) 获取指定编号的RTP路径,参数不填为获取所有RTP
GetPath.readini(文件,参数1,[参数2,[参数3]])
GetPath.get(文件名,文件类型) 获取文件的路径
作者:
zh99998
时间:
2009-2-15 19:35
其他
作者:
zh99998
时间:
2009-2-15 19:37
占楼备用
作者:
zh99998
时间:
2009-2-15 19:46
占楼备用
[LINE]1,#dddddd[/LINE]
{/fd}▼楼下抢地盘?!
作者:
chenyin
时间:
2009-2-15 20:03
对话框背景效果
class Window_Message < Window_Selectable
PIC1 = "1"
PIC2 = "2"
SPEED = 1
alias initialize_via initialize
def initialize
@vie = Viewport.new(0, 288, 544, 128)
@vie.z = 0
@pic1 = Sprite.new(@vie)
@pic2 = Sprite.new(@vie)
@pic1.opacity, @pic2.opacity = 128, 128
@pic1.x, @pic1.y, @pic2.x, @pic2.y = 0, 0, 0, 0
@pic1.bitmap = Bitmap.new("Graphics/Pictures/#{PIC1}")
@pic2.bitmap = Bitmap.new("Graphics/Pictures/#{PIC2}")
initialize_via
update
end
alias update_via update
def update
if self.openness == 255
@pic1.visible=true
@pic2.visible=true
else
@pic1.visible=false
@pic2.visible=false
end
@pic1.y -= SPEED * 2
@pic2.y -= SPEED
@pic1.y = 0 if @pic1.y == -160
@pic2.y = 0 if @pic2.y == -160
update_via
end
alias dispose_via dispose
def dispose
@vie.dispose
@pic1.bitmap.dispose
@pic2.bitmap.dispose
@pic1.dispose
@pic2.dispose
dispose_via
end
end
class Window_Message < Window_Selectable
SoundFile = "Audio/SE/键盘声1" #声音文件
WaitTime = 2 #等待时间,为了防止过于频繁播放声音
alias update_message_sound update_message
def update_message
update_message_sound
if !@waittime
@waittime = WaitTime
elsif @waittime < WaitTime
@waittime += 1
else
Audio.se_play(SoundFile,80) #可以在括号里再加上音量音调,用逗号隔开
@waittime = 0
end
end
end
复制代码
范例地址:
http://rpg.blue/upload_program/d/chenyin_脚本1_115194223.rar
------------------------------------------------------------------------------------
这个脚本仓库也借我用用吧。- -
作者:
hitlerson
时间:
2009-2-15 20:29
你的LOADING在哪里判断游戏加载进度的?
作者:
zh99998
时间:
2009-2-15 21:00
以下引用
hitlerson于2009-2-15 12:29:27
的发言:
你的LOADING在哪里判断游戏加载进度的?
nth
作者:
hitlerson
时间:
2009-2-15 21:19
这个nth是nth+=1出来的,不是getBytesTotal()啊
作者:
zh99998
时间:
2009-2-15 21:41
跟BytesTotal有什么关系- -
范例
http://rpg.blue/viewthread.php?tid=108703&ntime=2009%2D2%2D15+13%3A42%3A22
作者:
Earth
时间:
2009-2-15 21:47
占楼备用……
[LINE]1,#dddddd[/LINE]
也借我用用吧……{/dy}
作者:
zh99998
时间:
2009-2-16 02:42
楼上是蓝雪乎?
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1