Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Displaying a Reversed Image, How do you draw a reversed version of the desired image with RGSS?
lemonairable
post May 26 2011, 07:37 AM
Post #1


Level 4
Group Icon

Group: Member
Posts: 50
Type: Writer
RM Skill: Skilled




How do you draw a reversed image with RGSS? As in, if I want to display a character portrait facing right at one point, and facing left at another, how would I do that? I think it would probably be a simple code thing, right?
Go to the top of the page
 
+Quote Post
   
Kread-EX
post May 26 2011, 07:42 AM
Post #2


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




You can but it's a slow process so unless the picture is small you'll be better with just making a flipped version in an image editing program.
Do you intend to do that in an event or within a script?

EDIT: Disgerard what I just stroke. Actually, it's much faster that I expected. But the last question remains: do you want to do it on the map or within a script?


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Xim
post May 26 2011, 07:42 AM
Post #3


Level 6
Group Icon

Group: Member
Posts: 89
Type: Developer
RM Skill: Intermediate




QUOTE (Kread-EX @ May 26 2011, 11:42 AM) *
You can but it's a slow process so unless the picture is small you'll be better with just making a flipped version in an image editing program.


This might actually work out better for asymmetrical characters (ie: a character with an eye-patch) so his eye-patch won't switch eyes (although you'd have to make a new picture).

This post has been edited by Xim: May 26 2011, 07:43 AM


__________________________
The Black Walkway DEMO RELEASED!
Go to the top of the page
 
+Quote Post
   
lemonairable
post May 26 2011, 07:51 AM
Post #4


Level 4
Group Icon

Group: Member
Posts: 50
Type: Writer
RM Skill: Skilled




I want to do it within a script.
Specifically, in battles.
Go to the top of the page
 
+Quote Post
   
Kread-EX
post May 26 2011, 07:56 AM
Post #5


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Okay. What exactly do you want to flip? You mentioned a portrait so I take you are using a custom battle system that displays the face of the actors? Which one?


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
lemonairable
post May 26 2011, 08:03 AM
Post #6


Level 4
Group Icon

Group: Member
Posts: 50
Type: Writer
RM Skill: Skilled




It's an original made my somebody at savepoint:

The Code

CODE
#===========================================================
# ** Window_Portrait
#===========================================================
class Window_Portrait < Window_Base
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #-----------------------------------------------------------------------------
  def initialize
    super(483, 0, 160, 170)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
  #-----------------------------------------------------------------------------
  # * Draw Actor Graphic
  #-----------------------------------------------------------------------------
  def draw_actor_face_graphic(actor, x, y)
    bitmap = RPG::Cache.picture(actor.id.to_s)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  end
  #-----------------------------------------------------------------------------
  # * Refresh
  #-----------------------------------------------------------------------------
  def refresh(actor)
    self.contents.clear
    draw_actor_face_graphic(actor, 0, 0)
  end
end



There are also minor edits to Scene_Battle 1 and 3, detailed in MGC's second post here:
http://www.save-point.org/showthread.php?t...=22512#pid22512

This post has been edited by lemonairable: May 26 2011, 08:05 AM
Go to the top of the page
 
+Quote Post
   
Kread-EX
post May 26 2011, 08:39 AM
Post #7


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Tough luck: it's not a sprite but a window so the method to draw the flipped graphic will indeed be the slow one. So I'll give you two options: flipping with script (slow) or switching to another file flipped with an image editing program.

In the first code MGC gave you (Window_Portrait), modify the refresh method like this:

CODE
  #-----------------------------------------------------------------------------
  # * Refresh
  #-----------------------------------------------------------------------------
  def refresh(actor, flip = false)
    self.contents.clear
    draw_actor_face_graphic(actor, 0, 0, flip)
  end

Then modify draw_actor_face_graphic like this:
CODE
  #-----------------------------------------------------------------------------
  # * Draw Actor Graphic
  #-----------------------------------------------------------------------------
  def draw_actor_face_graphic(actor, x, y, flip)
    bitmap = RPG::Cache.picture(actor.id.to_s)
    flipped_bitmap = Bitmap.new(bitmap.width, bitmap.height)
    rect = Rect.new(0, 0, 1, height)
    if flip
      bitmap.width.times do |i|
       rect.x = bitmap.width - 1 - i
       flipped.blt(i, 0, bitmap, flip_rect)
      end
      self.contents.blt(x, y, bitmap, Rect.new(0, 0, flipped.width, flipped.height))
    else
      self.contents.blt(x, y, bitmap, Rect.new(0, 0, flipped.width, flipped.height))
    end
  end

Now, in the 3rd piece of code MGC gave you, look at this:
CODE
    # refresh the portrait
    @window_portrait.visible = true
    @window_portrait.refresh(@active_battler)

Setup the conditions for the flip (I don't know what they are so I can't do it) and to activate it, simply replace @window_portrait.refresh(@active_battler) with @window_portrait.refresh(@active_battler, true) and this is it.

In the event you want to use flipped pictures rather than flipping them with the script (and you should), use the same syntax than before for your file and simply add _flipped at the end. Then, modify draw_actor_face_graphic like this:
CODE
#-----------------------------------------------------------------------------
  # * Draw Actor Graphic
  #-----------------------------------------------------------------------------
  def draw_actor_face_graphic(actor, x, y, flip)
    bitmap = RPG::Cache.picture(actor.id.to_s + '_flipped')
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, flipped.width, flipped.height))
  end


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
lemonairable
post May 26 2011, 08:50 AM
Post #8


Level 4
Group Icon

Group: Member
Posts: 50
Type: Writer
RM Skill: Skilled




Thank you. This was the last thing I needed to complete my custom battle system.
Go to the top of the page
 
+Quote Post
   
Redd
post May 26 2011, 03:36 PM
Post #9


:<
Group Icon

Group: Revolutionary
Posts: 2,310
Type: Developer
RM Skill: Advanced




Why not just flip it around in paint?


__________________________
Go to the top of the page
 
+Quote Post
   
lemonairable
post May 26 2011, 05:50 PM
Post #10


Level 4
Group Icon

Group: Member
Posts: 50
Type: Writer
RM Skill: Skilled




@Redd: They have to be facing right at one point and left at another.

@Kread_EX: Slight problem with this portion of the script:
CODE
#-----------------------------------------------------------------------------
  # * Draw Actor Graphic
  #-----------------------------------------------------------------------------
  def draw_actor_face_graphic(actor, x, y, flip)
    bitmap = RPG::Cache.picture(actor.id.to_s + '_flipped')
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, flipped.width, flipped.height))
  end


I'm getting "wrong number of arguments (3 for 4)" on the line after the note. I believe it is the (actor, x, y, flip) that is causing the problem.
Go to the top of the page
 
+Quote Post
   
Kread-EX
post May 27 2011, 01:24 AM
Post #11


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Did you add the flip to refresh? Like this:
CODE
  #-----------------------------------------------------------------------------
  # * Refresh
  #-----------------------------------------------------------------------------
  def refresh(actor, flip = false)
    self.contents.clear
    draw_actor_face_graphic(actor, 0, 0, flip)
  end

You can see I added it to draw_actor_face_graphic here too. The error happens because it's probably not added here.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
lemonairable
post May 27 2011, 07:39 AM
Post #12


Level 4
Group Icon

Group: Member
Posts: 50
Type: Writer
RM Skill: Skilled




Oh, nevermind. All I had to do was add an extra "end."

This post has been edited by lemonairable: May 27 2011, 07:41 AM
Go to the top of the page
 
+Quote Post
   
Redd
post May 28 2011, 09:08 PM
Post #13


:<
Group Icon

Group: Revolutionary
Posts: 2,310
Type: Developer
RM Skill: Advanced




So all you would have to do is make two copies of the image, one facing right and one facing left, right?

Or am I totally missing something here?


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th May 2013 - 11:30 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker