Tsukihime 1,426 Report post Posted April 30, 2012 (edited) Picture Wrapper v1.2 Tsukihime Introduction 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.. Features -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 -fade-in/fade-out -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. Usage 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 Example 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. Script 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. Notes 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 June 14, 2016 by Tsukihime 4 Archeia, Chaos17, Aberrant Dodo and 1 other reacted to this Share this post Link to post Share on other sites
Tsukihime 1,426 Report post Posted April 30, 2012 (edited) 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 April 30, 2012 by Tsukihime Share this post Link to post Share on other sites
Chaos17 31 Report post Posted May 1, 2012 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
Tsukihime 1,426 Report post Posted May 1, 2012 (edited) 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 May 1, 2012 by Tsukihime Share this post Link to post Share on other sites
Tsukihime 1,426 Report post Posted May 3, 2012 (edited) I've added "wait for completion" functionality so you can chain a bunch of commands together. spin_pic(30) 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 image001 image002 image003 ... image012 ... 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 May 3, 2012 by Tsukihime Share this post Link to post Share on other sites
Tsukihime 1,426 Report post Posted May 6, 2012 (edited) Added four new methods grayscale_pic: toggles grayscale mirror_pic: toggles horizontal flip flip_pic: toggles vertical flip 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 May 6, 2012 by Tsukihime Share this post Link to post Share on other sites
Henry 0 Report post Posted May 24, 2012 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
Tsukihime 1,426 Report post Posted May 24, 2012 Just paste in a new page. Share this post Link to post Share on other sites
Henry 0 Report post Posted May 24, 2012 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
Tsukihime 1,426 Report post Posted May 24, 2012 What are you trying to do? These are meant for event script boxes. I've probably sample calls in the first post. Share this post Link to post Share on other sites
Henry 0 Report post Posted May 24, 2012 (edited) Actually, I'm trying to use these methods in a script in the script editor. Edited May 24, 2012 by Henry Share this post Link to post Share on other sites
Tsukihime 1,426 Report post Posted May 24, 2012 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 image.show_pic(...) 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
Henry 0 Report post Posted May 25, 2012 Thanks! Event commands are definitely simpler. Share this post Link to post Share on other sites
stramin 1 Report post Posted October 19, 2012 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
Tsukihime 1,426 Report post Posted October 19, 2012 Pictures are drawn on the screen, and the screen is basically the camera. I don't know how to draw pictures on the map directly.. Share this post Link to post Share on other sites
Galv 1,380 Report post Posted October 19, 2012 I know of Modern Algebra's script that fixes images to the map if that helps http://rmrk.net/index.php?topic=39052.0 1 stramin reacted to this Share this post Link to post Share on other sites
reLic 4 Report post Posted October 19, 2012 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
stramin 1 Report post Posted October 22, 2012 (edited) hey tsuki! I got it! module FIX module UTILITY2 FIX_PICTURE_SWITCH = 11 end # UTILITY end # FIX module Switch2 def self.fix_picture return $game_switches[FIX::UTILITY2::FIX_PICTURE_SWITCH] end end # Switch class Sprite_Picture < Sprite def update super if @picture.name != "" update_bitmap update_origin 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 else update_position end update_zoom update_other else self.bitmap.dispose if self.bitmap != nil end end end 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 October 22, 2012 by stramin 1 Tsukihime reacted to this Share this post Link to post Share on other sites
Tsukihime 1,426 Report post Posted October 22, 2012 (edited) 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 October 22, 2012 by Tsukihime 1 stramin reacted to this Share this post Link to post Share on other sites
stramin 1 Report post Posted October 22, 2012 I think is perfect in that way, you did it... (again), tsuki! Share this post Link to post Share on other sites
Tsukihime 1,426 Report post Posted October 22, 2012 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
stramin 1 Report post Posted October 23, 2012 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 tan=@picture.width.to_f/@picture.height.to_f 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 else self.x = 0 - $game_map.display_x * 32 + @picture.x self.y = 0 - $game_map.display_y * 32 + @picture.y end else p @picture.x, @picture.y self.x = @picture.x self.y = @picture.y end end Share this post Link to post Share on other sites
Tsukihime 1,426 Report post Posted October 23, 2012 (edited) lol, what is all that trig calculating? Pictures are rectangular; would that make it easier? The coords of the center is just (width / 2, height / 2) Edited October 23, 2012 by Tsukihime Share this post Link to post Share on other sites
stramin 1 Report post Posted October 24, 2012 i thinked you want to make it rotate when the origin is 0 xD well that script make the rotation in the coord (0,0) (when the origin is 0) Share this post Link to post Share on other sites
Tsukihime 1,426 Report post Posted October 24, 2012 (edited) 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 October 24, 2012 by Tsukihime Share this post Link to post Share on other sites