Code:
#=======================================#
# class Game_Title #
# Written by Deke
# Rewiten by Near Fantastica
#=======================================#
class Game_Time
attr_accessor :minute_length
def initialize
@minute_length= 0.1#0.325 #length of game minute in real seconds
@hour_length= 60.0 #minute in an hour
@day_length= 24.0 #hours in a day
@month_length=30.0 #days in a month
@year_length=12.0 #months in a year
@minutes=0 #starting minute count
start_minute=0
add_minutes(start_minute)
start_hour=23 #starting hour count
add_hours(start_hour)
start_day=20 #starting day count
add_days(start_day)
start_month=6 #starting month count
add_months(start_month-1)
start_year= 2000 #starting year count
add_years(start_year)
end
def add_minutes(minutes)
@minutes +=minutes
end
def add_hours(hours)
@minutes +=hours*@hour_length
end
def add_days(days)
@minutes += days*@hour_length*@day_length
end
def add_months(months)
@minutes +=months * @hour_length*@day_length*@month_length
end
def add_years(years)
@minutes += years * @hour_length*@day_length*@month_length * @year_length
end
def get_year
minutes=get_total_minutes
year=minutes / @hour_length / @day_length / @month_length / @year_length
return year
end
def get_month
minutes=get_total_minutes
month=minutes / @hour_length / @day_length / @month_length % @year_length + 1
return month
end
def get_day
minutes=get_total_minutes
day=minutes / @hour_length / @day_length % @month_length
return day
end
def get_hour
minutes=get_total_minutes
hour=minutes / @hour_length % @day_length
return hour
end
def get_total_minutes
total_sec=Graphics.frame_count / Graphics.frame_rate
minute=(total_sec/@minute_length+@minutes)
return minute
end
def get_minute
minutes=get_total_minutes % @hour_length
return minutes
end
def get_tone
period_length=Math::PI*(get_hour / @day_length)
red_shift= -100+ 115*Math.sin(period_length)
green_shift= -140+ 155*Math.sin(period_length)
blue_shift= -150+ 165*Math.sin(period_length)
return Tone.new(red_shift, green_shift, blue_shift, 0)
end
end # of class Game_Time
#=======================================#
# â– class Window_Time
# written by Deke
#=======================================#
class Window_PlayTime < Window_Base
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface # "Time" window font
self.contents.font.size = $fontsize
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@total_sec = Graphics.frame_count / Graphics.frame_rate
@minute=$game_time.get_minute.floor
hour = $game_time.get_hour
pm_flag= hour >=12 ? true : false
hour= hour >= 12 ? hour-12 : hour
day=$game_time.get_day
month=$game_time.get_month
year=$game_time.get_year
if hour.floor==0
text=sprintf("%02d:%02d",12,@minute)
else
text=sprintf("%02d:%02d",hour,@minute)
end
if pm_flag
text += " PM"
else
text += " AM"
end
self.contents.font.color = normal_color
self.contents.draw_text(0, 32, 120, 32, text)
text = sprintf("%02d-%02d-%02d", month, day, year)
self.contents.font.color=system_color
self.contents.draw_text(4,0,120,32,'Time')
end
#--------------------------------------------------------------------------
def update
if $game_time.get_minute.floor != @minute
refresh
end
end
end # of class
#=======================================
class Game_Temp
#--------------------------------------------------------------------------
# â—