mcgluszak

kubaxd7

Nov 5th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.65 KB | None | 0 0
  1. #==============================================================================
  2. # ** Window_Czas
  3. #==============================================================================
  4. class Window_Czas < Window_Base
  5.   #--------------------------------------------------------------------------
  6.   # * Object Initialization
  7.   #--------------------------------------------------------------------------
  8.   def initialize
  9.     super(0, 0, 64, 64)
  10.     self.contents = Bitmap.new(width - 32, height - 32)
  11.     refresh
  12.     @czas = 0
  13.     @czas_old = 0
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # * Refresh
  17.   #--------------------------------------------------------------------------
  18.   def refresh
  19.     if @czas != @czas_old #żeby nie odświeżało niepotrzebnie, tak samo możesz
  20.                           # zrobić z punktami jak je dodasz
  21.       self.contents.clear
  22.       self.contents.font.color = normal_color
  23.       self.contents.draw_text(-5, 0, 32, 32, @czas.to_s, 2)
  24.       self.contents.font.color = system_color
  25.     end
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # * Update_czas
  29.   #--------------------------------------------------------------------------
  30.   def update_czas(czas)
  31.     @czas_old = @czas
  32.     @czas = czas
  33.     update #musi być zrobione na odwrót, ale efekt jest ten sam
  34.   end
  35.  
  36.   #--------------------------------------------------------------------------
  37.   # * Frame Update
  38.   #--------------------------------------------------------------------------
  39.   def update
  40.     super
  41.     refresh
  42.   end
  43. end
  44.  
  45. #==============================================================================
  46. # ** Window_Punkty
  47. #==============================================================================
  48. class Window_Punkty < Window_Base
  49.   #--------------------------------------------------------------------------
  50.   # * Object Initialization
  51.   #--------------------------------------------------------------------------
  52.   def initialize
  53.     super(0, 0, 128, 64)
  54.     self.contents = Bitmap.new(width - 32, height - 32)
  55.     refresh
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # * Refresh
  59.   #--------------------------------------------------------------------------
  60.   def refresh
  61.     self.contents.clear
  62.     self.contents.font.color = normal_color
  63.     self.contents.font.color = system_color
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # * Frame Update
  67.   #--------------------------------------------------------------------------
  68.   def update
  69.     super
  70.     refresh
  71.   end
  72. end
  73.  
  74. #==============================================================================
  75. # ** Scene_Zamki
  76. #==============================================================================
  77.  
  78. class Scene_Zamki
  79.  
  80.   #--------------------------------------------------------------------------
  81.   # * Main Processing
  82.   #--------------------------------------------------------------------------
  83.   def main
  84.     @czas_window = Window_Czas.new
  85.     @czas_window.back_opacity = 120
  86.     @czas_window.y = 416
  87.    
  88.     @pkt_window = Window_Punkty.new
  89.     @pkt_window.back_opacity = 120
  90.     @pkt_window.x = 64
  91.     @pkt_window.y = 416
  92.    
  93.     @odliczanie = false
  94.     @czas = 0
  95.    
  96.     @spriteset = Spriteset_Map.new #spriteset tworzy się w scenie, nie w każdym
  97.                                    # oknie oddzielnie
  98.     Graphics.transition
  99.     loop do
  100.       Graphics.update
  101.       Input.update
  102.       update
  103.       if $scene != self
  104.         break
  105.       end
  106.     end
  107.     Graphics.freeze
  108.     @czas_window.dispose
  109.     @pkt_window.dispose
  110.     @spriteset.dispose #nie usuwałem spritesetu, to był powód kraszów
  111.   end
  112.  
  113.   #--------------------------------------------------------------------------
  114.   # * Frame Update
  115.   #--------------------------------------------------------------------------
  116.   def update
  117.     if @odliczanie
  118.       czas = @czas / Graphics.frame_rate #obliczania wykonuj tutaj i przekazuj
  119.                                          # wynik do okna. nie ma sensu robić
  120.                                          # tysiąca zmiennych globalnych
  121.       @czas += 1
  122.     end
  123.     @czas_window.update_czas(czas)
  124.     @pkt_window.update
  125.    
  126.     if Input.trigger?(Input::B)
  127.       $scene = Scene_Map.new
  128.     end
  129.    
  130.     if Input.trigger?(Input::C)
  131.       odliczanie
  132.     end
  133.   end
  134.  
  135.  
  136.   #--------------------------------------------------------------------------
  137.   # * Odliczanie
  138.   #--------------------------------------------------------------------------
  139.   def odliczanie
  140.     @odliczanie = !@odliczanie
  141.   end
  142. end
Advertisement
Add Comment
Please, Sign In to add comment