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.

Capturing the screen

Status
Not open for further replies.

khmp

Sponsor

Does RGSS have the functinality to capture the screen and store the pixel information in a buffer like lockrect does in directx? Or does it store the information in an available manner to directly manipulate the data? It probably has been asked before and so I apologize, and the answer most likely no, but I still wanted a definite answer from the local gurus.
 
khmp;277688 said:
Alright. Thanks Slipknot for the quick reply. I guess I should rethink how I'm going to do that menu.

My old, old project has a menu that uses the current map as a very faded background behind a parchment-textured foreground. I'll look into the script quickly to see how I did it. I'll let you know though that it was a long time ago so I might forget :)

EDIT: Basically what I did was I preserved $scene_map temporarily by assigning it to a global variable called $scene2, which is called once to draw all the graphics and such but is not updated continuously like $scene is (within Main). What this basically did is allow me to have the map hidden behind the menu so you could still see it. Sounds like what you're trying to do is take a screenshot using scripts which is what I would have preferred to do for that menu system but I had to settle for what I thought was the next best thing. Sorry I couldn't help.
 

khmp

Sponsor

Sir you have accomplished precisely what I was attempting to do ^_^. So preserving the old scene with a global huh? The screenshot idea I had was so I could create a temporary snapshot of the scene_map just before I went into the scene_menu sequence. The menu would overlay this picture and I could edit it if need be. But from what I've gathered it would require some extraneous steps to accomplish. Would you mind if I looked over your code to see how exactly? Is your game w/ source available for download?
 
khmp;277760 said:
Sir you have accomplished precisely what I was attempting to do ^_^. So preserving the old scene with a global huh? The screenshot idea I had was so I could create a temporary snapshot of the scene_map just before I went into the scene_menu sequence. The menu would overlay this picture and I could edit it if need be. But from what I've gathered it would require some extraneous steps to accomplish. Would you mind if I looked over your code to see how exactly? Is your game w/ source available for download?

I've long since abandoned the project but I can hook you up with my Scene_Map doc and if you'd like to we can chat on AIM and walk through the process again together. I wouldn't mind re-learning my old logic again =p
 
no there is an easier way rather than using globals (bad programming practice) , and you can thank Seph

The Screenshot module created by Andreas21 & Cybersam is included in the MACL (it was added by Seph)

to use it all you do is call

Screenshot.shot(filename, image_type)

where filename is the filename to save to
image_type is either 0 for bmp 1 for jpg or 2 for png

and that will capture the screen
 

khmp

Sponsor

Yes I was just wandering through that complete.txt in the MACL 2.1. That is some conglomeration of functionality. Gratz to Trickster, Selwyn, Yeyinde, Lobosque, Andreas21, Cybersam and others who weren't listed in the documentation.txt :). The screenshot functionality in it though, takes it beyond my purposes. I need the screen's pixel information to remain in the code. Actually I guess I haven't really explained what I was going to use it for. Much like what Justin had done with another scene global, I need to overlay Scene_Map last image before entering Scene_Menu. If I could generate a bitmap based on the last updated Scene_Map screen before entering Scene_Menu I could perform other actions on it like blurring etc.:thumb:

Now so far I have a few ideas about it.
1.) Use an alternate scene global. I haven't done this yet but according to Justin its feasible.
2.) (Nasty Disclaimer) Take a screenshot as I leave the Scene_Map screen. Then load the screenshot as a picture when entering Scene_Menu and then when leaving the Scene_Menu delete the picture.
3.) (Nasty Disclaimer) Bloat the code in Scene_Map by never truly leaving the scene to get to Scene_Menu and instead store all the work inside Scene_Map
4.) (Easy Disclaimer) Create a static picture for Scene_Menu.

[edit for atrocious grammar
 
Well then what I suggested is what to do if you were going to do something more complex

but if you just want the map in the background it is much more efficient to just do this in Scene_Menu

either add this in a new script

Code:
class Scene_Menu
  alias_method :mapbackground_initialize, :initialize
  def initialize
    @spriteset = Spriteset_Map.new
    mapbackground_initialize
    @spriteset.dispose
  end
end

or add this directly in Scene_Menu initialize

Code:
class Scene_Menu
  def initialize
    @spriteset = Spriteset_Map.new
    #code here
    @spriteset.dispose
  end
end

Spriteset_Map is the actual object that draws the map image you see in Scene_Map by just creating an instance of that object gives you the map screen at that current instant

If you want the map to be animated just add in your update method
Code:
$game_map.update
@spriteset.update

and that updates the map and the spriteset causing the map to move

but yeah that is another way of going about it
 

khmp

Sponsor

Thanks so very much Trickster. I had no idea it would be so simple and you saved me a lot of head ache. However I don't want to bug about things but could you clarify in both examples? You have the disposal of the Spriteset_Map instance at the end of initialize function. Does that not effectively destroy it, making unusable outside the scope of initialize? Should disposal occur rather at the end of main after the loop has broken? Again sorry to bug you with follow ups I was just curious about it.:D
 
you asked for it you got it

alias is a keyword in ruby it allows you to make a copy of a method or variable a good use for this is adding code to methods without actually overwriting the method.

it can be useful for sharing scripts and making code easily portable in many projects, but if you are just using a script for yourself then overwriting the method is better since the method call depth isn't as great. (Each time the method is aliased you have to call one more method in a method adding to the depth)

so here's how you alias

you start with the keyword alias and then type the name of the new name for the method and then type the name of the original so...

alias new_name original

then you can do whatever with the original you can overwrite it and then call the new method like so

Code:
def original
  p "Hey this is the original"
end

alias new_name original
def original
  p 'this is the new method'
  new_name
end

original #=> prints to screen 'this is the new method'
          #     then prints to screen "Hey this is the original"

but with aliasing you can only add code to the beginning or end of a method, there are some methods that if you write it correctly you can make it seem like you replaced code in the center of a method (the method has to be written a certain way)

There is also alias_method which does the same thing except you are sending symbol objects and alias_method is a method

alias_method :new_name, :eek:riginal

Generally alias_method is used in SDK scripts so that the SDK keeps track of what is aliased (this is for script incompatibility checking)

but that is a quick note on aliasing, there are also tutorials available in the Tutorials forum about the topic so check there if you want to learn more about it
 
Status
Not open for further replies.

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