Advertisement
marlosgama

Untitled

Mar 16th, 2020
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.51 KB | None | 0 0
  1. #==============================================================================
  2. # ** Sprite
  3. #------------------------------------------------------------------------------
  4. #  Esta é a superclasse de alguns objetos gráficos.
  5. #------------------------------------------------------------------------------
  6. #  Autor: Valentine
  7. #==============================================================================
  8.  
  9. class Bitmap
  10.  
  11.   alias vxaos_draw_text draw_text
  12.  
  13.   # Corrige a compressão de texto do RGD
  14.   def draw_text(*args)
  15.     if args[5] && args[5] == 1
  16.       args[2] += 20
  17.       args[0] -= 9
  18.     end
  19.     vxaos_draw_text(*args)
  20.   end
  21.  
  22. end
  23.  
  24. #==============================================================================
  25. # ** Sprite2
  26. #==============================================================================
  27. class Sprite2 < Sprite
  28.  
  29.   attr_writer   :dragable
  30.  
  31.   def initialize(viewport = nil)
  32.     super(viewport)
  33.     @dragable = false
  34.     @dif_x = nil
  35.     @dif_y = nil
  36.   end
  37.  
  38.   def in_area?(x = 0, y = 0, w = self.bitmap.width, h = self.bitmap.height)
  39.     Mouse.x >= self.x + x && Mouse.x <= self.x + x + w && Mouse.y >= self.y + y && Mouse.y <= self.y + y + h
  40.   end
  41.  
  42.   def text_color(n)
  43.     windowskin = Cache.system('Window')
  44.     windowskin.get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
  45.   end
  46.  
  47.   def normal_color
  48.     text_color(0)
  49.   end
  50.  
  51.   def system_color
  52.     text_color(16)
  53.   end
  54.  
  55.   def crisis_color
  56.     text_color(17)
  57.   end
  58.  
  59.   def text_width(str)
  60.     b = Bitmap.new(1, 1)
  61.     wth = b.text_size(str).width
  62.     b.dispose
  63.     wth
  64.   end
  65.  
  66.   def convert_gold(value)
  67.     value.to_s.reverse.scan(/...|..|./).join('.').reverse
  68.   end
  69.  
  70.   def update
  71.     super
  72.     update_dragging
  73.     $dragging_window = Mouse.press?(:L) ? in_area? && !$dragging_window ? self : $dragging_window : nil
  74.   end
  75.  
  76.   def update_dragging
  77.     return unless @dragable
  78.     return if $cursor.object
  79.     if $dragging_window == self
  80.       self.x = Mouse.x - @dif_x
  81.       self.y = Mouse.y - @dif_y
  82.     else
  83.       @dif_x = Mouse.x - self.x
  84.       @dif_y = Mouse.y - self.y
  85.     end
  86.   end
  87.  
  88. end
  89.  
  90. #==============================================================================
  91. # ** Color
  92. #==============================================================================
  93. class Color
  94.  
  95.   White = self.new(255, 255, 255)
  96.   Black = self.new(0, 0, 0)
  97.   Red = self.new(255, 120, 76)
  98.   Green = self.new(0, 224, 96)
  99.   Yellow = self.new(255, 255, 0)
  100.   Blue = self.new(0, 162, 232)
  101.  
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement