Jump to content

Recommended Posts

Picture Wrapper






There must be an easier way to work with picture objects.


This script extends the Game_Picture class with additional methods that manipulate the picture object, and exposes a set of functions to the Game Interpreter..




-change picture by name. Supports any string formatting including variable assignment

-move picture by absolute coords (relative to screen)

-move picture by relative coords (relative to image origin)

-zoom picture

-rotate picture


-spin picture around origin or top-left corner (in-progress...)

-change the tone

-change the blend type

-horizontal flip

-vertical flip

-toggle grayscale


You can combine any call together as well.




Copy into script editor.

Call the functions through script or script box

Make sure that a picture with the specified filename exists in your Graphics Pictures folder.

Examples at the top of the file




Show a picture with name "test_pic" at coords (10, 10) with opacity 255


make_pic("test_pic", 255, 10, 10)
Shift the picture to the left 20 units along the x-axis over a duration of 60 frames


shift_pic(-10, 0, 60)
Make a second picture with name "pic2" at coords(60, 10) with opacity 255)


make_pic("pic2", 255, 60, 10, 2)
Note that spin_pic(0) stops your picture from spinning.




Link: Download here


Known issues


*You should make sure you have a valid picture on the screen before you call the picture manipulation methods.

*bitmap appears to be mysterious disposed when you change scenes even though picture is still on the screen

*picture is still on the screen even if you switch maps.




When it says "wait" it means the whole game waits while the action is being processed.

I'm going to look into changing this to support two types of waits:


-whole game waits

-next event waits


Which makes more sense.


If you want something added just ask. I'm just adding wrappers based on order of difficulty.

May be updated at anytime when I find more ways to work with Picture objects.

Edited by Tsukihime

Share this post

Link to post
Share on other sites

Script has been updated with some more amusing functions.


*shift_pic - moves the picture over, relative to the current x,y coords.

*spin_pic - now you can choose to spin relative to the center of the image, or the top-left corner of the image. Not perfect though...


I am not too sure about my design though.

I basically fetch a copy of the bitmap from cache in order to have easy access to the width and height attributes.


I need those values in order to be able to spin the image on the spot.

Edited by Tsukihime

Share this post

Link to post
Share on other sites

Can you give an example, please ?

Because I would like to use your script for changing the skin of the default menu.

Is it possible ? If yes, I would like to know how to do it.

Share this post

Link to post
Share on other sites

Windowskins are controlled by the Window_Base class, so it is not related to the Game Picture class.


I've posted a topic here discussing window skin changing via script calls. I would imagine that a larger "configuration" script already has window skin changing support but I don't know what they might be.

Edited by Tsukihime

Share this post

Link to post
Share on other sites

I've added "wait for completion" functionality so you can chain a bunch of commands together.


move_pic(0, 0, 60, true)


would allow you to spin your picture while it's moving to the target coords.


Also note that spin_pic(0) turns off spinning, if you're wondering how to stop your image from spinning.


Note that not every method has a "wait" function because it doesn't really make sense for pictures that don't take effect over a period of time to have a wait option.


I have tried to implement a very simple "animation" features where it assumes your pictures are stored like




But it is TOO slow since they are not cached apparently. So I have not included it.

Maybe if I find a better way to do it.


I've also generalized it so you can draw a picture in a battle as well.

The problem is that you could in theory want to draw a picture anywhere (through script calls from the script editor) but I haven't seen anything that requires that.

Edited by Tsukihime

Share this post

Link to post
Share on other sites

Added four new methods


  1. grayscale_pic: toggles grayscale
  2. mirror_pic: toggles horizontal flip
  3. flip_pic: toggles vertical flip
  4. spin_pic: toggles spinning on and off (corrected from before)


When I say horizontal flip, it means I'm flipping it along y-axis, relative the center of the image. Similarly, vertical flip is along x-axis. It is not the same rotating 180 degrees.


Spinning has also been implemented correctly. Now you can toggle spinning on and off.

All operations can be combined together.


I rewrote the library by moving all of the picture indices to the first argument. Turns out the index is used more often than all the other parameters after I took this picture lol.





Edited by Tsukihime

Share this post

Link to post
Share on other sites

Thank you for your script, Tsukihime. :)


I've some questions, being a beginner in RGSS: must I paste the whole script in a new page in RGSS3 script-list or

must I paste its methods in their respective class?

Share this post

Link to post
Share on other sites

Thanks for you answer!

I've just did that, however the game returns a script error.


Which class must I call to display a picture with your script? I tried Game_Picture

(with @image = Game_Picture.new) but that doesn't remove the error.


Could you help me out?

Share this post

Link to post
Share on other sites

I haven't written any scripts using these methods.

You would need to create a picture sprite and assign it a specific Game_Picture.


image = Game_Picture.new
sprite = Sprite_Picture.new

#somehow assign the image to the sprite



And then you need to make sure the sprite is getting updated.

It is not simple.

Share this post

Link to post
Share on other sites

Hello Tsukihime!


I used your script to make a light effect, but I think doesn't have the feature what I need :(


I'm looking for a way to show map position relative pictures, not screen relative, so when the player walk the picture moves with the map (just like RPGMaker 2000)


Do you know a way to do it?


If its not possible, its a good idea for an update, don't you think?

Share this post

Link to post
Share on other sites

Hi, Love your script and using it in my game. I recently started to add save points in my game and discovered that after displaying a picture using your script i wasn't able to save my game anymore. I looked in another thread http://www.rpgmakervxace.net/topic/4601-yanfly-saving-glitch/ and noticed others have the same problem. However using his fix (Comment out code) didn't help for me.


Do you have any other ideas on how to fix this problem? Or could you show me some code on how to display a picture without using your script?

Share this post

Link to post
Share on other sites

hey tsuki! I got it!




module FIX
 module UTILITY2
 end # UTILITY
end # FIX

module Switch2
 def self.fix_picture
return $game_switches[FIX::UTILITY2::FIX_PICTURE_SWITCH]
end # Switch

class Sprite_Picture < Sprite
 def update
	if @picture.name != ""
		if Switch2.fix_picture or @picture.name.include?("[FIXED]")
		  self.x = 0 - $game_map.display_x * 32 + @picture.x
		  self.y = 0 - $game_map.display_y * 32 + @picture.y
		self.bitmap.dispose if self.bitmap != nil


its a mix from 2 scripts (Seer UK and Yanfly Channel), when the switch 11 is on all the pictures are fixed, when the picture name contain "[FIXED]" that picture is fixed.


I think you could add this on your script, because your picture wrapper is the best picture script i ever seen... well the Yanfly Channel made a flip picture switch too, very useful

Edited by stramin

Share this post

Link to post
Share on other sites

I have added that snippet into the picture wrapper.

I have added the following function


fix_pic(index, bool)


If the picture is not fixed, it will become fixed.

You can pass in `false` for the bool if you want to un-fix it.


However, I have not worked out the coordinates when you change the fixed value so...you should avoid doing that.


Instead, you should specify the fixed value when you create the picture


make_pic(1, "name", opacity, x, y, origin, fixed)


Then the picture will appear in the correct spot, where x and y is the position in tiles.

Edited by Tsukihime

Share this post

Link to post
Share on other sites

I really have to do something about the coordinates.

As well as the origin. It is somewhat inconsistent...


I said the default origin should be 1 (centered) because that makes rotating images really easy, but I think some parts assume origin 0..

Share this post

Link to post
Share on other sites

ok, i think this is what you want, but looks some choppy:


# Offset the image to the origin
 def update_fixed
   if @picture.fixed
  if !@origin
    midhyp=Math.sqrt(@picture.width.to_f**2 + @picture.height.to_f**2)/2
    plus=Math.atan(tan) / Math::PI * 180
    anglecos1=Math.cos((@picture.angle.to_f+plus.to_f+270) * Math::PI / 180)
    anglecos2=Math.cos((@picture.angle.to_f+plus.to_f+0) * Math::PI / 180)
    self.x = 0 - $game_map.display_x * 32 + @picture.x + anglecos1 * midhyp
    self.y = 0 - $game_map.display_y * 32 + @picture.y + anglecos2 * midhyp
    self.x = 0 - $game_map.display_x * 32 + @picture.x
    self.y = 0 - $game_map.display_y * 32 + @picture.y
  p @picture.x, @picture.y
  self.x = @picture.x
  self.y = @picture.y

Share this post

Link to post
Share on other sites

It's probably easier to just assume all positions are specified based on centered origin and simply offset the picture by (width/2, height/2) to make up for that.


Internally they would be stored as centered origin, but of course I tell people to think in terms of upper-left because...that is probably easier to imagine.

Edited by Tsukihime

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.