设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 99|回复: 0

[转载发布] Glitch Effects v1.0

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9015

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 昨天 15:52 | 显示全部楼层 |阅读模式
    Pasp's Glitch Effects v1.0







    This script can be used to create a "glitching" effect over the current screen, with the option to add a sound effect as well.

    Instructions:
    Place script below Materials and above Main

    Use the script call "show_glitch" when you want to have a glitching effect. "show_glitch" can be used with the defaults, or with the arguments intensity, duration, volume, and pitch in that order.

    For example:
                    Ruby:       
    1. show_glitch(10,20,100,50)
    复制代码

    This will create a glitch effect with a maximum pixel shift of 10 pixels that lasts for 20 frames, with a sound effect volume of 100 and sound effect pitch of 50.
    The default values are intensity = 5, duration = 3, volume = 100, and pitch = 100.

    User Settings:
    The user can set the ID for a switch to turn the glitch sound effect on and off using GLITCH_AUDIO_SWITCH. Setting the switch ID to 0 will disable glitch sound effects.
    The sound effect file name is set using the variable AUDIO_FILE. The sound effect must be in the SE folder.
    The sound effect pitch and volume can also be randomly tweaked when RANDOM_PITCH and RANDOM_VOL are set to true, for extra glitchiness.

    History:
    June 10, 2026: v1.0 release

    Terms:
    Can be used in free and commercial games or modified however you like, but please credit!

    Code:
    Spoiler                Ruby:       
    1. #===============================================================================
    2. # Pasp's Glitch Effects v1.0
    3. #-------------------------------------------------------------------------------
    4. # Can be used to create a "glitching" effect over the current screen, with
    5. # the option to add a sound effect as well.
    6. #-------------------------------------------------------------------------------
    7. # Instructions:
    8. # Place script below Materials and above Main
    9. #
    10. # Use the script call "show_glitch" when you want to have a glitching effect
    11. # "show_glitch" can be used with the defaults, or with the arguments intensity,
    12. # duration, volume, and pitch in that order.
    13. #
    14. # For example: show_glitch(10,20,100,50)
    15. # This will create a glitch effect with a maximum pixel shift of 10 pixels that
    16. # lasts for 20 frames, with a sound effect volume of 100 and sound effect pitch
    17. # of 50.
    18. # Default values are intensity = 5, duration = 3, volume = 100, and pitch = 100
    19. #-------------------------------------------------------------------------------
    20. # History:
    21. # June 10, 2026: v1.0 release
    22. #-------------------------------------------------------------------------------
    23. # Terms:
    24. # Can be used in free and commercial games or modified however you like, but
    25. # please credit!
    26. #===============================================================================
    27. module GLITCH_USER_SETTINGS
    28.   # Switch to turn on and off glitch sound effects. Set to 0 to disable sound
    29.   # effects altogether
    30.   GLITCH_AUDIO_SWITCH = 0
    31.   # Name of audio file to use for glitch effects. Must be in the SE folder
    32.   AUDIO_FILE = ""
    33.    
    34.   # Set to "true" to randomize glitch sound effect pitch by +/- 25; otherwise
    35.   # set to false
    36.   RANDOM_PITCH = true
    37.   # Set to "true" to randomize glitch sound effect volume by +/- 25; otherwise
    38.   # set to false
    39.   RANDOM_VOL = true
    40. end #GLITCH_USER_SETTINGS
    41. #===============================================================================
    42. # Edit below at your own risk!
    43. #===============================================================================
    44. module Glitch
    45.   #-----------------------------------------------------------------------------
    46.   # * Apply Glitch Effect
    47.   #   Creates the glitched bitmap from a snap of the current screen
    48.   #-----------------------------------------------------------------------------
    49.   def self.apply_glitch_effect(intensity)
    50.     source = Graphics.snap_to_bitmap
    51.     result = Bitmap.new(Graphics.width, Graphics.height)
    52.    
    53.     y = 0
    54.     while y < Graphics.height
    55.       shift = rand(intensity * 2 + 1) - intensity
    56.       
    57.       src_rect = Rect.new(0, y, Graphics.width, 1)
    58.       result.blt(shift, y, source, src_rect)
    59.       
    60.       y += 1
    61.     end
    62.    
    63.     source.dispose
    64.     return result
    65.   end
    66.   #-----------------------------------------------------------------------------
    67.   # * Play Glitch SE
    68.   #   Plays a glitch sound effect, if enabled
    69.   #-----------------------------------------------------------------------------
    70.   def self.play_glitch_se(volume,pitch)
    71.     return if GLITCH_USER_SETTINGS::GLITCH_AUDIO_SWITCH <= 0
    72.     return unless $game_switches[GLITCH_USER_SETTINGS::GLITCH_AUDIO_SWITCH]
    73.     return if GLITCH_USER_SETTINGS::AUDIO_FILE.strip.empty?
    74.    
    75.     audio_path = "Audio/SE/" + GLITCH_USER_SETTINGS::AUDIO_FILE
    76.    
    77.     rng_vol = volume
    78.     if GLITCH_USER_SETTINGS::RANDOM_VOL
    79.       rng_vol = [[(rand(51) + volume - 25),100].min,0].max
    80.     end
    81.       
    82.     rng_pitch = pitch
    83.     if GLITCH_USER_SETTINGS::RANDOM_PITCH
    84.       rng_pitch = [[(rand(51) + pitch - 25),150].min,50].max
    85.     end
    86.    
    87.     Audio.se_play(audio_path,rng_vol,rng_pitch)
    88.   end
    89. end #Glitch
    90. #===============================================================================
    91. # ** Game_Interpreter
    92. #===============================================================================
    93. class Game_Interpreter
    94.   #-----------------------------------------------------------------------------
    95.   # * Show Glitch
    96.   #   Can be called to display glitch effect
    97.   #-----------------------------------------------------------------------------
    98.   def show_glitch(intensity=5,duration=3,volume=100,pitch=100)   
    99.     Glitch.play_glitch_se(volume,pitch)
    100.     bitmap = Glitch.apply_glitch_effect(intensity)
    101.    
    102.     glitch_sprite = Sprite.new
    103.     glitch_sprite.bitmap = bitmap
    104.     glitch_sprite.z = 999
    105.     duration.times { Graphics.update }
    106.    
    107.     glitch_sprite.bitmap.dispose
    108.     glitch_sprite.dispose
    109.     glitch_sprite = nil
    110.   end
    111. end
    复制代码





    Pastebin link


    本贴来自国际rpgmaker官方论坛作者:Pasp处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/glitch-effects-v1-0.183987/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-4 17:32 , Processed in 0.079816 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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