Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: ShadowSaber on April 19, 2011, 06:48:25 am

Title: [Resolved] Invert Graphic in Game
Post by: ShadowSaber on April 19, 2011, 06:48:25 am
Hello everyone,
I need help how to invert character graphic in map when game is playing

I found the script, but I don't know how to use it

---------edit : resolved-----------
Title: Re: Invert Graphic in Game
Post by: brewmeister on April 19, 2011, 01:49:11 pm
This is a very simple implementation of just the invert method.

#=======================================================================
# ** Additional Bitmap Methods
#-----------------------------------------------------------------------
#   By Untra
#   5/5/10
#   v0.5
#=======================================================================
  #---------------------------------------------------------------------
  # * Invert
  #   WARNING: Inverting colors is especially process consuming, and
  #     with frequent use can lag a game indefinitely. Use sparringly. 
  #   NOTE: calling an invert color method a second time will bring its
  #     colors back to normal, assuming you didn't change its colors
  #     while in negative.
  #---------------------------------------------------------------------
  class Bitmap
  def invert
    for w in 0..(width - 1)
      for h in 0..(height - 1)
        color = get_pixel(w, h)
        r = 255 - color.red
        g = 255 - color.green
        b = 255 - color.blue
        a = color.alpha
        set_pixel(w, h, Color.new(r, g, b, a)) if a > 0
      end
    end
    return self
  end
end

#=======================================================================
# ** Additional Bitmap Methods Implemented
#=======================================================================

class Sprite_Character
  alias invert_update update
  def update
    invert_update
    if @character.inverting
      self.bitmap.invert
      @character.invert
    end
  end
end

class Game_Character
  attr_reader :inverting
  alias invert_init initialize
  def initialize
    invert_init
    @inverting = false
  end
  def invert
    @inverting = !@inverting
  end
end


To change the player, call

$game_player.invert

To change an event, call

event = get_character(0)
event.invert
Title: Re: Invert Graphic in Game
Post by: ForeverZer0 on April 19, 2011, 05:42:24 pm
DELETED POST

I totally just misread what this did...

Title: Re: Invert Graphic in Game
Post by: ShadowSaber on April 19, 2011, 10:38:13 pm
thanks brewmeister, now i understand how to use it ^^