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.

RMXP or RMVX question about sprite scaling

It doesn't matter for which since I have both, I prefer VX if possible.
I am not sure if this is possible or even asked before if it has please point me in the right direction.

I am wondering if its possible and if so how to go about scaling the character sprites for like NPC's like if I wanted the sprite to appear smaller or larger. I am not worried about if they look pixeled. THe reason I am asking I was thinking of doing a mad sciencist type of scene where a NPC is caused to either shrink or grow and I wanted to show it with the character sprites. I am not real familar with scripts but if they are written I know enough about programing where I can read whats going on.

THanx again for all and any help with this question. I had some other questions but I did find those answers already on this forum. Such as having scrolling pictures (for like credits or still frame cutscenes).
 
would that really work in the RMXP / RMVX though? Cause I want the NPC to still be useable in the game to like 'talk' too etc. Something tells me simply rescaling the file outside of the main program isn't going to really help.
 

khmp

Sponsor

[edit Answer]
Alright good news:
Code:
#==============================================================================
# ** Game_Character (part 1)
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :algn_shrinking_game_character_initialize, :initialize
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :shrinking
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    algn_shrinking_game_character_initialize
    @shrinking = false
  end
  #--------------------------------------------------------------------------
  # * Shrinky Dink Mode On
  #--------------------------------------------------------------------------
  def shrink
    @shrinking = true
  end
  #--------------------------------------------------------------------------
  # * Get Bigger Quicker
  #--------------------------------------------------------------------------
  def unshrink
    @shrinking = nil
  end
end

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  This sprite is used to display the character. It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Character < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :algn_shrinking_sprite_character_update, :update
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  SHRINK_RATE = 0.02 # Translates to a percentage of a 100%
  SMALLEST_SIZE = 0.20 # The smallest percentage size the character can be.
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    algn_shrinking_sprite_character_update

    # If the character is shrinking.
    if @character.shrinking
      # Test to see if we should continue to shrink.
      if self.zoom_x > SMALLEST_SIZE
        self.zoom_x -= SHRINK_RATE
        self.zoom_y -= SHRINK_RATE
      else
        # Just in case the rate is uneven.
        self.zoom_x = SMALLEST_SIZE
        self.zoom_y = SMALLEST_SIZE
      end
    else
      # If we are still smaller than 1.0
      if self.zoom_x < 1.0
        self.zoom_x += SHRINK_RATE
        self.zoom_y += SHRINK_RATE
      else
        # Just in case the rate is uneven.
        self.zoom_x = 1.0
        self.zoom_y = 1.0
      end
    end
  end
end

Uh I hope this is just a problem I have but it's really cool and odd at the same time. There is a mysterious bug which I can not for the life of me figure out. Inside the method unshrink I have added a line. It does nothing really but when the method had only @shrinking = false the player would hang and you could not move. The line must do some sort of work it can not be a comment. At least thats what was happening to me. It is by far the oddest thing I've ever encountered in RMXP. Anyway if you do get rid of that line and the player still moves, great. Just tell me so.

Anywho how it works. First install the script by creating a new section above Main in your Script Editor. Paste in the code I gave you above.

If you want the player to shrink. Use the event command "Script.." with the following line:
Code:
$game_player.shrink
If you want the player to get back to normal size:
Code:
$game_player.unshrink

Good luck with it Allogagan! :thumb:
 
Thanx, how about the other way make them giant size?

And I copied the previous script but not quite sure how to get it to work... I tried to have a NPC ask you should they drink something and have a yes or no, yes would shrink the NPC and no wouldn't. But nothing happen or got an error syntax message. Guess I need more help then I thought.
 
I'm not sure what you're doing wrong; you sure you pasted it in a new, clean section above "Main" and below "Scene_Debug" in the Script Editor?

But khmp, about the "@shrinking = false" glitch, I think it might be because of some weird bug in RGSS. Try changing it to "@shrinking = nil". There's a glitch that happens when turning off switches or other things via scripting, and "nil" gets rid of the error.
 

khmp

Sponsor

Allogagan":23h7zn1r said:
Thanx, how about the other way make them giant size?

And I copied the previous script but not quite sure how to get it to work... I tried to have a NPC ask you should they drink something and have a yes or no, yes would shrink the NPC and no wouldn't. But nothing happen or got an error syntax message. Guess I need more help then I thought.

Open your project in RMXP hit F11, this will bring up your script editor. Now right click "Main" in the script listings in the left portion of this window. You might need to scroll down its the very last item. After right clicking it select "Insert". Now copy the code I gave you above in this thread and paste it into the section on the right. Name this section something memorable and click "Apply". Now exit the editor and create an event on your start map. Use the "Script..." event command and use the following line:
Code:
$game_player.shrink
To unshrink your character do the same kind of thing with the event but use this line instead:
Code:
$game_player.unshrink

Regimos":23h7zn1r said:
I'm not sure what you're doing wrong; you sure you pasted it in a new, clean section above "Main" and below "Scene_Debug" in the Script Editor?

But khmp, about the "@shrinking = false" glitch, I think it might be because of some weird bug in RGSS. Try changing it to "@shrinking = nil". There's a glitch that happens when turning off switches or other things via scripting, and "nil" gets rid of the error.

Do you get the same problem? I mean about the Interpreter hanging but the Graphics still going? Setting it to nil in place of false does indeed resolve the issue. That is kind of funny though. Makes debugging a fun and exciting experience it does.

Thanks Regimos! :thumb:
 
khmp":1p6dr89z said:
Do you get the same problem? I mean about the Interpreter hanging but the Graphics still going? Setting it to nil in place of false does indeed resolve the issue. That is kind of funny though. Makes debugging a fun and exciting experience it does.

Well, I'm not much of a scripting genius, but I learned it from DerVV when studying self-switches. I'm not exactly sure why it happens, but I just use "nil" in place of "false" everywhere to avoid it (unless it's x == false, that's okay) :smile:
 
Ok I got the shrinking to work my character in my RMXP (have to try the updated code on RMVX still) but 2 things, I also wanted a 'grow' version plus I wanted it to do it to a NPC also not just my characters. i.e. There is a person walking in a town and for somereason the person shrink/grow type of thing.

I do thank you all for the help so far.
 
Ok update since my last message a little bit ago.
The script works fine on my party character on the screen both grow and shrink (I played around with the var in the main code and firgure out the grow part as an example instead of 0.2 I changed it to a higher number such as 2.00 and it works as a grow code.) But I wanted it also to have a code to make the NPC characters grow/shrink also not sure exactly has to be changed for that.

Also this code seems to only work in RMXP not in RMVX. RMVX gives an error about an undefined sprite when you first load up your game and then doesn't work at all. So that part isn't a real big deal to me since I don't mine using RMXP if I need too for making my game I want to play around with even though I prefered RMVX. The only thing more I would want is a code for the NPCs. I am assuming RMXP can show Picture files also (such as Jpgs and such up to a certien rez) cause this code is going to be for a cut scene or two. Maybe even make it a main theme in the game. I am willing to add a credit to the ones making these codes for me since they are doing all the work and I am just testing them out to see if the fit my needs and so far they are working pretty good.
 

khmp

Sponsor

Oh sorry yes I only used and tested it in RMXP. To get the VX equivalent you'll have to rewrite the whole thing! And have to know a tad of calculus and physics. Or CTRL-H and do the following:

Find What:
Code:
class Sprite_Character < RPG::Sprite
Replace with:
Code:
class Sprite_Character < Sprite_Base

And that should fix your problem. Aren't the characters small enough in VX though?  :huh:

Good luck with it Allogagan! :thumb:
 
was that last post to change the sprites of the Party members in VX?

I started off really asking how to do it to NPC like people in towns etc. Not so much my party members.

P.S. I wasn't sure but the new code didn't seem to work in RMXP.
 
:thumb: Your number 1 man, thank you. This was exactly wanted I wanted to see and findout.

I will have my notes including your name and this site to give credit for the script. If and when I make a game. Thanks again. Your right about the size of the sprites on VX may do the game in RMXP since it has the features I would need anyway (MP3 and Picture).
 

khmp

Sponsor

Personal credit isn't necessary although the site would probably appreciate it. Just glad it worked out in the end. Out of curiosity and to better help anyone else who might have a problem installing/using this or other scripts. What did you do differently than what was in the demo?
 
I didn't try the VX one yet since VX is on my desktop, and XP is on my Laptop which I use most of the time. But as far the XP script I didn't know what to use for the NPC (other characters) so I was pretty much guessing what the name should be once I seen it the demo I understood what I was naming it was wrong and what the name should be. In the case of the NPC on the XP version it was game_map.event[n] with N being the event number as used in the XP's Event listings. I kept thinking of the NPCs as another character not so much as an Event for somereason.

Also as far as making the character or npc's bigger instead of smaller I changed the script where it has the scale (defult was 0.20 to a number larger then 1.00 in my case I may be using 2.00 or 3.00 (2 times or 3 times) larger that way they are not too pixed but yet still noticable larger.

As a side note the script as written causes the shrinking and unshrinking effect have a smooth effect where if I change to make a grow effect the effect doesn't happen, while this will not matter for what I am going to be doing I just thought I would mention it.

I took your demo you made for the RMXP opened the file inside my RMXP and looked both at the Script and each of the example's scripts listed in their events. Which gave me the scripts I need to make my own for either the Party or a NPC (event).  :lol:
 
khmp":34hazvjk said:
Personal credit isn't necessary although the site would probably appreciate it. Just glad it worked out in the end. Out of curiosity and to better help anyone else who might have a problem installing/using this or other scripts. What did you do differently than what was in the demo?

Ok on my desktop and tested out the RMVX version, what I was doing differently there was I had $game player and it should be $game_player (no space) which may be why it wasn't working for me.
 

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