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.

Drawing graphic in menu by center pixel

Culex

Member

I have acquired Momomo's Bestiary Script, and I have personalized it to have all stats where I would like them. The one problem that I'm having however, is that I would like to be able to draw the monsters by their center pixel and not their upper left pixel, so that when I'm scrolling through the different monsters, they are always in the center of the window. Also, I found this topic:

http://www.rmxp.org/forums/showthread.php?t=4844&highlight=center

...about ox and oy, but I obviously don't understand it (having tinkered with those values in my window for while). It seems to be the closest thing to my topic that I could find in the forums, but I don't even know if it will help. If further clarification is necessary, please do not hesitate to ask. Thanks in advance.
 

Culex

Member

@Daniel : I did try that. I make sure to tinker with things a LOT before I ask for help, but thanks a lot anyway! :D

Since my current method and the draw actor graphic method are basically the same, we can use that:

Code:
 def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end

And we can use the default Window_Status for the sample window where we will draw it, under def refresh and self.contents.clear:

Code:
[...]
draw_actor_graphic(@actor, 40, 112)
[...]

I believe that's where I want to act upon changing x and y values to ox and oy values, but I can't seem to get it to work.

When test playing, you can see that the basic hero sprites will not show much of a difference in centering, so for testing I used sprites 100-Monster14 and 088-Monster02 (two VERY different sprite sizes). I hope this helps, and forgive me if it isn't enough clarification!
 

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