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.

Bitmap Distortion

Hello.

First of all, if you recall in RM2K/2, there's an option in Move Picture which distort the picture. My question is, is there a script dto do this?
ONe other thing. If there's no script for this, i'd like if someone could teach me a lil' bit the Bitmap class. My goal is to make distortion effects like in ff6 (House on fire, Dischord Skill, ect)

Thanks

EDIT:
Here's my slant bar code
Code:
for i in -10..10
   if i <=0
      self.contents.fill_rect(50 - i, 50 + 10 - i, 150 + 1, 1, Color.new(50, 50, 50, 255))
   else
      self.contents.fill_rect(50 + i, 50 + 10 - i, 150 + 1, 1, Color.new(50, 50, 50, 255))
   end
end

The lines above draws something that look like an arrow. I'm trying to animate every horizontal lines of pixel to do a "wave" effect in bitmaps but i don't know how do slant a bitmap :(

-Dargor
 
Might not be the 'distortion' you were looking for, I just wrote this stuff up now, if you want something else just say, and yeah this may be a bit hard to read, I tried to keep it short for performance. It is still veery slow.
Code:
class Bitmap

	def brighten(amount)
		for w in 0..(width - 1)
			for h in 0..(height - 1)
				colour = get_pixel(w, h)
				set_pixel(w, h, Color.new([colour.red + amount, 255].min, [colour.green + amount, 255].min, [colour.blue + amount, 255].min, colour.alpha)) if colour.alpha > 0
			end
		end
		return self
	end
	
	def pixelate(size = 2)
		for w in 0..((width - 1) / size)
			w *= size
			for h in 0..((height - 1) / size)
				h *= size
				r, g, b, a = 0, 0, 0, 0
				size.times do |i|
					colour = get_pixel(w, h)
					r += colour.red; g += colour.green; b += colour.blue; a += colour.alpha
					colour = get_pixel(w + i, h)
					r += colour.red; g += colour.green; b += colour.blue; a += colour.alpha
					colour = get_pixel(w, h + i)
					r += colour.red; g += colour.green; b += colour.blue; a += colour.alpha
				end
				fill_rect(w, h, size, size, Color.new( r / size**2, g / size**2, b / size**2, a / size**2))
			end
		end
	end
	
	def darken(amount)
		for w in 0...width
			for h in 0...height
				colour = get_pixel(w, h)
				set_pixel(w, h, Color.new([colour.red - amount, 0].max, [colour.green - amount, 0].max, [colour.blue - amount, 0].max, colour.alpha)) if colour.alpha > 0
			end
		end
		return self
	end
	
	def invert
		for w in 0..(width - 1)
			for h in 0..(height - 1)
				colour = get_pixel(w, h)
				set_pixel(w, h, Color.new(255 - colour.red, 255 - colour.green, 255 - colour.blue, colour.alpha)) if colour.alpha > 0
			end
		end
		return self
	end
	
	def to_greyscale
		for w in 0...width
			for h in 0...height
				colour = get_pixel(w, h)
				a = colour.alpha
				if a > 0
					num = (colour.red + colour.green + colour.blue) / 3
					set_pixel(w, h, Color.new(num, num, num, a))
				end
			end
		end
		return self
	end
	
	def scatter(passes = 1)
		for pass in 1..passes
			for w in 0...width
				for h in 0...height
					set_pixel(w, h, get_pixel(w + rand(3) - 1, h + rand(3) - 1))
				end
			end
		end
		return self
	end
	
end

http://img84.imageshack.us/img84/3225/effectsav9.png[/img]
 
This is nice! Even if it may be slow, it's interresting. It's not what i'm lookinf for though. If you can, take a look at FF6 title screen, you'll see a fire sprite (begind the title) moving from left to right like the picture option you had in rm2k3.

But still, your script is nice!

-Dargor
 

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