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.

Ive got lag!!!

Hey, I have this small script using StephSpawns slant bar, but i'm getting a tonne of lag! its going at 7/8 FPS!!! I'm using it in the Help Window when you go over an enemy, heres the code

Code:
  def set_enemy(enemy)
    text = enemy.name
    state_text = make_battler_state_text(enemy, 112, false)
    if state_text != ""
      text += "  " + state_text
    end
    text += " " + enemy.hp.to_s + "/" + enemy.maxhp.to_s
    draw_slant_bar(x + 120 ,y + 27, enemy.hp, enemy.maxhp, 80, 6)
    set_text(text, 1)
  end

Thanks :D
 
I'm really sorry, but would you be able to make the script quickly for me, just combine what you've said and the script i posted,

Thank you very much :D:D:D

EDIT: Sorry, Ive just got what you wrote, Thanks :D
 
OK, this is the code that I now have:

Code:
def set_enemy(enemy)
    text = enemy.name
    state_text = make_battler_state_text(enemy, 112, false)
    if state_text != ""
      text += " - " + state_text
    end
    text += " - " + enemy.hp.to_s + "/" + enemy.maxhp.to_s
    if text != @text
      draw_slant_bar(contents.width / 2 - 67, 25, enemy.hp, enemy.maxhp, 135, 6) # 80
    end
    draw_slant_bar(contents.width / 2 - 67, 25, enemy.hp, enemy.maxhp, 135, 6) # 80
    set_text(text, 1)
  end
end

But I'm still getting the lag!?

Thank You :D
 
Because the set_text method clears the windows contents.

Use this:

Code:
  def set_enemy(enemy)
    text = enemy.name
    state_text = make_battler_state_text(enemy, 112, false)
    if state_text != ""
      text += " - " + state_text
    end
    text += " - " + enemy.hp.to_s + "/" + enemy.maxhp.to_s
    return if @text == text
    draw_slant_bar(contents.width / 2 - 67, 25, enemy.hp, enemy.maxhp, 135, 6) # 80
    set_text(text, 1)
  end
 

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