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

Project1

 找回密码
 注册会员
搜索
查看: 3284|回复: 5
打印 上一主题 下一主题

[原创发布] [RMXP]时间流逝窗口

[复制链接]

Lv1.梦旅人

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
跳转到指定楼层
1
发表于 2013-9-19 16:44:05 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 876加几 于 2013-9-20 10:07 编辑

呼,终于写好了,目前只支持儒略历。
原创脚本:
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 == 23 and @minute_index == 59
  91.         case @cycle_index
  92.         when 1
  93.           @cycle_index = 2
  94.         when 2
  95.           @cycle_index = 3
  96.         when 3
  97.           @cycle_index = 4
  98.         when 4
  99.           @cycle_index = 5
  100.         when 5
  101.           @cycle_index = 6
  102.         when 6
  103.           @cycle_index = 7
  104.         when 7
  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.       when 1 #大月
  115.         @day_index = @total_second / 60 / 60 / 24 % 30 + 1
  116.         @month_index = @total_second / 60 / 60 / 24 / 30 % 11 + 1
  117.       when 2 #小月
  118.         @day_index = @total_second / 60 / 60 / 24 % 29
  119.         @month_index = @total_second / 60 / 60 / 24 / 29 % 11 + 1
  120.       when 3 #特殊月
  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.       when 2
  137.         @season_index = 1
  138.       when 5
  139.         @season_index = 2
  140.       when 8
  141.         @season_index = 3
  142.       when 11
  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.     when 1 #星期一
  180.       self.contents.draw_text(296, 0, 72, 32, "星期一")
  181.     when 2 #星期二
  182.       self.contents.draw_text(296, 0, 72, 32, "星期二")
  183.     when 3
  184.       self.contents.draw_text(296, 0, 72, 32, "星期三")
  185.     when 4
  186.       self.contents.draw_text(296, 0, 72, 32, "星期四")
  187.     when 5
  188.       self.contents.draw_text(296, 0, 72, 32, "星期五")
  189.     when 6
  190.       self.contents.draw_text(296, 0, 72, 32, "星期六")
  191.     when 7
  192.       self.contents.draw_text(296, 0, 72, 32, "星期日")
  193.     end
  194.     case @season_index
  195.     when 1 # 春季
  196.       self.contents.draw_text(512, 0, 32, 32, "春")
  197.     when 2 # 夏季
  198.       self.contents.draw_text(512, 0, 32, 32, "夏")
  199.     when 3 # 秋季
  200.       self.contents.draw_text(512, 0, 32, 32, "秋")
  201.     when 4 # 冬季
  202.       self.contents.draw_text(512, 0, 32, 32, "冬")
  203.     end
  204.     #色相修改
  205.     case @season_index
  206.     when 1
  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.     when 2
  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.     when 3
  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.     when 4
  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
因为天气变化放进去过于唐突,所以我不写天气变化。
范例:
Project19.rar (193.65 KB, 下载次数: 82)
发现一转换场景,很多数据变成nil,所以我就占用一些Switches和Variables。
裁图:




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

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

发现有个bug,先修改了。

点评

@chd114 将所有的*50缩小就解决了。  发表于 2013-9-19 19:36
换算不科学···1分钟=1天的话时间跨度太大了···  发表于 2013-9-19 19:27
呃,发糖贴好冷清呀!

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

2
发表于 2013-9-19 16:50:25 | 只看该作者
等于现实时间的系统吗?

点评

现实1分钟,游戏一天。  发表于 2013-9-19 19:14
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
32036
在线时间
5081 小时
注册时间
2012-11-19
帖子
4877

开拓者

3
发表于 2013-9-19 21:44:04 | 只看该作者
脚本看得人眼花缭乱,需要改进一下,比如:
  1. case @cycle_index
  2. when 1 #星期一
  3.   text = "一"
  4. when 2 #星期二
  5.   text = "二"
  6. when 3
  7.   text = "三"
  8. when 4
  9.   text = "四"
  10. when 5
  11.   text = "五"
  12. when 6
  13.   text = "六"
  14. when 7
  15.   text = "日"
  16. end
  17. text = "星期" + text
  18. self.contents.draw_text(296, 0, 72, 32, text)
复制代码

点评

呵呵~,我只能说:就当我什么都没说。  发表于 2013-9-19 22:05
用你这个方法换场景就会出现脚本错误,我测试了的,先写的就是那种方法,结果出错了  发表于 2013-9-19 22:02
xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
4
发表于 2013-9-20 00:55:39 | 只看该作者
加上天气一点也不唐突,效果反而会好(个人看法),去看看我的?

点评

加上天气很快随着窗口的refresh就唐突了。  发表于 2013-9-20 09:57
回复 支持 反对

使用道具 举报

Lv3.寻梦者

孤独守望

梦石
0
星屑
3121
在线时间
1534 小时
注册时间
2006-10-16
帖子
4321

开拓者贵宾

5
发表于 2013-9-20 03:20:19 手机端发表。 | 只看该作者
悄悄告诉你哦,有个类叫做Time
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3841
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
6
发表于 2013-9-20 05:25:11 | 只看该作者
LS说得对,RMXP的Ruby有一个Time的类,所以这个麻烦了一些…
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-10 10:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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