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.

Using self.contents.fill_rect with 0 opacity to erase?

I don't know how the self.contents.clear method works, but would it reduce lag on equip screens, etc. if I used self.contents.fill_rect to erase only the parts that need refreshing while scrolling through the menus (numbers and such) so that the game does not have to redraw text like "Attack:", "Defense:", etc? Or is the self.contents.fill_rect method in itself slow? Thanks in advance.
 
fill_rect should be faster than draw_text (as draw_text is one of the heavier methods to use overall), but it's still a highly resource-wasting way to do things. Either way, you shouldn't have any issues drawing a couple strings here and there more, but yeah - of course, perfectionism is to be encouraged :p
So instead, you might want to try something like this:

Code:
def initialize

  # blah blah

  init_refresh

end

def init_refresh

  # draw constant strings here

  # draw functional here

def refresh

  # draw functionals here

end

That way, you're only drawing what's necessary. Note that you can't really use self.contents.clear here though, so you'd have to fish the values from the array.

After all, I think the regular way is the best to go with.
 
It clears the whole self.contents bitmaps, which means whatever you define by 'self.contents =' will be disposed by that. I doubt there's a chance to reasonably pass this.

Like I said earlier on, you might be best off with just the regular way of drawing texts again... you still being here makes me wonder if you got some special conditions which cause you problems. Regarding the topic, it's very likely that you did that something a more complicated way that it'd be needed... like I said, IF there's anything behind this.
 

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