设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: 七夕小雨

[15VIP]MTV脚本VX化~

 关闭 [复制链接]

Lv1.梦旅人

昨日的黄昏

梦石
0
星屑
106
在线时间
936 小时
注册时间
2006-11-5
帖子
4128

第2届短篇游戏比赛季军第3届短篇游戏大赛小游戏及其他组季军

 楼主| 发表于 2008-1-21 04:54:26 | 显示全部楼层
以下引用美兽于2008-1-20 18:02:52的发言:


谢谢,我明天来看看。

谢谢兽大人~~{/hx}
[url=http://weibo.com/2238291690?s=6uyXnP]
回复 支持 反对

使用道具 举报

Lv1.梦旅人

彩色的银子

梦石
0
星屑
50
在线时间
190 小时
注册时间
2006-6-13
帖子
1361

贵宾

发表于 2008-1-21 05:42:01 | 显示全部楼层
MTV脚本?
是..AVI播放那个?..
还是显示歌词那个?
-.-
回复 支持 反对

使用道具 举报

Lv1.梦旅人

最BT美攻!

梦石
0
星屑
50
在线时间
3 小时
注册时间
2007-3-7
帖子
1407
发表于 2008-1-21 09:49:53 | 显示全部楼层
太感谢了
小雨和美兽真是造福大众啊~~

期待成品
骑士の圣堂最终版华丽丽登场~~

http://rpg.blue/viewthread.php?tid=116851
AVG原创自制游戏  
神の大陆出品
神之大陆游戏制作小组唯美为主BT为终(偏BL向)
欢迎来搅合BLOG:http://hi.baidu.com/tranpol
官网:http://tierradesagrado.uueasy.com/
回复 支持 反对

使用道具 举报

Lv1.梦旅人

昨日的黄昏

梦石
0
星屑
106
在线时间
936 小时
注册时间
2006-11-5
帖子
4128

第2届短篇游戏比赛季军第3届短篇游戏大赛小游戏及其他组季军

 楼主| 发表于 2008-1-21 11:36:33 | 显示全部楼层
以下引用神思于2008-1-20 21:42:01的发言:

MTV脚本?
是..AVI播放那个?..
还是显示歌词那个?


[本贴由作者于 2008-1-20 21:42:38 最后编辑]


显示歌词那个啦~~~
[url=http://weibo.com/2238291690?s=6uyXnP]
回复 支持 反对

使用道具 举报

Lv1.梦旅人

月下可怜人

梦石
0
星屑
50
在线时间
10 小时
注册时间
2005-11-23
帖子
4085

第1届短篇游戏比赛亚军

发表于 2008-1-21 18:18:18 | 显示全部楼层
利用面粉的优化版修改,版权还是归原作者,与我无关。


  1. #======================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #======================================================================

  4. #==============================================
  5. # 增加两个用来进行条件判断的临时变量
  6. #==============================================
  7. class Game_Temp
  8.    attr_accessor :old_text
  9.    attr_accessor :refresh_times
  10. alias meanfree_initialize initialize
  11. def initialize
  12.   meanfree_initialize
  13.   @old_text = ""
  14.   @refresh_times = 0
  15. end
  16. end

  17. module MTV  
  18. #===============================================================
  19. # 读取文件。文件相对地址:Audio/BGM
  20. # file_name:文件名;length:MTV长度,按照.1秒为单位记数
  21. #===============================================================
  22. def self.load(file_name,length = 0)
  23.   $mtv_time = []
  24.   $mtv_text = []
  25.   $game_system.mtv_length = length
  26.   #=============================================================
  27.   # 打开文件并且读取之
  28.   #=============================================================
  29.   file =  File.open("Audio/BGM/"+file_name)
  30.   #=============================================================
  31.   # 读取歌词
  32.   #=============================================================
  33.   for line in file.readlines
  34.     #===========================================================
  35.     # 转为UTF-8编码
  36.     #===========================================================
  37.     line = EasyConv.s2u(line)
  38.     #===========================================================
  39.     # 寻找本行歌词
  40.     #===========================================================
  41.     this_line_text = line[line.scan(/\]/).size*10,line.size]
  42.     #===========================================================
  43.     # 把读取的行分存成时间与文字
  44.     #===========================================================
  45.     for i in 0...line.scan(/\]/).size
  46.       temp_b = line[i*10+1,8]
  47.       temp_c = temp_b.split(/:/)[0]
  48.       mmsecond = 600 * temp_c.to_i
  49.       temp_c = temp_b.split(/:/)[1]
  50.       mmsecond += 10 * temp_c.to_f
  51.       $mtv_time.push(mmsecond.to_i)
  52.       $mtv_text.push(this_line_text)
  53.     end
  54.   end
  55.   file.close
  56. end
  57. #===============================================================
  58. # 开始MTV字幕
  59. #===============================================================
  60. def self.mtv_begin
  61.   $game_system.mtv_now = true
  62.   $game_system.mtv_begin_time = $sys_timer.now()
  63.   $lrc_text = ""
  64.   return
  65. end
  66. #===============================================================
  67. # 结束MTV字幕
  68. #===============================================================
  69. def self.stop
  70.   $game_system.mtv_now = false
  71.   return
  72. end
  73. #===============================================================
  74. # 测试MTV是否播放
  75. #===============================================================
  76. def self.mtv?
  77.   return $game_system.mtv_now
  78. end
  79. #===============================================================
  80. # 获取MTV字幕
  81. #===============================================================
  82. def self.new_text
  83.   if $game_system.mtv_now
  84.     #===========================================================
  85.     # 求出已经经过的时间
  86.     #===========================================================
  87.     nt = $sys_timer.now()
  88.     nt -= $game_system.mtv_begin_time
  89.     nt = nt.to_i
  90.     nt /= 100      
  91.     #===========================================================
  92.     # 制作循环
  93.     #===========================================================
  94.     if $game_system.mtv_length>0 and nt > $game_system.mtv_length
  95.       nt -= $game_system.mtv_length
  96.     end
  97.     #===========================================================
  98.     # 放出字幕
  99.     #===========================================================
  100.     for tm in 0...$mtv_time.size
  101.       if $mtv_time[tm] == nt
  102.         $lrc_text = $mtv_text[tm]
  103.         #=======================================
  104.         # 时间有限
  105.         $game_temp.old_text = $lrc_text
  106.         $game_temp.refresh_times += 1
  107.         # 面粉无敌
  108.         #=======================================
  109.         break
  110.       end
  111.     end
  112.   else
  113.     $lrc_text = ""
  114.   end
  115. end
  116. end
  117. # --------------------------------------------------------------------

  118. # 高精度计时器 by FantasyDR
  119. # --------------------------------------------------------------------


  120. # E-mail: [email protected]
  121. # --------------------------------------------------------------------

  122. # 2005.10.18
  123. # --------------------------------------------------------------------


  124. # 该类已经被定义为全局变量 $sys_timer
  125. # 如果只需要精确到毫秒,请设置初始化参数为true
  126. # decimal属性设置返回时间值的小数位数。
  127. # --------------------------------------------------------------------


  128. # 下面是一些有用的方法列表,调用时写:$sys_timer.方法名
  129. # 例如 $sys_timer.clear()
  130. # --------------------------------------------------------------------


  131. # clear() :计时器清零
  132. # now() :获取当前经过的时间,单位毫秒
  133. # now_s() :获取当前经过的时间,单位秒
  134. # --------------------------------------------------------------------


  135. class SystemTimer
  136. attr_accessor:decimal #小数位数设定,默认为3

  137. def initialize(use_GetTime=false)
  138. # 初始化,根据系统选择不同精度计时器
  139. @qpFrequency = Win32API.new("kernel32","QueryPerformanceFrequency",'p','L')
  140. @qpCounter = Win32API.new("kernel32","QueryPerformanceCounter",'p','L')
  141. @tGetTime = Win32API.new("winmm","timeGetTime",'','L')

  142. @decimal=3
  143. @perf_cnt=" " * 8
  144. @time_start=" " * 8
  145. @time_now=" " * 8

  146. result = @qpFrequency.call(@perf_cnt)

  147. if use_GetTime
  148. result = 0
  149. end

  150. if result!=0
  151. @perf_flag=true
  152. else
  153. @perf_flag=false
  154. @perf_cnt=[1000,0].pack('LL')
  155. end

  156. #设置时间比例因数
  157. @time_scale=@perf_cnt.unpack('LL')
  158. @time_scale[0] /= 1000.0
  159. @time_scale[1] /= 1000.0

  160. #起始时间清零
  161. self.clear()
  162. end

  163. #-=====================-#
  164. # 计时器清零
  165. #-=====================-#
  166. def clear()
  167. if @perf_flag
  168. @qpCounter.call(@time_start)
  169. else
  170. @time_start=[@tGetTime.call(),0].pack('LL')
  171. end
  172. end

  173. #-==============================-#
  174. # 获取当前经过的时间,单位毫秒
  175. #-==============================-#
  176. def now()
  177. now_time = 0.0e1
  178. now_time += self.timer() - self.start()
  179. now_time /= self.scale()
  180. return self.debug(now_time)
  181. end

  182. #-==============================-#
  183. # 获取当前经过的时间,单位秒
  184. #-==============================-#
  185. def now_s()
  186. now_time = 0.0e1
  187. now_time += self.timer() - self.start()
  188. now_time /= (self.scale()*1000)
  189. return self.debug(now_time)
  190. end

  191. #-==============================-#
  192. # 帧错...
  193. #-==============================-#
  194. def debug(now_time)
  195. if @decimal>0
  196. now_time = (now_time * (10**@decimal)).floor/(10.0**@decimal)
  197. else
  198. now_time = now_time.floor
  199. end
  200. return now_time

  201. #以下用于debug模式
  202. if now_time < 0
  203. p "Timer Wrong!! Clear...",now_time,@perf_flag,@qpCounter,@tGetTime,
  204. @time_now.unpack('LL')[0],@time_now.unpack('LL')[1],
  205. @time_start.unpack('LL')[0],@time_start.unpack('LL')[1]
  206. self.clear()
  207. return 0.0
  208. else
  209. return now_time
  210. end
  211. end

  212. #-=====================-#
  213. # 获取时间比例因数
  214. #-=====================-#
  215. def scale()
  216. return @time_scale[0]+@time_scale[1]*0xffffffff
  217. end

  218. #-=====================-#
  219. # 获取起始滴答数
  220. #-=====================-#
  221. def start()
  222. return @time_start.unpack('LL')[0]+@time_start.unpack('LL')[1]*0xffffffff
  223. end

  224. #-=====================-#
  225. # 获取当前的嘀哒数
  226. #-=====================-#
  227. def timer()
  228. if @perf_flag
  229. @qpCounter.call(@time_now)
  230. else
  231. @time_now=[@tGetTime.call(),0].pack('LL')
  232. end
  233. return @time_now.unpack('LL')[0]+@time_now.unpack('LL')[1]*0xffffffff
  234. end
  235. end
  236. #-------------------------------------#
  237. # 初始化自身成一个全局变量
  238. #-------------------------------------#
  239. $sys_timer=SystemTimer.new()
  240. #-------------------------------------#

  241. #======================================================================

  242. # 仭 EasyConv module - Ver 0.90
  243. #---------------------------------------------------------------------

  244. # Moonlight INN
  245. # http://cgi.members.interq.or.jp/aquarius/rasetsu/
  246. # RaTTiE
  247. # [email protected]
  248. #------------------------------------------------------------
  249. # EasyConv::s2u(text) : S-JIS -> UTF-8
  250. # EasyConv::u2s(text) : UTF-8 -> S-JIS
  251. #======================================================================

  252. module EasyConv
  253. # API梡掕悢掕媊
  254. CP_ACP = 0
  255. CP_UTF8 = 65001

  256. #---------------------------------------------------------------------

  257. # 仠 S-JIS -> UTF-8
  258. #---------------------------------------------------------------------

  259. def s2u(text)
  260. # API掕媊
  261. m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  262. w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

  263. # S-JIS -> Unicode
  264. len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
  265. buf = "\0" * (len*2)
  266. m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);

  267. # Unicode -> UTF-8
  268. len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  269. ret = "\0" * len
  270. w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);

  271. return ret
  272. end
  273. # module_function偲偟偰岞奐
  274. module_function :s2u
  275. #---------------------------------------------------------------------

  276. # 仠 UTF-8 -> S-JIS
  277. #---------------------------------------------------------------------

  278. def u2s(text)
  279. # API掕媊
  280. m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  281. w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

  282. # UTF-8 -> Unicode
  283. len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
  284. buf = "\0" * (len*2)
  285. m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);

  286. # Unicode -> S-JIS
  287. len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
  288. ret = "\0" * len
  289. w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);

  290. return ret
  291. end
  292. # module_function偲偟偰岞奐
  293. module_function :u2s
  294. end


  295. #======================================================================

  296. # ■ Game_System
  297. #---------------------------------------------------------------------

  298. #  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
  299. # $game_system 。
  300. #======================================================================

  301. class Game_System
  302. #---------------------------------------------------------------------

  303. # ● 定义实例变量
  304. #---------------------------------------------------------------------

  305. attr_accessor :mtv_begin_time
  306. attr_accessor :mtv_now
  307. attr_accessor :mtv_length
  308. #---------------------------------------------------------------------


  309. # ● 初始化对像
  310. #---------------------------------------------------------------------


  311. alias mtv_gamesystem_initialize initialize
  312. def initialize
  313.   mtv_gamesystem_initialize
  314.   @mtv_begin_time = $sys_timer.now()
  315.   @mtv_now = false
  316.   @mtv_length = 0
  317. end
  318. end  

  319. #======================================================================

  320. # ■ Scene_Map
  321. #---------------------------------------------------------------------

  322. #  处理地图画面的类。
  323. #======================================================================

  324. class Scene_Map
  325. #---------------------------------------------------------------------


  326. # ● 刷新画面
  327. #---------------------------------------------------------------------


  328. alias mtv_scenemap_update update
  329. def update
  330.   MTV.new_text
  331.   @mtv_window.refresh
  332.   mtv_scenemap_update
  333. end
  334. #---------------------------------------------------------------------

  335. # ● 主处理
  336. #---------------------------------------------------------------------

  337. alias mtv_scenemap_main main
  338. def main
  339.   @mtv_window = Window_MTV.new
  340.   mtv_scenemap_main
  341.   @mtv_window.dispose
  342. end
  343. #---------------------------------------------------------------------

  344. # ● 调用战斗 (调整自动切换BGM)
  345. #---------------------------------------------------------------------

  346. def call_battle
  347.   # 清除战斗调用标志
  348.   $game_temp.battle_calling = false
  349.   # 清除菜单调用标志
  350.   $game_temp.menu_calling = false
  351.   $game_temp.menu_beep = false
  352.   # 生成遇敌计数
  353.   $game_player.make_encounter_count
  354.   # 记忆地图 BGM 、停止 BGM
  355.   $game_temp.map_bgm = $game_system.playing_bgm
  356.   unless MTV.mtv?      
  357.     $game_system.bgm_play($game_system.battle_bgm)
  358.     # 演奏战斗开始 SE
  359.     $game_system.se_play($data_system.battle_start_se)
  360.   end
  361.   # 矫正主角姿势
  362.   $game_player.straighten
  363.   # 切换到战斗画面
  364.   $scene = Scene_Battle.new
  365. end
  366. end

  367. #======================================================================

  368. # ■ Scene_Battle
  369. #---------------------------------------------------------------------

  370. #  处理战斗的类。
  371. #======================================================================

  372. class Scene_Battle
  373. #---------------------------------------------------------------------

  374. # ● 刷新画面
  375. #---------------------------------------------------------------------


  376. alias mtv_scenebattle_update update
  377. def update
  378.   @mtv_window.refresh
  379.   mtv_scenebattle_update
  380. end
  381. #---------------------------------------------------------------------

  382. # ● 主处理
  383. #---------------------------------------------------------------------

  384. alias mtv_scenebattle_main main
  385. def main
  386.   @mtv_window = Window_MTV.new
  387.   mtv_scenebattle_main
  388.   @mtv_window.dispose
  389. end
  390. end

  391. #======================================================================

  392. # ■ Window_MTV
  393. #---------------------------------------------------------------------

  394. #  显示MTV字幕的窗口。
  395. #======================================================================


  396. class Window_MTV < Window_Base
  397. #---------------------------------------------------------------------
  398. # ● 初始化窗口
  399. #---------------------------------------------------------------------

  400. def initialize
  401.   super(0, 330, 544, 64)
  402.   self.contents = Bitmap.new(width - 32, height - 32)
  403.   $lrc_text = ""
  404.   self.z = 9999
  405.   #===========================
  406.   # 时间有限
  407.   @temp_text = ""
  408.   $game_temp.old_text = ""
  409.   # 面粉无敌
  410.   #===========================
  411.   refresh

  412. end
  413. #--------------------------------------------------------------------------
  414. # ● 刷新
  415. #--------------------------------------------------------------------------
  416. def refresh(text = "")
  417.   #=================================================
  418.   # 时间有限
  419.   if $game_temp.in_battle
  420.     self.opacity = 120
  421.   else
  422.     self.opacity = 255
  423.   end
  424.   if $game_system.mtv_now == false or $lrc_text == ""
  425.     self.contents.clear
  426.     else
  427.   if $game_temp.refresh_times != 1
  428.     if $game_temp.old_text != @temp_text
  429.       self.contents.clear
  430.       self.contents.font.color = Color.new(0,0,0,255)
  431.       self.contents.draw_text(0, 0, 512, 32, $lrc_text, 1)   
  432.       self.contents.font.color = Color.new(255,255,255,255)
  433.       self.contents.draw_text(1, 1, 512, 32, $lrc_text, 1)
  434.       @temp_text = $lrc_text
  435.     end
  436.   else
  437.     self.contents.clear
  438.      self.contents.font.color = Color.new(0,0,0,255)
  439.       self.contents.draw_text(0, 0, 512, 32, $lrc_text, 1)   
  440.       self.contents.font.color = Color.new(255,255,255,255)
  441.       self.contents.draw_text(1, 1, 512, 32, $lrc_text, 1)
  442.       @temp_text = $lrc_text
  443.     end
  444.   end
  445.   # 面粉无敌
  446.   #==================================================
  447. end

  448. end
复制代码
纵然千里外,我等雁归来。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

喵,小柯的宠物

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-12-15
帖子
2310
发表于 2008-1-21 18:19:56 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

昨日的黄昏

梦石
0
星屑
106
在线时间
936 小时
注册时间
2006-11-5
帖子
4128

第2届短篇游戏比赛季军第3届短篇游戏大赛小游戏及其他组季军

 楼主| 发表于 2008-1-22 11:49:32 | 显示全部楼层
测试可用~辛苦美兽大人了~23VIP请笑纳{/hx}
[url=http://weibo.com/2238291690?s=6uyXnP]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-17 06:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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