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.

Need help adding feature to text script.

Hey guys Dargor made me this awesome script a few days ago, and i was wondering if someone could help me update it as he's already helped me with so much and i don't want to bother him again. :) Basically what the script does it allows me to display text anywhere on the screen with a call script given (x coord, y coord,length,width,the text, clear_bitmap). Happy to say thx to Dargor it works beautifully and looks really colorful on the screen. The only issue i have is this. The only way of erasing text from the screen is by setting clear_bitmap= true, and that erases All the text from the screen. How would i modify this script so that if i want to change the text on the screen, i don't have to constantly redisplay everything as it can cause a tremendous amount of lag.

Example: Using this script i display Hero: John, HP: 50/50, MP:40/40 on the top left of the screen. On the bottom left of the screen im displaying Gold:50. Okay, then i have an event somewhere on my map that changes the Variable:Gold im displaying from 50 to 80. So now i have to clear_bitmap, and redisplay all the text on the top left of the screen (Hero:John, HP:50/50,MP:40/40), and also redisplay Gold, so that it now says Gold:80.

How would i set up an updated method of clear_bitmap in this script so that i can somehow tell it to only erase gold:50 from the screen and display gold:80, without having to worry about all the other text.

Thanks a bunch all, here is Dargor's current script he made for me. It's really short!

class Scene_Map
  alias dargor_req_draw_text_map_main main
  alias dargor_req_draw_text_map_update update
  attr_accessor    :text_sprite
  attr_accessor    :shadowed_text
  def main
    text_viewport = Viewport.new(0,0,640,480)
    text_viewport.z = 9000
    @text_sprite = RPG::Sprite.new(text_viewport)
    @text_sprite.bitmap = Bitmap.new(640,480)
    dargor_req_draw_text_map_main
    @text_sprite.dispose
  end
  def update
    dargor_req_draw_text_map_update
    @text_sprite.update
  end
  def draw_text(x,y,width,height,text,align=0,clear_bitmap=true)
    @text_sprite.bitmap.clear if clear_bitmap
    @text_sprite.bitmap.draw_text(x,y,width,height,text,align)
  end
end
 
Let's just clear that portion of the bitmap where you're drawing the new text...

Code:
class Scene_Map
  alias dargor_req_draw_text_map_main main
  alias dargor_req_draw_text_map_update update
  attr_accessor :text_sprite
  def main
    text_viewport = Viewport.new(0,0,640,480)
    text_viewport.z = 9000
    @text_sprite = RPG::Sprite.new(text_viewport)
    @text_sprite.bitmap = Bitmap.new(640,480)
    dargor_req_draw_text_map_main
    @text_sprite.dispose
  end
  def update
    dargor_req_draw_text_map_update
    @text_sprite.update
  end
  def draw_text(x,y,width,height,text,align=0,clear_bitmap=true)
    if clear_bitmap
      @text_sprite.bitmap.clear 
    else
      # clear just this section of the bitmap
      @text_sprite.bitmap.fill_rect(x,y,width,height,Color.new(0,0,0,0))
    end
    @text_sprite.bitmap.draw_text(x,y,width,height,text,align)
  end
end

Be Well

Ref: Junk123
 

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