搜索附件  
同能RPG制作大师 附件中心 同能RM技术讨论区 RPG Maker XP 讨论区 [RMXP]时间流逝窗口: d2.jpg

[RMXP]时间流逝窗口: d2.jpg

 

[RMXP]时间流逝窗口:
呼,终于写好了,目前只支持儒略历。
原创脚本:
RUBY 代码
  1. #-------------------------------------------------------------------------------
  2. # 时间流逝 by 876加几
  3. #-------------------------------------------------------------------------------
  4. class Window_Time < Window_Base
  5.   #--------------------------------------------------------------------------
  6.   # ● 初始化窗口
  7.   #--------------------------------------------------------------------------
  8.   def initialize
  9.     super(0, 0, 640, 64)
  10.     self.contents = Bitmap.new(width - 32, height - 32)
  11.     if$game_switches[3] != true
  12.       @year_index = -1#这个可以随便改,但要符合实际(还要在下面计算出来)
  13.       @month_index = 1
  14.       @day_index = 1
  15.       @hour_index = 9
  16.       @minute_index = 0
  17.       @second_index = 0
  18.       @cycle_index = 1   #后面三个不用计算,并且要符合实际
  19.       @season_index = 4
  20.       @leap = false
  21.       $game_switches[3] = true
  22.     end
  23.     refresh
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 刷新
  27.   #--------------------------------------------------------------------------
  28.   def refresh
  29.     self.contents.clear
  30.     #存储数据/读取数据
  31.     if@year_index != nil
  32.       $game_variables[1] = @year_index
  33.     else
  34.       @year_index = $game_variables[1]
  35.     end
  36.     if@month_index != nil
  37.       $game_variables[2] = @month_index
  38.     else
  39.       @month_index = $game_variables[2]
  40.     end
  41.     if@day_index != nil
  42.       $game_variables[3] = @day_index
  43.     else
  44.       @day_index = $game_variables[3]
  45.     end
  46.     if@cycle_index != nil
  47.       $game_variables[4] = @cycle_index
  48.     else
  49.       @cycle_index = $game_variables[4]
  50.     end
  51.     if@season_index != nil
  52.       $game_variables[5] = @season_index
  53.     else
  54.       @season_index = $game_variables[5]
  55.     end
  56.     if@leap != nil
  57.       $game_switches[1] = @leap
  58.     else
  59.       @leap = $game_switches[1]
  60.     end
  61.     #时间显示
  62.     time = sprintf("%02d:%02d:%02d", @hour_index, @minute_index, @second_index)
  63.       #判断这个月是什么月
  64.       if@month_index == 1
  65.         @judge_index = 1
  66.       elsif@month_index == 2
  67.         @judge_index = 3
  68.       elsif@month_index == 3
  69.         @judge_index = 1
  70.       elsif@month_index == 4
  71.         @judge_index = 2
  72.       elsif@month_index == 5
  73.         @judge_index = 1
  74.       elsif@month_index == 6
  75.         @judge_index = 2
  76.       elsif@month_index == 7
  77.         @judge_index = 1
  78.       elsif@month_index == 8
  79.         @judge_index = 1
  80.       elsif@month_index == 9
  81.         @judge_index = 2
  82.       elsif@month_index == 10
  83.         @judge_index = 1
  84.       elsif@month_index == 11
  85.         @judge_index = 2
  86.       elsif@month_index == 12
  87.         @judge_index = 1
  88.       end
  89.       #星期变更
  90.       if@hour_index == 23and@minute_index == 59
  91.         case@cycle_index
  92.         when1
  93.           @cycle_index = 2
  94.         when2
  95.           @cycle_index = 3
  96.         when3
  97.           @cycle_index = 4
  98.         when4
  99.           @cycle_index = 5
  100.         when5
  101.           @cycle_index = 6
  102.         when6
  103.           @cycle_index = 7
  104.         when7
  105.           @cycle_index = 1
  106.         end
  107.       end
  108.       #制造时间动力
  109.       @total_second = Graphics.frame_count * 50
  110.       @second_index = @total_second % 60
  111.       @minute_index = @total_second / 60 % 60
  112.       @hour_index = @total_second / 60 / 60 % 24
  113.       case@judge_index
  114.       when1#大月
  115.         @day_index = @total_second / 60 / 60 / 24 % 30 + 1
  116.         @month_index = @total_second / 60 / 60 / 24 / 30 % 11 + 1
  117.       when2#小月
  118.         @day_index = @total_second / 60 / 60 / 24 % 29
  119.         @month_index = @total_second / 60 / 60 / 24 / 29 % 11 + 1
  120.       when3#特殊月
  121.         if@leap == true
  122.           @day_index = @total_second / 60 / 60 / 24 % 28
  123.           @month_index = @total_second / 60 / 60 / 24 / 28 % 11 + 1
  124.         else
  125.           @day_index = @total_second / 60 / 60 / 24 % 27
  126.           @month_index = @total_second / 60 / 60 / 24 / 27 % 11 + 1
  127.         end
  128.       end
  129.       if@leap == true
  130.         @year_index = @total_second / 60 / 60 / 24 / 365 + 1
  131.       else
  132.         @year_index = @total_second / 60 / 60 / 24 / 364 + 1
  133.       end
  134.       #季度判断
  135.       case@month_index
  136.       when2
  137.         @season_index = 1
  138.       when5
  139.         @season_index = 2
  140.       when8
  141.         @season_index = 3
  142.       when11
  143.         @season_index = 4
  144.       end
  145.     self.contents.font.color = normal_color
  146.     self.contents.draw_text(360, 0, 120, 32, time, 2)
  147.     #判断是否为闰年
  148.     @leap_index = @year_index
  149.     @leap_index %= 4
  150.     if@leap_index == 0
  151.       @leap = true
  152.     else
  153.       @leap = false
  154.     end
  155.     #绘制
  156.     mx = self.contents.text_size(@month_index.to_s).width
  157.     dx = self.contents.text_size(@day_index.to_s).width
  158.     if@year_index < 0
  159.       @yearf_index = @year_index * (0 - 1)
  160.       yx = self.contents.text_size(@yearf_index.to_s).width
  161.       self.contents.draw_text(16, 0, 72, 32,"公元前")
  162.       self.contents.draw_text(82, 0, 72, 32, @yearf_index.to_s)
  163.       self.contents.draw_text(82+yx, 0, 32, 32, "年")
  164.       self.contents.draw_text(102+yx, 0, 20, 32, @month_index.to_s)
  165.       self.contents.draw_text(102+yx+mx, 0, 32, 32, "月")
  166.       self.contents.draw_text(122+yx+mx, 0, 20, 32, @day_index.to_s)
  167.       self.contents.draw_text(122+yx+mx+dx, 0, 32, 32, "日")
  168.     else
  169.       yx = self.contents.text_size(@year_index.to_s).width
  170.       self.contents.draw_text(16, 0, 72, 32,"公元")
  171.       self.contents.draw_text(60, 0, 72, 32, @year_index.to_s)
  172.       self.contents.draw_text(60+yx, 0, 32, 32, "年")
  173.       self.contents.draw_text(80+yx, 0, 20, 32, @month_index.to_s)
  174.       self.contents.draw_text(80+yx+mx, 0, 32, 32, "月")
  175.       self.contents.draw_text(100+yx+mx, 0, 20, 32, @day_index.to_s)
  176.       self.contents.draw_text(100+yx+mx+dx, 0, 32, 32, "日")
  177.     end
  178.     case@cycle_index
  179.     when1#星期一
  180.       self.contents.draw_text(296, 0, 72, 32, "星期一")
  181.     when2#星期二
  182.       self.contents.draw_text(296, 0, 72, 32, "星期二")
  183.     when3
  184.       self.contents.draw_text(296, 0, 72, 32, "星期三")
  185.     when4
  186.       self.contents.draw_text(296, 0, 72, 32, "星期四")
  187.     when5
  188.       self.contents.draw_text(296, 0, 72, 32, "星期五")
  189.     when6
  190.       self.contents.draw_text(296, 0, 72, 32, "星期六")
  191.     when7
  192.       self.contents.draw_text(296, 0, 72, 32, "星期日")
  193.     end
  194.     case@season_index
  195.     when1# 春季
  196.       self.contents.draw_text(512, 0, 32, 32, "春")
  197.     when2# 夏季
  198.       self.contents.draw_text(512, 0, 32, 32, "夏")
  199.     when3# 秋季
  200.       self.contents.draw_text(512, 0, 32, 32, "秋")
  201.     when4# 冬季
  202.       self.contents.draw_text(512, 0, 32, 32, "冬")
  203.     end
  204.     #色相修改
  205.     case@season_index
  206.     when1
  207.       if@hour_index == 7
  208.         $game_screen.start_tone_change(Tone.new(64,0,0,0),20)
  209.       elsif@hour_index == 8
  210.         $game_screen.start_tone_change(Tone.new(0,0,0,0),20)
  211.       elsif@hour_index == 19
  212.         $game_screen.start_tone_change(Tone.new(64,0,0,0),20)
  213.       elsif@hour_index == 20
  214.         $game_screen.start_tone_change(Tone.new(-64,-64,64,0),20)
  215.       elsif@hour_index == 0
  216.         $game_screen.start_tone_change(Tone.new(-128,-128,128,0),20)
  217.       end
  218.     when2
  219.       if@hour_index == 6
  220.         $game_screen.start_tone_change(Tone.new(64,0,0,0),20)
  221.       elsif@hour_index == 7
  222.         $game_screen.start_tone_change(Tone.new(0,0,0,0),20)
  223.       elsif@hour_index == 20
  224.         $game_screen.start_tone_change(Tone.new(64,0,0,0),20)
  225.       elsif@hour_index == 21
  226.         $game_screen.start_tone_change(Tone.new(-64,-64,64,0),20)
  227.       elsif@hour_index == 0
  228.         $game_screen.start_tone_change(Tone.new(-128,-128,128,0),20)
  229.       end
  230.     when3
  231.       if@hour_index == 7
  232.         $game_screen.start_tone_change(Tone.new(64,0,0,0),20)
  233.       elsif@hour_index == 8
  234.         $game_screen.start_tone_change(Tone.new(0,0,0,0),20)
  235.       elsif@hour_index == 19
  236.         $game_screen.start_tone_change(Tone.new(64,0,0,0),20)
  237.       elsif@hour_index == 20
  238.         $game_screen.start_tone_change(Tone.new(-64,-64,64,0),20)
  239.       elsif@hour_index == 0
  240.         $game_screen.start_tone_change(Tone.new(-128,-128,128,0),20)
  241.       end
  242.     when4
  243.       if@hour_index == 8
  244.         $game_screen.start_tone_change(Tone.new(64,0,0,0),20)
  245.       elsif@hour_index == 9
  246.         $game_screen.start_tone_change(Tone.new(0,0,0,0),20)
  247.       elsif@hour_index == 18
  248.         $game_screen.start_tone_change(Tone.new(64,0,0,0),20)
  249.       elsif@hour_index == 19
  250.         $game_screen.start_tone_change(Tone.new(-64,-64,64,0),20)
  251.       elsif@hour_index == 0
  252.         $game_screen.start_tone_change(Tone.new(-128,-128,128,0),20)
  253.       end
  254.     end
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # ● 刷新画面
  258.   #--------------------------------------------------------------------------
  259.   def update
  260.     super
  261.     if Graphics.frame_count * 50 != @total_second
  262.       refresh
  263.     end
  264.   end
  265. end
复制代码
因为天气变化放进去过于唐突,所以我不写天气变化。
范例:

发现一转换场景,很多数据变成nil,所以我就占用一些Switches和Variables。
裁图:




Q:leap那些分别是什么?
A:leap判断平闰年,season是季节判断,year、month、day、hour、minute和second各代表年、月、日、小时、分钟、秒。

有的组件千万不能改!!!
范例新添的脚本要用这个脚本全文替换!!!

发现有个bug,先修改了。
             本帖来自P1论坛作者876加几,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=332811  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
[RMXP]时间流逝窗口: d2.jpg

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

GMT+8, 2024-9-21 16:39 , Processed in 0.039673 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部