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.

VX to XP-Converter

title12iw6.png


Features and Usage:
Hey everyone.
Well, I think this was my first script so dont look at the code, just use it.
I like the VX-RTP very much so I made this script, which converts the VX ressources to XP.

To use it, copy and paste the two scripts above main. Copy the VX-ressources in the project-file and use this call script:
Code:
$vxtoxp = VX_to_XP.new("source","target","type"(,shutdown))
You dont need to write shutdown, you can also give only 3 parameters.
The source is the VX-picture (for example "Graphics/Pictures/Monkey")
The target is the file and the name of the converted picture
If you give true as fourth parameter the 'game' will close after converting the file
Type can be
Characters, for converting Characters
Faces, for converting Faces
Tile, for converting TileB,TileC,TileD and TileE
Balloon, for converting Balloon
Icons, for converting Icons
Bigchar, for converting Characters with $
A1/A2/A3/A4, for converting the corresponding Tiles
Then just wait, espacially with Ballon it will take some seconds.

I added some extra-features. The third script can do three things. Use this call script:
Code:
$extra = Extras.new("source","target","type"(,shutdown))
Source has to be an Array, which is made like this:
Code:
array = ["Number1","Number2"...]
$extra = Extras.new(array,"target","type"(,shutdown))
Now, type can be other things:
Tilefusion, combines the source-tilesets (all in the array)
Autofusion combines two autotiles or an autotile with a tile. Here the array must have 2 elements. It takes the second array-element and copies it above the first. If one element is not an Autotile but a 32x32 tile, it is copied to a 96x128 Picture.

Credits
Me (Neo-Bahamut) and 本脚本出自www.66rpg.com,转载请注明。, well who ever they are, i got the "Save-as-png-Script" from them ^^

Skripts:
Code:
#==============================================================================
#           本脚本出自www.66rpg.com,转载请注明。
#==============================================================================
=begin
==============================================================================
                    Bitmap to PNG By 轮回者
==============================================================================
 
 对Bitmap对象直接使用
 
 bitmap_obj.make_png(name[, path])
 
 name:保存文件名
 path:保存路径
 
 感谢66、夏娜、金圭子的提醒和帮助!
 
==============================================================================
=end
 
module Zlib
  class Png_File < GzipWriter
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def make_png(bitmap_Fx,mode)
  @mode = mode
  @bitmap_Fx = bitmap_Fx
  self.write(make_header)
  self.write(make_ihdr)
  self.write(make_idat)
  self.write(make_iend)
end
#--------------------------------------------------------------------------
# ● PNG文件头数据块
#--------------------------------------------------------------------------
def make_header
  return [0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a].pack("C*")
end
#--------------------------------------------------------------------------
# ● PNG文件情报头数据块(IHDR)
#--------------------------------------------------------------------------
def make_ihdr
  ih_size = [13].pack("N")
  ih_sign = "IHDR"
  ih_width = [@bitmap_Fx.width].pack("N")
  ih_height = [@bitmap_Fx.height].pack("N")
  ih_bit_depth = [8].pack("C")
  ih_color_type = [6].pack("C")
  ih_compression_method = [0].pack("C")
  ih_filter_method = [0].pack("C")
  ih_interlace_method = [0].pack("C")
  string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
           ih_compression_method + ih_filter_method + ih_interlace_method
  ih_crc = [Zlib.crc32(string)].pack("N")
  return ih_size + string + ih_crc
end
#--------------------------------------------------------------------------
# ● 生成图像数据(IDAT)
#--------------------------------------------------------------------------
def make_idat
  header = "\x49\x44\x41\x54"
  case @mode # 请54~
  when 1
    data = make_bitmap_data#1
  else
    data = make_bitmap_data
  end
  data = Zlib::Deflate.deflate(data, 8)
  crc = [Zlib.crc32(header + data)].pack("N")
  size = [data.length].pack("N")
  return size + header + data + crc
end
#--------------------------------------------------------------------------
# ● 从Bitmap对象中生成图像数据 mode 1(请54~)
#--------------------------------------------------------------------------
def make_bitmap_data1
  w = @bitmap_Fx.width
  h = @bitmap_Fx.height
  data = []
  for y in 0...h
    data.push(0)
    for x in 0...w
      color = @bitmap_Fx.get_pixel(x, y)
      red = color.red
      green = color.green
      blue = color.blue
      alpha = color.alpha
      data.push(red)
      data.push(green)
      data.push(blue)
      data.push(alpha)
    end
  end
  return data.pack("C*")
end
#--------------------------------------------------------------------------
# ● 从Bitmap对象中生成图像数据 mode 0
#--------------------------------------------------------------------------
def make_bitmap_data
  gz = Zlib::GzipWriter.open('hoge.gz')
  t_Fx = 0
  w = @bitmap_Fx.width
  h = @bitmap_Fx.height
  data = []
  for y in 0...h
    data.push(0)
    for x in 0...w
      t_Fx += 1
      if t_Fx % 10000 == 0
        Graphics.update
      end
      if t_Fx % 100000 == 0
        s = data.pack("C*")
        gz.write(s)
        data.clear
        #GC.start
      end
      color = @bitmap_Fx.get_pixel(x, y)
      red = color.red
      green = color.green
      blue = color.blue
      alpha = color.alpha
      data.push(red)
      data.push(green)
      data.push(blue)
      data.push(alpha)
    end
  end
  s = data.pack("C*")
  gz.write(s)
  gz.close   
  data.clear
  gz = Zlib::GzipReader.open('hoge.gz')
  data = gz.read
  gz.close
  File.delete('hoge.gz')
  return data
end
#--------------------------------------------------------------------------
# ● PNG文件尾数据块(IEND)
#--------------------------------------------------------------------------
def make_iend
  ie_size = [0].pack("N")
  ie_sign = "IEND"
  ie_crc = [Zlib.crc32(ie_sign)].pack("N")
  return ie_size + ie_sign + ie_crc
end
  end
end
#==============================================================================
# â–  Bitmap
#------------------------------------------------------------------------------
#  关联到Bitmap。
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # ● 关联
  #--------------------------------------------------------------------------
  def make_png(name="like", path="",mode=0)
make_dir(path) if path != ""
Zlib::Png_File.open("temp.gz") {|gz|
  gz.make_png(self,mode)
}
Zlib::GzipReader.open("temp.gz") {|gz|
  $read = gz.read
}
f = File.open(path + name + ".png","wb")
f.write($read)
f.close
File.delete('temp.gz')
end
  #--------------------------------------------------------------------------
  # ● 生成保存路径
  #--------------------------------------------------------------------------
  def make_dir(path)
dir = path.split("/")
for i in 0...dir.size
  unless dir == "."
    add_dir = dir[0..i].join("/")
    begin
      Dir.mkdir(add_dir)
    rescue
    end
  end
end
  end
end
#==============================================================================
#           本脚本出自www.66rpg.com,转载请注明。
#==============================================================================

Code:
class VX_to_XP
  def initialize(quelle,ziel,type,shutdown=false)
	@quelle = quelle
	@ziel = ziel
 
	# Führe entsprechende Methode aus
	if type == "Characters" then
  	load_characters
	elsif type == "Faces" then
  	load_faces
	elsif type == "Tile" then
  	load_tiles
	elsif type == "Balloon" then
  	load_balloon
	elsif type == "Icons" then
  	load_icons
	elsif type == "A1" or type == "A2" or type == "A3" or type == "A4" then
  	load_autotile(type)
	elsif type == "Bigchar" then
  	load_bigchar
	end
 
	# Wenn shutdown true ist, beende das Programm
	if shutdown == true then
  	$scene = nil
	end
  end
 
 
  def load_characters
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	# Speichere original-Bitmap Höhe und Breite
	block_breite = original.bitmap.width / 4
	block_hoehe = original.bitmap.height / 2
 
	# Erstelle neuen Array
	@new_bitmap = Array.new(8)
	for br in 1..4
  	for he in [0,1]
 
    	# Errechne Additionswert add
    	if he == 0
      	then add = 0
      	else add = 4
    	end
 
    	#Erstelle neuen Sprite
    	@new_bitmap[br+add] = Sprite.new
    	#Erstelle neues Bitmap
    	@new_bitmap[br+add].bitmap = Bitmap.new(block_breite+(block_breite/3),block_hoehe)
    	#Setzte Rect fest
    	ausschnitt = Rect.new(((br-1)*block_breite)+(block_breite/3),he*block_hoehe,block_breite/3,block_hoehe)
    	#Kopiere Ausschnitt
    	@new_bitmap[br+add].bitmap.blt(0,0,original.bitmap,ausschnitt)
    	#Setzte Rect fest
    	ausschnitt = Rect.new((br-1)*block_breite,he*block_hoehe,block_breite,block_hoehe)
    	#Kopiere Ausschnitt
    	@new_bitmap[br+add].bitmap.blt(block_breite/3,0,original.bitmap,ausschnitt)
 
  	end
	end
	#Lösche den original-Sprite
	original.dispose
	#Speichere die Bitmaps
	for number in 1..8
  	@new_bitmap[number].bitmap.make_png("#{@ziel} - #{number}")
  	@new_bitmap[number].dispose
	end
  end
 
  def load_tiles
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	#Erstelle neuen Sprite
	@new_bitmap = Sprite.new
	#Erstelle neues Bitmap
	@new_bitmap.bitmap = Bitmap.new(256,1024)
	#Setzte Rect fest
	ausschnitt = Rect.new(0,0,256,512)
	#Kopiere Ausschnitt
	@new_bitmap.bitmap.blt(0,0,original.bitmap,ausschnitt)
	#Ändere Rect
	ausschnitt.x = 256
	#Kopiere Ausschnitt
	@new_bitmap.bitmap.blt(0,512,original.bitmap,ausschnitt)
	#Lösche den original-Sprite
	original.dispose
	#Speichere die Bitmaps
	@new_bitmap.bitmap.make_png("#{@ziel}")
	@new_bitmap.dispose
  end
 
  def load_faces
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	# Speichere original-Bitmap Höhe und Breite
	block_breite = original.bitmap.width / 4
	block_hoehe = original.bitmap.height / 2
 
	# Erstelle neuen Array
	@new_bitmap = Array.new(8)
	for br in 1..4
  	for he in [0,1]
 
    	# Errechne Additionswert add
    	if he == 0
      	then add = 0
      	else add = 4
    	end
 
    	#Erstelle neuen Sprite
    	@new_bitmap[br+add] = Sprite.new
    	#Erstelle neues Bitmap
    	@new_bitmap[br+add].bitmap = Bitmap.new(block_breite,block_hoehe)
    	#Setzte Rect fest
    	ausschnitt = Rect.new((br-1)*block_breite,he*block_hoehe,block_breite,block_hoehe)
    	#Kopiere Ausschnitt
    	@new_bitmap[br+add].bitmap.blt(0,0,original.bitmap,ausschnitt)
 
  	end
	end
	#Lösche den original-Sprite
	original.dispose
	#Speichere die Bitmaps
	for number in 1..8
  	@new_bitmap[number].bitmap.make_png("#{@ziel} - #{number}")
  	@new_bitmap[number].dispose
	end
  end
 
  def load_balloon
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	#Erstelle neuen Array
	@new_bitmap = Array.new(10)
	for nr in 1..10
  	#Erstelle neuen Sprite
  	@new_bitmap[nr] = Sprite.new
  	#Erstelle neues Bitmap
  	@new_bitmap[nr].bitmap = Bitmap.new(960,384)
	end
 
	for hoehe in 0..9
  	for breite in 0..7
    	#Lege Rect fest
    	ausschnitt = Rect.new(breite*32,hoehe*32,32,32)
    	# Bestimme anim
    	if breite <= 4 then
      	anim = breite, 0
    	else
      	anim = breite-5, 1
    	end
    	#Kopiere Ausschnitt auf @new_bitmap
    	@new_bitmap[hoehe+1].bitmap.blt((192*anim[0])+80,80+(192*anim[1]),original.bitmap,ausschnitt)
  	end
	end
	#Lösche den original-Sprite
	original.dispose
	#Speichere die Bitmaps
	for number in 1..10
  	@new_bitmap[number].bitmap.make_png("#{@ziel} - #{number}")
  	@new_bitmap[number].dispose
	end
  end
 
  def load_icons
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	#Lese Iconanzahl fest
	iconsx = original.bitmap.width/24
	iconsy = original.bitmap.height/24
	#Erstelle neuen Array
	@new_bitmap = Array.new(iconsx*iconsy)
	for nr in 1..@new_bitmap.size
  	#Erstelle neuen Sprite
  	@new_bitmap[nr] = Sprite.new
  	#Erstelle neues Bitmap
  	@new_bitmap[nr].bitmap = Bitmap.new(24,24)
	end
	add = 1
	for breite in 1..iconsx
  	for hoehe in 1..iconsy
    	#Lege Rect fest
    	ausschnitt = Rect.new(24*(breite-1),24*(hoehe-1),24,24)
    	#Kopere ausschnitt auf @new_bitmap
    	@new_bitmap[add].bitmap.blt(0,0,original.bitmap,ausschnitt)
    	@new_bitmap[add].y = (breite+add)*24
    	add += 1
  	end
	end
	#Lösche den original-Sprite
	original.dispose
	#Speichere die Bitmaps
	for number in 1..@new_bitmap.size-1
  	@new_bitmap[number].bitmap.make_png("#{@ziel} - #{number}")
  	@new_bitmap[number].dispose
	end
  end
 
  def tileA1
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
 
	# KONVERTIERE "WASSER"-AUTOTILES
 
	@new_bitmap = Array.new(16)
	add = 0
	for hoehe in 0..3
  	for breite in 0..1
    	add += 1
    	@new_bitmap[add] = Sprite.new
    	@new_bitmap[add].bitmap = Bitmap.new(288,128)
    	for animation in 0..2
      	convert_auto((64*animation)+(breite*256),hoehe*96,original.bitmap)
      	ausschnitt = Rect.new(0,0,96,128)
      	@new_bitmap[add].bitmap.blt(animation*96,0,$autotile_bitmap,ausschnitt)
    	end
    	$autotile_bitmap.dispose
  	end
	end
 
	# KONVERTIERE "WASSERFALL"-AUTOTILES
	wasserfall = Array.new(8)
	add = 0
 
	#Wandle Wasserfälle in normale VX-Autotiles
	for hoehe in 0..3
  	for breite in 0..1
    	if breite == 1 or hoehe > 1 then
      	add += 1
      	wasserfall[add] = Bitmap.new(192,96)
      	for animation in 0..2
        	#Erstelle Anzeige-Bild
        	rect = Rect.new(192+(breite*256),(hoehe*96)+(animation*32),16,16)
        	wasserfall[add].blt(animation*64,0,original.bitmap,rect)
        	rect.x += 48
        	wasserfall[add].blt(16+(animation*64),0,original.bitmap,rect)
        	rect.x -= 48
        	rect.y += 16
        	wasserfall[add].blt(animation*64,16,original.bitmap,rect)
        	rect.x += 48
        	wasserfall[add].blt(16+(animation*64),16,original.bitmap,rect)
 
        	#Erstelle Autotile-Rand
        	rect = Rect.new(animation*64,0,16,16)
        	wasserfall[add].blt(animation*64,32,wasserfall[add],rect)
        	wasserfall[add].blt(animation*64,64,wasserfall[add],rect)
        	rect.x += 16
        	wasserfall[add].blt(48+(animation*64),32,wasserfall[add],rect)
        	wasserfall[add].blt(48+(animation*64),64,wasserfall[add],rect)
        	rect.y += 16
        	wasserfall[add].blt(48+(animation*64),80,wasserfall[add],rect)
        	wasserfall[add].blt(48+(animation*64),48,wasserfall[add],rect)
        	rect.x -= 16
        	wasserfall[add].blt(animation*64,80,wasserfall[add],rect)
        	wasserfall[add].blt(animation*64,48,wasserfall[add],rect)
 
        	#Erstelle Autotile-Mitte
        	rect = Rect.new(208+breite*256,(hoehe*96)+(animation*32),32,32)
        	wasserfall[add].blt(16+animation*64,32,original.bitmap,rect)
        	wasserfall[add].blt(16+animation*64,64,original.bitmap,rect)
 
        	#Erstelle Autotile-Ecke
        	rect = Rect.new(16+(animation*64),48,32,32)
        	wasserfall[add].blt((animation*64)+32,0,wasserfall[add],rect)
       	end
    	end
  	end
	end
 
	#Wandle Wasserfälle zu XP-Autotiles um
	add = 0
	6.times do
  	add += 1
  	@new_bitmap[add+8] = Sprite.new
  	@new_bitmap[add+8].bitmap = Bitmap.new(288,128)
  	for x_wert in 0..2
    	convert_auto(x_wert*64,0,wasserfall[add])
    	rect = Rect.new(32,64,32,32)
    	$autotile_bitmap.blt(64,0,$autotile_bitmap,rect)
    	@new_bitmap[add+8].bitmap.blt(96*x_wert,0,$autotile_bitmap,ausschnitt)
    	$autotile_bitmap.dispose
  	end
	end
 
	# KONVERTIERE UNANIMIERTE AUTOTILES
	add = 0
	@new_bitmap[15] = Sprite.new
	@new_bitmap[15].bitmap = Bitmap.new(96,128)
	@new_bitmap[16] = Sprite.new
	@new_bitmap[16].bitmap = Bitmap.new(96,128)
	2.times do
  	convert_auto(192,(add*96),original.bitmap)
  	add += 1
  	ausschnitt = Rect.new(0,0,96,128)
  	@new_bitmap[add+14].bitmap.blt(0,0,$autotile_bitmap,ausschnitt)
  	$autotile_bitmap.dispose
	end
 
	#Lösche den original-Sprite
	original.dispose
 
	# Speichere die Autotiles
	for save in 1..8
  	@new_bitmap[save].bitmap.make_png("#{@ziel} W#{save}")
  	@new_bitmap[save].dispose
	end
 
	for save in 9..14
 	@new_bitmap[save].bitmap.make_png("#{@ziel} WF#{save-8}")
 	@new_bitmap[save].dispose
	end
 
	for save in 15..16
  	@new_bitmap[save].bitmap.make_png("#{@ziel} #{save-14}")
  	@new_bitmap[save].dispose
	end
  end
 
 
 
  def load_autotile(type)
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	if type == "A1" then
  	tileA1
	elsif type == "A2" then
  	tileA2
	elsif type == "A3" then
  	tileA3
	elsif type == "A4" then
  	tileA4
	end
  end
 
  def convert_auto(x,y,bitmap)
	$autotile_bitmap = Bitmap.new(96,128)
 
	rect = Rect.new(x+32,y,32,32)
	$autotile_bitmap.blt(64,0,bitmap,rect)
	rect = Rect.new(x,y,32,32)
	$autotile_bitmap.blt(0,0,bitmap,rect)
 
	rect = Rect.new(x,y+32,16,16)
	$autotile_bitmap.blt(0,32,bitmap,rect)
	rect = Rect.new(x+48,y+32,16,16)
	$autotile_bitmap.blt(80,32,bitmap,rect)
	rect = Rect.new(x,y+80,16,16)
	$autotile_bitmap.blt(0,112,bitmap,rect)
	rect = Rect.new(x+48,y+80,16,16)
	$autotile_bitmap.blt(80,112,bitmap,rect)
 
	rect = Rect.new(x+16,y+32,32,16)
	$autotile_bitmap.blt(16,32,bitmap,rect)
	rect = Rect.new(x,y+48,16,32)
	$autotile_bitmap.blt(0,48,bitmap,rect)
	rect = Rect.new(x+48,y+48,16,32)
	$autotile_bitmap.blt(80,48,bitmap,rect)
	rect = Rect.new(x+16,y+80,32,16)
	$autotile_bitmap.blt(16,112,bitmap,rect)
 
	rect = Rect.new(x+16,y+32,32,16)
	$autotile_bitmap.blt(48,32,bitmap,rect)
	rect = Rect.new(x,y+48,16,32)
	$autotile_bitmap.blt(0,80,bitmap,rect)
	rect = Rect.new(x+48,y+48,16,32)
	$autotile_bitmap.blt(80,80,bitmap,rect)
	rect = Rect.new(x+16,y+80,32,16)
	$autotile_bitmap.blt(48,112,bitmap,rect)
 
	rect = Rect.new(x+16,y+48,32,32)
	$autotile_bitmap.blt(16,48,bitmap,rect)
	rect = Rect.new(x+16,y+48,32,32)
	$autotile_bitmap.blt(16,80,bitmap,rect)
	rect = Rect.new(x+16,y+48,32,32)
	$autotile_bitmap.blt(48,48,bitmap,rect)
	rect = Rect.new(x+16,y+48,32,32)
	$autotile_bitmap.blt(48,80,bitmap,rect)
 
	return $autotile_bitmap
  end
 
  def tileA2
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	# Erstelle neuen Array
	@new_bitmap = Array.new(32)
 
	add = 0
	#Wandle VX-Autotiles in XP-Autotiles
	for breite in 0..7
  	for hoehe in 0..3
    	add += 1
    	@new_bitmap[add] = Sprite.new
    	@new_bitmap[add].bitmap = Bitmap.new(96,128)
    	convert_auto(breite*64,hoehe*96,original.bitmap)
    	rect = Rect.new(0,0,96,128)
    	@new_bitmap[add].bitmap.blt(0,0,$autotile_bitmap,rect)
  	end
	end
 
	#Lösche den original-Sprite
	original.dispose
 
	#Speichere die Autotiles
	for save in 1..32
  	@new_bitmap[save].bitmap.make_png("#{@ziel} - #{save}")
  	@new_bitmap[save].dispose
	end
  end
 
  def tileA3
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	# Erstelle neuen Array und neues Bitmap
	@new_bitmap = Array.new(32)
	@tileset = Bitmap.new(256,512)
 
	rect = Rect.new(0,0,256,256)
	@tileset.blt(0,0,original.bitmap,rect)
	rect.x += 256
	@tileset.blt(0,256,original.bitmap,rect)
 
	#Wandle die Tiles in VX-Autotiles
	vxp = Array.new(32)
	add = 0
	for hoehe in 0..3
  	for breite in 0..7
    	add += 1
    	vxp[add] = Bitmap.new(64,96)
    	rect = Rect.new(breite*64,hoehe*64,64,64)
    	vxp[add].blt(0,32,original.bitmap,rect)
    	rect = Rect.new(0,32,16,16)
    	vxp[add].blt(0,0,vxp[add],rect)
    	rect.x += 32
    	vxp[add].blt(16,0,vxp[add],rect)
    	rect.y += 32
    	vxp[add].blt(16,16,vxp[add],rect)
    	rect.x -= 32
    	vxp[add].blt(0,16,vxp[add],rect)
  	end
	end
 
	# Wandle vxp in XP-Autotiles
	for add in 1..32
  	convert_auto(0,0,vxp[add])
  	rect = Rect.new(32,64,32,32)
  	$autotile_bitmap.blt(64,0,$autotile_bitmap,rect)
  	@new_bitmap[add] = Sprite.new
  	@new_bitmap[add].bitmap = Bitmap.new(96,128)
  	rect = Rect.new(0,0,96,128)
  	@new_bitmap[add].bitmap.blt(0,0,$autotile_bitmap,rect)
	end
 
	#Lösche den original-Sprite
	original.dispose
 
	#Speichere die Bitmaps
	for save in 1..32
  	@new_bitmap[save].bitmap.make_png("#{@ziel} - #{save}")
  	@new_bitmap[save].dispose
	end
 
	@tileset.make_png("Tileset A3")
  end
 
  def tileA4
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	# Erstelle neuen Array und neues Bitmap
	@new_bitmap = Array.new(48)
	for bit in 1..64
  	@new_bitmap[bit] = Sprite.new
  	@new_bitmap[bit].bitmap = Bitmap.new(96,128)
	end
	@tileset = Bitmap.new(256,768)
 
	#Erstelle die Tiles als komplettes Set
	add = 0
	for br in 0..1
  	for he in 0..2
    	rect = Rect.new(br*256,(he*160)+32,256,128)
    	@tileset.blt(0,add*128,original.bitmap,rect)
    	add += 1
  	end
	end
  # @tileset.make_png("#{@ziel} Tileset")
  @tileset.dispose
 
	#Konvertiere die bereits fertigen Autotiles
	add = 0
	for breite in 0..7
  	for hoehe in 0..2
    	add += 1
    	convert_auto(breite*64,hoehe*160,original.bitmap)
    	rect = Rect.new(0,0,96,128)
    	@new_bitmap[add].bitmap.blt(0,0,$autotile_bitmap,rect)
  	end
	end
 
	#Wandle die Mauern in VX-Autotiles um
	vxp = Array.new(24)
	add = 0
	for breite in 0..7
  	for hoehe in 0..2
    	add += 1
    	vxp[add] = Bitmap.new(64,96)
    	rect = Rect.new(breite*64,(hoehe*160)+96,64,64)
    	vxp[add].blt(0,32,original.bitmap,rect)
    	rect = Rect.new(0,32,16,16)
    	vxp[add].blt(0,0,vxp[add],rect)
    	rect.x += 48
    	vxp[add].blt(16,0,vxp[add],rect)
    	rect.y += 48
    	vxp[add].blt(16,16,vxp[add],rect)
    	rect.x -= 48
    	vxp[add].blt(0,16,vxp[add],rect)
  	end
	end
 
	#Wandle die VX-Mauer-Autotiles in XP um
	for add in 1..24
  	convert_auto(0,0,vxp[add])
  	rect = Rect.new(32,64,32,32)
  	$autotile_bitmap.blt(64,0,$autotile_bitmap,rect)
  	rect = Rect.new(0,0,96,128)
  	@new_bitmap[add+24].bitmap.blt(0,0,$autotile_bitmap,rect)
	end
 
	#Lösche den original-Sprite
	original.dispose
 
	for save in 1..48
  	@new_bitmap[save].bitmap.make_png("#{@ziel} - #{save}")
  	@new_bitmap[save].dispose
	end
  end
 
  def load_bigchar
	# Erstelle original-Sprite
	original = Sprite.new
	# Erstelle original-Bitmap
	original.bitmap = Bitmap.new(@quelle)
	#Lese Breite und Höhe
	breite = original.bitmap.width
	hoehe = original.bitmap.height
	#Erstelle neues Bitmap
	@new_bitmap = Sprite.new
	@new_bitmap.bitmap = Bitmap.new(breite+breite/3,hoehe)
 
	rect = Rect.new(0,0,breite,hoehe)
	@new_bitmap.bitmap.blt(breite/3,0,original.bitmap,rect)
	rect = Rect.new(breite/3,0,breite/3,hoehe)
	@new_bitmap.bitmap.blt(0,0,original.bitmap,rect)
 
	#Lösche den original-Sprite
	original.dispose
	#Speichere die Bitmaps
	@new_bitmap.bitmap.make_png("#{@ziel}")
	@new_bitmap.dispose
  end
end

Code:
class Extras
  def initialize(quelle,ziel,type,shutdown=false)
	@quelle = quelle
	@ziel = ziel
 
	# Führe entsprechende Methode aus
	if type == "Tilefusion" then
  	load_tilefusion
	elsif type == "Autofusion" then
  	load_autofusion
	end
 
	# Wenn shutdown true ist, beende das Programm
	if shutdown == true then
  	$scene = nil
	end
  end
 
  def load_tilefusion
	#Lade die Tilesets
	hoehe = 0
	for load in 0..@quelle.size-1
  	@quelle[load] = Bitmap.new(@quelle[load])
  	hoehe += @quelle[load].height
	end
	#Erstelle ein neues Bitmap
	@new_bitmap = Bitmap.new(256,hoehe)
	#Fusioniere die Tilesets
	hoehe = 0
	for fus in 0..@quelle.size-1
  	rect = Rect.new(0,0,256,@quelle[fus].height)
  	@new_bitmap.blt(0,hoehe,@quelle[fus],rect)
  	hoehe += @quelle[fus].height
	end
	#Speichere das Tileset
	@new_bitmap.make_png("#{@ziel}")
  end
 
  def load_autofusion
	#Lade die beiden Bilder
	for load in [0,1]
  	@quelle[load] = Bitmap.new(@quelle[load])
	end
	#Wenn eins der beiden ein einziges Tile ist, wandle es um
	for load in [0,1]
  	if @quelle[load].width == 32 and @quelle[load].height == 32 then
    	temp = Bitmap.new(32,32)
    	rect = Rect.new(0,0,32,32)
    	temp.blt(0,0,@quelle[load],rect)
    	@quelle[load] = Bitmap.new(96,128)
    	@quelle[load].blt(0,0,temp,rect)
    	@quelle[load].blt(64,0,temp,rect)
    	for h in 1..3
      	for b in 0..2
        	@quelle[load].blt(b*32,h*32,temp,rect)
      	end
    	end
  	end
	end
 
	#Lege das zweite Autotile über das erste
	rect = Rect.new(0,0,96,128)
	@quelle[0].blt(0,0,@quelle[1],rect)
	#Speichere das Bitmap
	@quelle[0].make_png("#{@ziel}")
  end
end

/edit:
Here is the Demo http://www.megaupload.com/de/?d=ZKML1ZN9
 

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