Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

i need help with sideview battle system

i use RPGMXP
every time i insert sideview battla script like this,
class Bitmap
if not method_defined?('original_draw_text')
alias original_draw_text draw_text
def draw_text(*arg)

   original_color = self.font.color.dup
   self.font.color = Color.new(0, 0, 0, 128)

   if arg[0].is_a?(Rect)
     arg[0].x += 2
     arg[0].y += 2
     self.original_draw_text(*arg)
     arg[0].x -= 2
     arg[0].y -= 2
   else
     arg[0] += 2
     arg[1] += 2
     self.original_draw_text(*arg)
     arg[0] -= 2
     arg[1] -= 2
   end

   self.font.color = original_color
   self.original_draw_text(*arg)

end
end
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
   for i in x...x + width
     red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
     green = color1.green +
             (color2.green - color1.green) * (i - x) / (width - 1)
     blue  = color1.blue +
             (color2.blue - color1.blue) * (i - x) / (width - 1)
     alpha = color1.alpha +
             (color2.alpha - color1.alpha) * (i - x) / (width - 1)
     color = Color.new(red, green, blue, alpha)
     fill_rect(i, y, 1, height, color)
   end
elsif align == 1
   for i in y...y + height
     red   = color1.red +
             (color2.red - color1.red) * (i - y) / (height - 1)
     green = color1.green +
             (color2.green - color1.green) * (i - y) / (height - 1)
     blue  = color1.blue +
             (color2.blue - color1.blue) * (i - y) / (height - 1)
     alpha = color1.alpha +
             (color2.alpha - color1.alpha) * (i - y) / (height - 1)
     color = Color.new(red, green, blue, alpha)
     fill_rect(x, i, width, 1, color)
   end
elsif align == 2
   for i in x...x + width
     for j in y...y + height
       red   = color1.red + (color2.red - color1.red) *
               ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       green = color1.green + (color2.green - color1.green) *
               ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       blue  = color1.blue + (color2.blue - color1.blue) *
               ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       alpha = color1.alpha + (color2.alpha - color1.alpha) *
               ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       color = Color.new(red, green, blue, alpha)
       set_pixel(i, j, color)
     end
   end
elsif align == 3
   for i in x...x + width
     for j in y...y + height
       red   = color1.red + (color2.red - color1.red) *
             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       green = color1.green + (color2.green - color1.green) *
             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       blue  = color1.blue + (color2.blue - color1.blue) *
             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       alpha = color1.alpha + (color2.alpha - color1.alpha) *
             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       color = Color.new(red, green, blue, alpha)
       set_pixel(i, j, color)
     end
   end
end
end
end

module RPG
class Sprite < ::Sprite
def damage(value, critical)
   dispose_damage
   if value.is_a?(Numeric)
     damage_string = value.abs.to_s
   else
     damage_string = value.to_s
   end
   bitmap = Bitmap.new(160, 48)
   bitmap.font.name = "Arial Black"
   bitmap.font.size = 32
   bitmap.font.color.set(0, 0, 0)
   bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
   bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
   bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
   bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
   if value.is_a?(Numeric) and value < 0
     bitmap.font.color.set(176, 255, 144)
   else
     bitmap.font.color.set(255, 255, 255)
   end
   bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
   if critical
     bitmap.font.size = 20
     bitmap.font.color.set(0, 0, 0)
     bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
     bitmap.font.color.set(255, 255, 255)
     bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
   end
   @_damage_sprite = ::Sprite.new
   @_damage_sprite.bitmap = bitmap
   @_damage_sprite.ox = 80 + self.viewport.ox
   @_damage_sprite.oy = 20 + self.viewport.oy
   @_damage_sprite.x = self.x + self.viewport.rect.x
   @_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y
   @_damage_sprite.z = 3000
   @_damage_duration%

i always get error line **** syntax error or something like that
and this error occurred in every battle script
help would be appreciated.....thx
 

khmp

Sponsor

To get help with this you are going to need to be a little more specific in your explanation. Although if that's the whole script the problem is that it's incomplete. Or you forgot to paste the whole script. ;) Also please place code in code tags [ code ]/[/ code ].
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top