#===================================================================
# * CGI Movies
#------------------------------------------------------------------------------------------------------------
# Create cutscenes and movies using images, like what Square-Enix is doing for Final Fantasy 12
#------------------------------------------------------------------------------------------------------------
# Tsunokiette
# Version 3
# 11.22.05
#=======================================================================
#**********************
# Create RPG::Cache.CGI
#**********************
module RPG
module Cache
def self.CGI(filename)
self.load_bitmap("Data/cgi/", filename)
end
end
end
#************************
# Start CGI Movies Script
#************************
class Scene_CGI
attr_accessor :cgi_over
#-------------------------------------------------------------------------
# Initialize the CGI Movie
#-------------------------------------------------------------------------
# cgi_folder = folder containing CGI images
# scene = the scene to return to after CGI plays
# skip = set to true if you want to be able to skip movie by pressing esc.
#-------------------------------------------------------------------------
def initialize(cgi_folder, name, scene, skip = false, above = true)
@folder = cgi_folder
@name = name
@scene = scene
@folder_size = Dir.entries("Data/cgi/#{@folder}").size
@skip = skip
@cgi_over = false
@above = above
@count = Graphics.frame_count
setup_cgi
end
#-------------------
# Main Processing
#-------------------
def main
loop do
play_cgi if !@cgi_over
break if @cgi_over
end
@cgi_over = false
$scene = @scene
end
#-------------------
# Play the CGI Movie
#-------------------
def play_cgi
if Graphics.frame_count - @count >= 10
@count = Graphics.frame_count
self.src_rect = Rect.new(@frame * @frame_height, @frame * @frame_width, @frame_width, @frame_height)
@frame += 1
# if we've reached the end of the frames for this pose
if @frame == @frames[@pose]
@cgi_over = true
@frame = 0
end
end
end
#-----------------------
# Setup the Sprite sheet
#-----------------------
def setup_gi
#Setup variables
bitmaps = []
height = width = 0
@frame_height = 0
@frames = 0
dummy_image = Bitmap.new(1, 1)
#Make a loop and find allthe files
for i in 1..(@folder_size - 2)
#Gets the picture/bitmap
if i >= 100
bitmaps[i] = RPG::Cache.CGI("#{@folder}/#{@name}#{i}")
elsif i >= 10
bitmaps[i] = RPG::Cache.CGI("#{@folder}/#{@name}0#{i}")
else
bitmaps[i] = RPG::Cache.CGI("#{@folder}/#{@name}00#{i}")
end
@frames += i
@frame_height = bitmaps[i].height
@frame_width = bitmaps[i].width
end
@sprite_sheet = Bitmap.new(width, height)
mark = 0
for i in 0..bitmaps.size
@sprite_sheet.blt(0, mark, bitmaps[i], bitmaps[i].rect) if bitmaps[i] != nil
mark += @frame_height
end
end
#------
# Delay
#------
def delay(wait)
count = Graphics.frame_count
while wait + count >= Graphics.frame_count
Graphics.update
end
end
end
#**********************
# End CGI Movies Script
#**********************