zegar, np. w jakimś przedmiocie, otwierasz menu przedmioty i np. zegarek, i że tam możesz ustawić godz min i potem sprawdzać która godzina, tak jak zegarek w rzeczywistości
[ Dodano: Sob 20 Mar, 2010 10:25 ]
please bardzo potrzebuje
Pomogła: 232 razy Dołączyła: 18 Wrz 2007 Posty: 2424
Wysłany: Sob 20 Mar, 2010 19:26
Nie mam zdarzeniówki, ale zrobiłam skrypt. Tylko dobrze przetestuj:
Spoiler:
Kod:
#==============================================================================
# Zegar
# by Ayene [yurika@o2.pl]
# www.ultimateam.pl
#------------------------------------------------------------------------------
# Skrypt dodaje okienko z zegarkiem. Jest w fazie testów.
# Wszelkie pytania proszę kierować na forum.
#==============================================================================
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window.index
when 0
return_scene
when 1
@command_window.active = false
@window_set_time.active = true
@window_set_time.visible = true
@help_window.set_text("Ustaw godzinę...")
when 2
@command_window.active = false
@command_window_time_format.active = true
@command_window_time_format.visible = true
@help_window.set_text("Wybierz format godziny...")
end
end
end
def update_command_window_time_format
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@command_window_time_format.active = false
@command_window_time_format.visible = false
@help_window.set_text("Zegar gry")
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window_time_format.index
when 0
$game_variables[Ayene::ZMIENNA_FORMATU] = 0
when 1
$game_variables[Ayene::ZMIENNA_FORMATU] = 1
end
@time_window.refresh
@command_window.active = true
@command_window_time_format.active = false
@command_window_time_format.visible = false
end
end
def update_window_set_time
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@window_set_time.active = false
@window_set_time.visible = false
@help_window.set_text("Zegar gry")
elsif Input.trigger?(Input::C)
Sound.play_decision
$game_variables[Ayene::ZMIENNA_CZASU] = @window_set_time.number
Graphics.frame_count = 0
@command_window.active = true
@window_set_time.active = false
@window_set_time.visible = false
end
end
end
def digits_max=(digits_max)
@digits_max = digits_max
refresh
end
def cursor_right(wrap)
if @index < @digits_max - 1 or wrap
@index = (@index + 1) % (@digits_max / 2)
end
end
def cursor_left(wrap)
if @index > 0 or wrap
@index = (@index + @digits_max - 1) % (@digits_max / 2)
end
end
def update
super
if self.active
if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
Sound.play_cursor
place = 10 ** (@digits_max - 2 - @index * 2)
n = @number / place % 100
@number -= n * place
case @index
when 0
n = (n + 1) % 24 if Input.repeat?(Input::UP)
n = (n + 23) % 24 if Input.repeat?(Input::DOWN)
when 1,2
n = (n + 1) % 60 if Input.repeat?(Input::UP)
n = (n + 59) % 60 if Input.repeat?(Input::DOWN)
end
@number += n * place
refresh
end
last_index = @index
if Input.repeat?(Input::RIGHT)
cursor_right(Input.trigger?(Input::RIGHT))
end
if Input.repeat?(Input::LEFT)
cursor_left(Input.trigger?(Input::LEFT))
end
if @index != last_index
Sound.play_cursor
end
update_cursor
end
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
s = sprintf("%0*d", @digits_max, @number)
for i in 0...@digits_max
self.contents.draw_text(14 + i * 16, 32, 16, WLH, s[i,1], 1)
end
self.contents.font.color = system_color
self.contents.draw_text(14, 0, self.width - 40, WLH, "HH:MM:SS", 0)
end
def update_cursor
self.cursor_rect.set(14 + @index * 32, 32, 32, WLH)
end
end
class Window_Time < Window_Base
def initialize
super(0, 0, 354, 360)
@animation = 0
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
font_size = self.contents.font.size
self.contents.draw_text(4, 0, 120, 32, "Zegar", 1)
clock = $game_variables[Ayene::ZMIENNA_CZASU]
h = clock / 100 / 100
m = clock / 100 % 100
s = clock % 100
clock2 = s + m * 60 + h * 3600
@total_sec = clock2 + (Graphics.frame_count / Graphics.frame_rate)
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
if hour >= 24
hour = hour - 24
end
if hour == 24 and min = 0 and sec = 0
Graphics.frame_count = 0
@total_sec = 0
$game_variables[Ayene::ZMIENNA_CZASU] = 0
hour = 0
end
case $game_variables[Ayene::ZMIENNA_FORMATU]
when 0
text = sprintf("%02d:%02d:%02d", hour, min, sec)
when 1
if hour > 12
text = sprintf("%02d:%02d PM", hour - 12, min)
else
text = sprintf("%02d:%02d AM", hour, min)
end
end
self.contents.font.color = normal_color
self.contents.font.size = 32
self.contents.draw_text(0, 32, 300, 32, text, 1)
self.contents.font.size = font_size
end
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window.index
when 0
return_scene
when 1
@command_window.active = false
@window_set_time.active = true
@window_set_time.visible = true
@help_window.set_text("Ustaw godzinę...")
when 2
@command_window.active = false
@command_window_time_format.active = true
@command_window_time_format.visible = true
@help_window.set_text("Wybierz format godziny...")
end
end
end
def update_command_window_time_format
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@command_window_time_format.active = false
@command_window_time_format.visible = false
@help_window.set_text("Zegar gry")
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window_time_format.index
when 0
$game_variables[Ayene::ZMIENNA_FORMATU] = 0
when 1
$game_variables[Ayene::ZMIENNA_FORMATU] = 1
end
@time_window.refresh
@command_window.active = true
@command_window_time_format.active = false
@command_window_time_format.visible = false
@help_window.set_text("Zegar gry")
end
end
def update_kropki
if @animation > 50
@animation = 0
end
if (@kropki.opacity > 250 and @animation > 50)
@kropki.opacity = 0
end
if (@kropki.opacity < 5 and @animation > 50)
@kropki.opacity = 250
end
end
end
def digits_max=(digits_max)
@digits_max = digits_max
refresh
end
def cursor_right(wrap)
if @index < @digits_max - 1 or wrap
@index = (@index + 1) % (@digits_max / 2)
end
end
def cursor_left(wrap)
if @index > 0 or wrap
@index = (@index + @digits_max - 1) % (@digits_max / 2)
end
end
def update
super
if self.active
if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
Sound.play_cursor
place = 10 ** (@digits_max - 2 - @index * 2)
n = @number / place % 100
@number -= n * place
case @index
when 0
n = (n + 1) % 24 if Input.repeat?(Input::UP)
n = (n + 23) % 24 if Input.repeat?(Input::DOWN)
when 1,2
n = (n + 1) % 60 if Input.repeat?(Input::UP)
n = (n + 59) % 60 if Input.repeat?(Input::DOWN)
end
@number += n * place
refresh
end
last_index = @index
if Input.repeat?(Input::RIGHT)
cursor_right(Input.trigger?(Input::RIGHT))
end
if Input.repeat?(Input::LEFT)
cursor_left(Input.trigger?(Input::LEFT))
end
if @index != last_index
Sound.play_cursor
end
update_cursor
end
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
s = sprintf("%0*d", @digits_max, @number)
for i in 0...@digits_max
self.contents.draw_text(14 + i * 16, 32, 16, WLH, s[i,1], 1)
end
self.contents.font.color = system_color
self.contents.draw_text(14, 0, self.width - 40, WLH, "HH:MM:SS", 0)
end
def update_cursor
self.cursor_rect.set(14 + @index * 32, 32, 32, WLH)
end
end
class Window_Time < Window_Base
def initialize
super(0, 0, 160, 60)
self.opacity = 0
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
font_size = self.contents.font.size
font_name = self.contents.font.name
clock = $game_variables[Ayene::ZMIENNA_CZASU]
h = clock / 100 / 100
m = clock / 100 % 100
s = clock % 100
clock2 = s + m * 60 + h * 3600
@total_sec = clock2 + (Graphics.frame_count / Graphics.frame_rate)
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
if hour >= 24
hour = hour - 24
end
if hour == 24 and min = 0 and sec = 0
Graphics.frame_count = 0
@total_sec = 0
$game_variables[Ayene::ZMIENNA_CZASU] = 0
hour = 0
end
case $game_variables[Ayene::ZMIENNA_FORMATU]
when 0
text1 = sprintf("%02d", hour)
text2 = sprintf("%02d", min)
text3 = sprintf("%02d", sec)
when 1
if hour > 12
text1 = sprintf("%02d", hour - 12)
text2 = sprintf("%02d", min)
text3 = "PM"
else
text1 = sprintf("%02d", hour)
text2 = sprintf("%02d", min)
text3 = "AM"
end
end
self.contents.font.color = normal_color
self.contents.font.size = 32
self.contents.font.name = Ayene::CZCIONKA
self.contents.draw_text(2, 0, 100, 32, ":", 1) if sec % 2 == 0
self.contents.draw_text(-55, 0, 100, 32, text1, 2)
self.contents.draw_text(55, 0, 100, 32, text2, 0)
self.contents.font.size = 24
self.contents.draw_text(95, 0, 100, 34, text3, 0)
self.contents.font.size = font_size
self.contents.font.name = font_name
end
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
class Window_Time_Status < Window_Base
def initialize(x, y)
super(x, y, 354, 360)
self.z = 1
bitmap = Cache::picture(Ayene::LOGO)
cw = bitmap.width + 32
self.contents.blt(self.width - cw, 220, bitmap, Rect.new(0, 0, 200, 200))
end
end
W folderze Graphics/Pictures należy umieścić dwa obrazki (oczywiście można zrobić swoje, gdyż domyślne są tylko w celu demonstracji):
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum