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.

Creating New Game_Picture

I have seen some threads here and there about creating pictures, something like :
Code:
$test = Sprite.new
$test.bitmap = RPG::Cache.picture('test.png')

First of all, I'd much rather have a class then just a variable (cleaner). But why bother creating a class, when there is already one, Game_Picture? Although I don't fully understand how it works.

1. It is referred as $game_screen.pictures 
 
$game_screen.pictures holds an array of Game_Pictures. Game_Picture holds all of the parameters for a picture, it does not create or store the actual bitmap for the picture.

Bitmaps don't get used by themselves. They need a sprite or window, or another object to display them.

Therefor, a Sprite_Picture object contains the bitmap & used the data from Game_Picture to determine how to display it.

You can create a Sprite (or RPG::Sprite) directly in Scene_Map if you wish. In fact, Scene_Map inits a Spriteset_Map, which contains an array of Sprite_Pictures, which in turn contain the bitmap (& picture data from Game_Picture).
It is typically better to encapsulate a class on it's own, including all of the necessary methods for that object so that they only get initilalized (loaded into memory) when an object of that class is in scope. Or, simply said, we don't create a bunch of stuff that we might use, instead create it when we know we will use it.

Z is a parameter of the Sprite class. You can specify the viewport when you create the sprite, and then control the z plane (layer) by setting the z parameter on the sprite.

I had a list of all the viewport / z values of the default objects. I'll see if I can dig it up & post it.

Be Well
 

EOG

Member

You can use Game_Picture function

Code:
$game_screen.pictures[pic_number].show("name", origin, x, y, zoom_x, zoom_y, opacity, blend_type)

example:
Code:
$game_screen.pictures[1].show("gui_zloto", 0, 0, 0, 100, 100, 255, 0)
Will show picture 'gui_zloto' as first picture at pos 0,0.

If you want to automatically set pic_number you can use loop
Code:
 for i in 0...$game_screen.pictures.size
   if $game_screen.pictures[i].name == ""
      $game_screen.pictures[i].show("name", origin, x, y, zoom_x, zoom_y, opacity, blend_type)
      break
   end
end
 
Thanks a lot for the information! You too, EOG, even though I knew that part of the things :wink:

Basically, I need only to have @graphic = Sprite_Picture.new(someviewport, Game_Picture.new) instead of just @graphic = Game_Picture.new
 

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