设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
返回列表
+ 发新帖
查看: 549|回复: 0

[转载发布] RGSS1实用"扩展库"

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    3 天前
  • 签到天数: 221 天

    连续签到: 1 天

    [LV.7]常住居民III

    9100

    主题

    890

    回帖

    7万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    64872
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    74892

    灌水之王

    发表于 2024-4-19 19:26:28 | 显示全部楼层 |阅读模式
    清单
    1.[方便] 随机播放BGM
    2.[扩展] 获取mp3文件时间长度 (有bug  ←等于没说)
    3.[扩展] Graphics块 模仿 RGSS2部分功能
    4.[扩展] Bitmap类   模仿 RGSS2部分功能
    5.[美化] 真 窗口移动
    6.[美化] 伪 窗口移动
    7.[扩展] 子选项窗口(http://rpg.blue/thread-174280-1-1.html)

    脚本如下:
    1+2 :使用方法 脚本置顶
    1.Audio.random_bgm_play
    2.Audio.mp3_length(name)   name = mp3文件名

    3:模仿RGSS2清单:
    1.等待指定帧数
    Graphics.wait(n)
    n = 帧数

    加上了扩展(代码块)
    Graphics.wait(n){...}

    比如向左移动一窗口55像素
    原来是:
    55.times{Graphics.update;窗口.x -= 1}
    现在
    Graphics.wait(55){窗口.x -= 1}
    (好像没区别...?)

    2.更改窗口大小
    Graphics.resize_screen(width, height)
    width = 宽   height 高

    3+4:获取窗口宽 高
    Graphics.width   Graphics.height

    4:(原    ——by 猫哥哥  改    ——by 沙漠.灰(未经过原作者同意,请见谅))[code]#==============================================================================# ■ Bitmap#------------------------------------------------------------------------------#    位图类    RGSS扩充#                  原    ——by 猫哥哥#                  改    ——by 沙漠.灰          #=============================================================================#class Bitmap  #--------------------------------------------------------------------------  # ● 渐进色彩填充  #    vertical : 横(竖)填充  #--------------------------------------------------------------------------  def gradient_fill_rect(x,y,width,height=false,color1=255,color2=nil,vertical=false,opacity=255)    # 矩形判断    if x.is_a?(Rect)      s1,s2,s3,s4=x.x,x.y,x.width,x.height      return self.gradient_fill_rect(s1,s2,s3,s4,y,width,height,color1)    end    # 渐进步长(step)判断    vertical == false ? step = width - x : step = height - y;color = color1;color.alpha = opacity    # 渐进_红    key_re = Math.sqrt(((color2.red   - color1.red  )/step)**2)    # 渐进_绿    key_gr = Math.sqrt(((color2.green - color1.green)/step)**2)    # 渐进_蓝    key_bl = Math.sqrt(((color2.blue  - color1.blue )/step)**2)    # 反渐进方向判断    key_re *= -1 if color2.red  < color1.red    key_gr *= -1 if color2.green< color1.green    key_bl *= -1 if color2.blue < color1.blue    # 横(竖)填充    if vertical        (height-y).times{          self.fill_rect(x, y, width, 1, color)          y=y+1;color.red =color.red + key_re          color.green =color.green + key_gr;color.blue =color.blue + key_bl         }    else      (width-x).times{          self.fill_rect(x, y, 1, height, color)          x=x+1;color.red =color.red + key_re          color.green =color.green + key_gr;color.blue =color.blue + key_bl      }    end  end  #--------------------------------------------------------------------------  # ● 清除位图指定地方  #--------------------------------------------------------------------------     def clear_rect(x, y=0,width=0,height=0)    # 矩形判断    if x.is_a?(Rect)      self.fill_rect(x,Color.new(0,0,0,0))    else      self.fill_rect(x, y, width, height, Color.new(0,0,0,0))     end  end  #--------------------------------------------------------------------------  # ● 位图重叠模糊(壳)  #--------------------------------------------------------------------------   def fragment_bluring(blur=4,during=3)    for i in 1..blur      self.fragment_blur(i)      self.blt(0, 0, self, self.rect)      during.times{Graphics.update}        end  end  #--------------------------------------------------------------------------  # ● 模糊算法(壳)  #     times      重做模糊次数  #     during     经历帧数  #     blur       分散半径  #--------------------------------------------------------------------------     def blur(times=1,during =1,blur=1)    times.times{blur_r(blur);during.times{Graphics.update if during >1}}   end  #--------------------------------------------------------------------------  # ● 玻璃(半透明)渐进填充  #    vertical   横(竖)渐进  #--------------------------------------------------------------------------      def glass_fill_rect(x, y=nil,width=nil,height=false,color1=nil,color2=nil,vertical=false)    # 矩形判断    if x.is_a?(Rect)      s1,s2,s3,s4=x.x,x.y,x.width,x.height      return self.glass_fill_rect(s1,s2,s3,s4,y,width,height)    end    # 生成临时位图    a1 = Bitmap.new(width, height);a2 = Bitmap.new(width, height)    # 并填充    a1.fill_rect(x, y, width, height, color1);a2.fill_rect(x, y, width, height, color2)    # 横(竖)渐进    unless vertical      key =[[255.0/(width - x),255.0].min,1.0].min      src_rect = Rect.new(x,y,1,height);k = x      for i in x..width        self.blt(x, y, a1, src_rect, (width-i)*key)        self.blt(x, y, a2, src_rect, (i-k)*key)        x += 1      end    else      key =[[255.0/(height - x),255.0].min,1.0].min      src_rect = Rect.new(x,y,width,1);k = y      for i in y..height        self.blt(x, y, a1, src_rect, (height-i)*key)        self.blt(x, y, a2, src_rect, (i-k)*key)        y += 1      end    end    # 释放临时位图    a1.dispose;a2.dispose  end  # 以下方法私有化  private  #--------------------------------------------------------------------------  # ● 位图重叠模糊(执行)  #--------------------------------------------------------------------------    def fragment_blur(radius=6)    src_bitmap = self;rect = self.rect;key = 255/7    self.blt(0,0,src_bitmap,rect,key*4)    self.blt(0,-radius,src_bitmap,rect,key*2)    self.blt(radius,0,src_bitmap,rect,key*2)    self.blt(-radius,0,src_bitmap,rect,key*2)    self.blt(0,radius,src_bitmap,rect,key*2)    self.blt(radius,-radius,src_bitmap,rect,key*1)    self.blt(-radius,radius,src_bitmap,rect,key*1)    self.blt(-radius,-radius,src_bitmap,rect,key*1)    self.blt(radius,radius,src_bitmap,rect,key*1)  end  #--------------------------------------------------------------------------  # ● 模糊算法(执行)  #      radius          分散半径  #      p.s. 写得好乱...和我有的一拼,不过好多废代码....  #--------------------------------------------------------------------------    def blur_r(radius = 2)    # 分散半径值修正    radius = [radius,1].max    src_bitmap = self    rect = self.rect        ta_l = 1+radius*2    ta = Table.new(ta_l,ta_l)  #过滤器         ta_l.times{|i|ta_l.times{|j|ta[i,j] = 1}}    ta[((ta.xsize+1)/2)-1,((ta.xsize+1)/2)-1] = 2**(1+radius)    main = ta[((ta.xsize+1)/2)-1,((ta.xsize+1)/2)-1]#找到中心点    nn = 2;j = ((ta.xsize+1)/2)-1;line =[]#主干道        for i in 0..((ta.xsize+1)/2)-2      ta[i,j] = nn      ta[j,i] = nn      ta[ta.xsize-1-i,j] = nn      ta[j,ta.xsize-1-i] = nn      line.push ta[i,((ta.xsize+1)/2)-1]      nn *= 2    end        for j in 0...line.size       for i in 0..((ta.xsize+1)/2)-2        line[j] = line[j]/2        break if line[j] == 1        ta[((ta.xsize+1)/2)-2-i ,j           ] = line[j]        ta[((ta.xsize+1)/2)+i   ,j           ] = line[j]        ta[((ta.xsize+1)/2)-2-i ,ta.xsize-1-j] = line[j]        ta[((ta.xsize+1)/2)+i   ,ta.xsize-1-j] = line[j]      end    end        key_a = [];key_p = main    for i in 1..main      if key_p == 1        key_a

    帖子地址: 

    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-10-20 03:23 , Processed in 0.102158 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表