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.

Image lag and other problems.

@cgi.z is the toggle thing u want

use it under @cgi.y

The lag is caused because it adds new Bitmaps each time. The only way I know to fix it is by putting all the of them in 1 Bitmap and then using Rect class to show parts.

There is an Exampl on how to do it in Ccoa's CBS, if anyone wants to look
 

arev

Sponsor

use avi player.
just kiddin', I'm using this one too. I didn't notice any lagging though.
try lowering the quality of the images, hte lags could be due to your machine.
as for the depth... I'm guessing you mean the z coordinate?
if so, try adding it under:
Code:
@cgi.y = ((480 - @cgi.bitmap.height) / 2)
z of 5000 should be above all.
 
@arevulopapo, myno is right ;)

it is not lag, considering RGSS, it is just transition.

@myno
no, simpler then that lol. You don't have to do anything.

I can rewrite and post it, give me some time. I'll do now.
 
Myonosken said:
No it just crashes.
Edit: The delay probably stops all pictures loading at once.

ok, i figured.. he does it in a weird way.

Test this;

Code:
#===================================================================
#  * 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
#**********************
 
500.. hmm. Interesting lol.

It lags. I know why ;) In long LOOPs you have to do;

Graphics.update

Here is the fix :P

Code:
#===============================================================================
#  * 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
        # Update game screen
        Graphics.update
        # Update input information
        Input.update
        #Go to next frame if the movie is not over
        play_cgi if !@cgi_over
        #Exit
        break if @cgi_over
      end
      #Dispose all the graphics.
      for i in 0..@bitmaps.size
        next if @bitmaps[i] == nil
        @bitmaps[i].dispose
      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_cgi
     #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
      Graphics.update
    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
#-------------------------------------------------------------------------

Hope it works
 
Can you ZIP and Upload and PM me the link for the pic so I can also try?

I will fix this!!

Edit::

Try this ;)

Code:
#===============================================================================
#  * 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
        # Update game screen
        Graphics.update
        # Update input information
        Input.update
        #Go to next frame if the movie is not over
        play_cgi if !@cgi_over
        #Exit
        break if @cgi_over
      end
      #Dispose all the graphics.
      for i in 0..@bitmaps.size
        next if @bitmaps[i] == nil
        @bitmaps[i].dispose
        Graphics.update
      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_cgi
     #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
      Graphics.update
    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
      Graphics.update
    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
#-------------------------------------------------------------------------
 

Anonymous

Guest

I might of missed something, but why don't you just play an actual video instead of having 500+ pictures?

~ Mysteerie
 
Done :)

Code:
#===============================================================================
#  * 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
      @sprite_sheet = Sprite.new
      z = (@above == true ? 999 : 0)
      @sprite_sheet.z = z
      @sprite_sheet.bitmap = Bitmap.new(640,480)
      @i = 0
      for i in 0..(@folder_size - 2)
        #Gets the picture/bitmap
        play_cgi
        Graphics.update
      end
    end
   #-------------------------------------------------------------------------
   # Main Processing
   #-------------------------------------------------------------------------
   def main
     #Dispose all the graphics.
     @sprite_sheet.dispose
     @cgi_over = false
     $scene = @scene
   end
   #-------------------------------------------------------------------------
   # Play the CGI Movie
   #-------------------------------------------------------------------------
   def play_cgi
     return if @cgi_over
     RPG::Cache.clear
     if @i >= 100
       bitmaps = RPG::Cache.CGI("#{@folder}/#{@name}#{@i}")
     elsif @i >= 10 and @i < 100
       bitmaps = RPG::Cache.CGI("#{@folder}/#{@name}0#{@i}")
     elsif @i <= 9
       bitmaps = RPG::Cache.CGI("#{@folder}/#{@name}00#{@i}")
     end
     @sprite_sheet.bitmap.clear
     @sprite_sheet.bitmap.blt(0,0,bitmaps,bitmaps.rect)
     # if we've reached the end of the frames for this pose
     @i += 1
   end
   #-------------------------------------------------------------------------
   # Delay
   #-------------------------------------------------------------------------
   def delay(wait)
      count = Graphics.frame_count
      while wait + count >= Graphics.frame_count
         Graphics.update
      end
   end
end
#-------------------------------------------------------------------------
# End CGI Movies Script
#-------------------------------------------------------------------------
 
crashes? what do u mean crashes? also do this in initialize before the for loop

Graphics.frame_rate = w/e (default 20 or 40)

and put one in def main so that it goes back to normal;
Graphics.frame_rate = 40
 

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